21 #define ASPECT_2PLANE (VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT)
22 #define ASPECT_3PLANE (VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT | VK_IMAGE_ASPECT_PLANE_2_BIT)
35 { VK_FORMAT_R16G16B16A16_UNORM,
AV_PIX_FMT_XV36, VK_IMAGE_ASPECT_COLOR_BIT },
36 { VK_FORMAT_B8G8R8A8_UNORM,
AV_PIX_FMT_BGRA, VK_IMAGE_ASPECT_COLOR_BIT },
37 { VK_FORMAT_R8G8B8A8_UNORM,
AV_PIX_FMT_RGBA, VK_IMAGE_ASPECT_COLOR_BIT },
44 { VK_FORMAT_B8G8R8A8_UNORM,
AV_PIX_FMT_BGR0, VK_IMAGE_ASPECT_COLOR_BIT },
45 { VK_FORMAT_R8G8B8A8_UNORM,
AV_PIX_FMT_RGB0, VK_IMAGE_ASPECT_COLOR_BIT },
89 { VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16,
AV_PIX_FMT_Y210, VK_IMAGE_ASPECT_COLOR_BIT },
90 { VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16,
AV_PIX_FMT_Y212, VK_IMAGE_ASPECT_COLOR_BIT },
107 return VK_IMAGE_ASPECT_NONE;
112 if (
desc->nb_components == 1)
113 return VK_VIDEO_CHROMA_SUBSAMPLING_MONOCHROME_BIT_KHR;
114 else if (!
desc->log2_chroma_w && !
desc->log2_chroma_h)
115 return VK_VIDEO_CHROMA_SUBSAMPLING_444_BIT_KHR;
116 else if (!
desc->log2_chroma_w &&
desc->log2_chroma_h == 1)
117 return VK_VIDEO_CHROMA_SUBSAMPLING_422_BIT_KHR;
118 else if (
desc->log2_chroma_w == 1 &&
desc->log2_chroma_h == 1)
119 return VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR;
120 return VK_VIDEO_CHROMA_SUBSAMPLING_INVALID_KHR;
126 case 8:
return VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR;
127 case 10:
return VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR;
128 case 12:
return VK_VIDEO_COMPONENT_BIT_DEPTH_12_BIT_KHR;
131 return VK_VIDEO_COMPONENT_BIT_DEPTH_INVALID_KHR;
137 case STD_VIDEO_H264_LEVEL_IDC_1_0:
return 10;
138 case STD_VIDEO_H264_LEVEL_IDC_1_1:
return 11;
139 case STD_VIDEO_H264_LEVEL_IDC_1_2:
return 12;
140 case STD_VIDEO_H264_LEVEL_IDC_1_3:
return 13;
141 case STD_VIDEO_H264_LEVEL_IDC_2_0:
return 20;
142 case STD_VIDEO_H264_LEVEL_IDC_2_1:
return 21;
143 case STD_VIDEO_H264_LEVEL_IDC_2_2:
return 22;
144 case STD_VIDEO_H264_LEVEL_IDC_3_0:
return 30;
145 case STD_VIDEO_H264_LEVEL_IDC_3_1:
return 31;
146 case STD_VIDEO_H264_LEVEL_IDC_3_2:
return 32;
147 case STD_VIDEO_H264_LEVEL_IDC_4_0:
return 40;
148 case STD_VIDEO_H264_LEVEL_IDC_4_1:
return 41;
149 case STD_VIDEO_H264_LEVEL_IDC_4_2:
return 42;
150 case STD_VIDEO_H264_LEVEL_IDC_5_0:
return 50;
151 case STD_VIDEO_H264_LEVEL_IDC_5_1:
return 51;
152 case STD_VIDEO_H264_LEVEL_IDC_5_2:
return 52;
153 case STD_VIDEO_H264_LEVEL_IDC_6_0:
return 60;
154 case STD_VIDEO_H264_LEVEL_IDC_6_1:
return 61;
156 case STD_VIDEO_H264_LEVEL_IDC_6_2:
return 62;
163 case STD_VIDEO_H265_LEVEL_IDC_1_0:
return 10;
164 case STD_VIDEO_H265_LEVEL_IDC_2_0:
return 20;
165 case STD_VIDEO_H265_LEVEL_IDC_2_1:
return 21;
166 case STD_VIDEO_H265_LEVEL_IDC_3_0:
return 30;
167 case STD_VIDEO_H265_LEVEL_IDC_3_1:
return 31;
168 case STD_VIDEO_H265_LEVEL_IDC_4_0:
return 40;
169 case STD_VIDEO_H265_LEVEL_IDC_4_1:
return 41;
170 case STD_VIDEO_H265_LEVEL_IDC_5_0:
return 50;
171 case STD_VIDEO_H265_LEVEL_IDC_5_1:
return 51;
172 case STD_VIDEO_H265_LEVEL_IDC_6_0:
return 60;
173 case STD_VIDEO_H265_LEVEL_IDC_6_1:
return 61;
175 case STD_VIDEO_H265_LEVEL_IDC_6_2:
return 62;
203 void *create_pNext,
size_t size)
243 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
260 FFVkVideoCommon *common)
264 if (common->session) {
265 vk->DestroyVideoSessionKHR(
s->hwctx->act_dev, common->session,
267 common->session = VK_NULL_HANDLE;
270 if (common->nb_mem && common->mem)
271 for (
int i = 0;
i < common->nb_mem;
i++)
272 vk->FreeMemory(
s->hwctx->act_dev, common->mem[
i],
s->hwctx->alloc);
280 FFVkVideoCommon *common,
281 VkVideoSessionCreateInfoKHR *session_create)
286 VkVideoSessionMemoryRequirementsKHR *mem =
NULL;
287 VkBindVideoSessionMemoryInfoKHR *bind_mem =
NULL;
290 ret = vk->CreateVideoSessionKHR(
s->hwctx->act_dev, session_create,
291 s->hwctx->alloc, &common->session);
292 if (
ret != VK_SUCCESS)
296 ret = vk->GetVideoSessionMemoryRequirementsKHR(
s->hwctx->act_dev,
300 if (
ret != VK_SUCCESS) {
306 common->mem =
av_mallocz(
sizeof(*common->mem)*common->nb_mem);
311 mem =
av_mallocz(
sizeof(*mem)*common->nb_mem);
316 bind_mem =
av_mallocz(
sizeof(*bind_mem)*common->nb_mem);
323 for (
int i = 0;
i < common->nb_mem;
i++) {
324 mem[
i] = (VkVideoSessionMemoryRequirementsKHR) {
325 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_MEMORY_REQUIREMENTS_KHR,
330 ret = vk->GetVideoSessionMemoryRequirementsKHR(
s->hwctx->act_dev,
331 common->session, &common->nb_mem,
333 if (
ret != VK_SUCCESS) {
340 for (
int i = 0;
i < common->nb_mem;
i++) {
342 UINT32_MAX,
NULL,
NULL, &common->mem[
i]);
346 bind_mem[
i] = (VkBindVideoSessionMemoryInfoKHR) {
347 .sType = VK_STRUCTURE_TYPE_BIND_VIDEO_SESSION_MEMORY_INFO_KHR,
348 .memory = common->mem[
i],
349 .memoryBindIndex = mem[
i].memoryBindIndex,
351 .memorySize = mem[
i].memoryRequirements.size,
355 bind_mem[
i].memorySize, bind_mem[
i].memoryBindIndex);
359 ret = vk->BindVideoSessionMemoryKHR(
s->hwctx->act_dev, common->session,
360 common->nb_mem, bind_mem);
361 if (
ret != VK_SUCCESS) {