28 VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR,
34 VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR
44 #define ASPECT_2PLANE (VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT)
45 #define ASPECT_3PLANE (VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT | VK_IMAGE_ASPECT_PLANE_2_BIT)
58 { VK_FORMAT_R16G16B16A16_UNORM,
AV_PIX_FMT_XV36, VK_IMAGE_ASPECT_COLOR_BIT },
59 { VK_FORMAT_B8G8R8A8_UNORM,
AV_PIX_FMT_BGRA, VK_IMAGE_ASPECT_COLOR_BIT },
60 { VK_FORMAT_R8G8B8A8_UNORM,
AV_PIX_FMT_RGBA, VK_IMAGE_ASPECT_COLOR_BIT },
67 { VK_FORMAT_B8G8R8A8_UNORM,
AV_PIX_FMT_BGR0, VK_IMAGE_ASPECT_COLOR_BIT },
68 { VK_FORMAT_R8G8B8A8_UNORM,
AV_PIX_FMT_RGB0, VK_IMAGE_ASPECT_COLOR_BIT },
112 { VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16,
AV_PIX_FMT_Y210, VK_IMAGE_ASPECT_COLOR_BIT },
113 { VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16,
AV_PIX_FMT_Y212, VK_IMAGE_ASPECT_COLOR_BIT },
130 return VK_IMAGE_ASPECT_NONE;
135 if (
desc->nb_components == 1)
136 return VK_VIDEO_CHROMA_SUBSAMPLING_MONOCHROME_BIT_KHR;
137 else if (!
desc->log2_chroma_w && !
desc->log2_chroma_h)
138 return VK_VIDEO_CHROMA_SUBSAMPLING_444_BIT_KHR;
139 else if (!
desc->log2_chroma_w &&
desc->log2_chroma_h == 1)
140 return VK_VIDEO_CHROMA_SUBSAMPLING_422_BIT_KHR;
141 else if (
desc->log2_chroma_w == 1 &&
desc->log2_chroma_h == 1)
142 return VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR;
143 return VK_VIDEO_CHROMA_SUBSAMPLING_INVALID_KHR;
149 case 8:
return VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR;
150 case 10:
return VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR;
151 case 12:
return VK_VIDEO_COMPONENT_BIT_DEPTH_12_BIT_KHR;
154 return VK_VIDEO_COMPONENT_BIT_DEPTH_INVALID_KHR;
160 case STD_VIDEO_H264_LEVEL_IDC_1_0:
return 10;
161 case STD_VIDEO_H264_LEVEL_IDC_1_1:
return 11;
162 case STD_VIDEO_H264_LEVEL_IDC_1_2:
return 12;
163 case STD_VIDEO_H264_LEVEL_IDC_1_3:
return 13;
164 case STD_VIDEO_H264_LEVEL_IDC_2_0:
return 20;
165 case STD_VIDEO_H264_LEVEL_IDC_2_1:
return 21;
166 case STD_VIDEO_H264_LEVEL_IDC_2_2:
return 22;
167 case STD_VIDEO_H264_LEVEL_IDC_3_0:
return 30;
168 case STD_VIDEO_H264_LEVEL_IDC_3_1:
return 31;
169 case STD_VIDEO_H264_LEVEL_IDC_3_2:
return 32;
170 case STD_VIDEO_H264_LEVEL_IDC_4_0:
return 40;
171 case STD_VIDEO_H264_LEVEL_IDC_4_1:
return 41;
172 case STD_VIDEO_H264_LEVEL_IDC_4_2:
return 42;
173 case STD_VIDEO_H264_LEVEL_IDC_5_0:
return 50;
174 case STD_VIDEO_H264_LEVEL_IDC_5_1:
return 51;
175 case STD_VIDEO_H264_LEVEL_IDC_5_2:
return 52;
176 case STD_VIDEO_H264_LEVEL_IDC_6_0:
return 60;
177 case STD_VIDEO_H264_LEVEL_IDC_6_1:
return 61;
179 case STD_VIDEO_H264_LEVEL_IDC_6_2:
return 62;
186 case STD_VIDEO_H265_LEVEL_IDC_1_0:
return 10;
187 case STD_VIDEO_H265_LEVEL_IDC_2_0:
return 20;
188 case STD_VIDEO_H265_LEVEL_IDC_2_1:
return 21;
189 case STD_VIDEO_H265_LEVEL_IDC_3_0:
return 30;
190 case STD_VIDEO_H265_LEVEL_IDC_3_1:
return 31;
191 case STD_VIDEO_H265_LEVEL_IDC_4_0:
return 40;
192 case STD_VIDEO_H265_LEVEL_IDC_4_1:
return 41;
193 case STD_VIDEO_H265_LEVEL_IDC_5_0:
return 50;
194 case STD_VIDEO_H265_LEVEL_IDC_5_1:
return 51;
195 case STD_VIDEO_H265_LEVEL_IDC_6_0:
return 60;
196 case STD_VIDEO_H265_LEVEL_IDC_6_1:
return 61;
198 case STD_VIDEO_H265_LEVEL_IDC_6_2:
return 62;
226 void *create_pNext,
size_t size)
266 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
283 FFVkVideoCommon *common)
287 if (common->session) {
288 vk->DestroyVideoSessionKHR(
s->hwctx->act_dev, common->session,
290 common->session =
NULL;
293 if (common->nb_mem && common->mem)
294 for (
int i = 0;
i < common->nb_mem;
i++)
295 vk->FreeMemory(
s->hwctx->act_dev, common->mem[
i],
s->hwctx->alloc);
303 FFVkVideoCommon *common,
304 VkVideoSessionCreateInfoKHR *session_create)
309 VkMemoryRequirements2 *mem_req =
NULL;
310 VkVideoSessionMemoryRequirementsKHR *mem =
NULL;
311 VkBindVideoSessionMemoryInfoKHR *bind_mem =
NULL;
314 ret = vk->CreateVideoSessionKHR(
s->hwctx->act_dev, session_create,
315 s->hwctx->alloc, &common->session);
316 if (
ret != VK_SUCCESS)
320 ret = vk->GetVideoSessionMemoryRequirementsKHR(
s->hwctx->act_dev,
324 if (
ret != VK_SUCCESS) {
330 common->mem =
av_mallocz(
sizeof(*common->mem)*common->nb_mem);
335 mem =
av_mallocz(
sizeof(*mem)*common->nb_mem);
340 mem_req =
av_mallocz(
sizeof(*mem_req)*common->nb_mem);
345 bind_mem =
av_mallocz(
sizeof(*bind_mem)*common->nb_mem);
352 for (
int i = 0;
i < common->nb_mem;
i++) {
353 mem_req[
i] = (VkMemoryRequirements2) {
354 .sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
356 mem[
i] = (VkVideoSessionMemoryRequirementsKHR) {
357 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_MEMORY_REQUIREMENTS_KHR,
358 .memoryRequirements = mem_req[
i].memoryRequirements,
363 ret = vk->GetVideoSessionMemoryRequirementsKHR(
s->hwctx->act_dev,
364 common->session, &common->nb_mem,
366 if (
ret != VK_SUCCESS) {
373 for (
int i = 0;
i < common->nb_mem;
i++) {
375 UINT32_MAX,
NULL,
NULL, &common->mem[
i]);
379 bind_mem[
i] = (VkBindVideoSessionMemoryInfoKHR) {
380 .sType = VK_STRUCTURE_TYPE_BIND_VIDEO_SESSION_MEMORY_INFO_KHR,
381 .memory = common->mem[
i],
382 .memoryBindIndex = mem[
i].memoryBindIndex,
384 .memorySize = mem[
i].memoryRequirements.size,
388 bind_mem[
i].memorySize, bind_mem[
i].memoryBindIndex);
392 ret = vk->BindVideoSessionMemoryKHR(
s->hwctx->act_dev, common->session,
393 common->nb_mem, bind_mem);
394 if (
ret != VK_SUCCESS) {