| @@ -130,9 +130,11 @@ static void init_frame(FFVulkanDecodeContext *dec, FFVulkanDecodePicture *vkpic) · 129 unmodified lines |
| 130 | 130 | FFVulkanFunctions *vk = &ctx->s.vkfn; |
| 131 | 131 | |
| 132 | 132 | vkpic->dpb_frame = NULL; |
| 133 | | − vkpic->img_view_ref = VK_NULL_HANDLE; |
| 134 | | − vkpic->img_view_out = VK_NULL_HANDLE; |
| 135 | | − vkpic->img_view_dest = VK_NULL_HANDLE; |
| 133 | + for (int i = 0; i < AV_NUM_DATA_POINTERS; i++) { |
| 134 | + vkpic->view.ref[i] = VK_NULL_HANDLE; |
| 135 | + vkpic->view.out[i] = VK_NULL_HANDLE; |
| 136 | + vkpic->view.dst[i] = VK_NULL_HANDLE; |
| 137 | + } |
| 136 | 138 | |
| 137 | 139 | vkpic->destroy_image_view = vk->DestroyImageView; |
| 138 | 140 | vkpic->wait_semaphores = vk->WaitSemaphores; |
| @@ -149,14 +151,14 @@ int ff_vk_decode_prepare_frame(FFVulkanDecodeContext *dec, AVFrame *pic, · 10 unmodified lines |
| 149 | 151 | |
| 150 | 152 | /* If the decoder made a blank frame to make up for a missing ref, or the |
| 151 | 153 | * frame is the current frame so it's missing one, create a re-representation */ |
| 152 | | − if (vkpic->img_view_ref) |
| 154 | + if (vkpic->view.ref[0]) |
| 153 | 155 | return 0; |
| 154 | 156 | |
| 155 | 157 | init_frame(dec, vkpic); |
| 156 | 158 | |
| 157 | 159 | if (ctx->common.layered_dpb && alloc_dpb) { |
| 158 | | − vkpic->img_view_ref = ctx->common.layered_view; |
| 159 | | − vkpic->img_aspect_ref = ctx->common.layered_aspect; |
| 160 | + vkpic->view.ref[0] = ctx->common.layered_view; |
| 161 | + vkpic->view.aspect_ref[0] = ctx->common.layered_aspect; |
| 160 | 162 | } else if (alloc_dpb) { |
| 161 | 163 | AVHWFramesContext *dpb_frames = (AVHWFramesContext *)ctx->common.dpb_hwfc_ref->data; |
| 162 | 164 | AVVulkanFramesContext *dpb_hwfc = dpb_frames->hwctx; |
| @@ -166,13 +168,13 @@ int ff_vk_decode_prepare_frame(FFVulkanDecodeContext *dec, AVFrame *pic, · 3 unmodified lines |
| 166 | 168 | return AVERROR(ENOMEM); |
| 167 | 169 | |
| 168 | 170 | err = ff_vk_create_view(&ctx->s, &ctx->common, |
| 169 | | − &vkpic->img_view_ref, &vkpic->img_aspect_ref, |
| 171 | + &vkpic->view.ref[0], &vkpic->view.aspect_ref[0], |
| 170 | 172 | (AVVkFrame *)vkpic->dpb_frame->data[0], |
| 171 | 173 | dpb_hwfc->format[0], !is_current); |
| 172 | 174 | if (err < 0) |
| 173 | 175 | return err; |
| 174 | 176 | |
| 175 | | − vkpic->img_view_dest = vkpic->img_view_ref; |
| 177 | + vkpic->view.dst[0] = vkpic->view.ref[0]; |
| 176 | 178 | } |
| 177 | 179 | |
| 178 | 180 | if (!alloc_dpb || is_current) { |
| @@ -180,15 +182,15 @@ int ff_vk_decode_prepare_frame(FFVulkanDecodeContext *dec, AVFrame *pic, · 1 unmodified line |
| 180 | 182 | AVVulkanFramesContext *hwfc = frames->hwctx; |
| 181 | 183 | |
| 182 | 184 | err = ff_vk_create_view(&ctx->s, &ctx->common, |
| 183 | | − &vkpic->img_view_out, &vkpic->img_aspect, |
| 185 | + &vkpic->view.out[0], &vkpic->view.aspect[0], |
| 184 | 186 | (AVVkFrame *)pic->data[0], |
| 185 | 187 | hwfc->format[0], !is_current); |
| 186 | 188 | if (err < 0) |
| 187 | 189 | return err; |
| 188 | 190 | |
| 189 | 191 | if (!alloc_dpb) { |
| 190 | | − vkpic->img_view_ref = vkpic->img_view_out; |
| 191 | | − vkpic->img_aspect_ref = vkpic->img_aspect; |
| 192 | + vkpic->view.ref[0] = vkpic->view.out[0]; |
| 193 | + vkpic->view.aspect_ref[0] = vkpic->view.aspect[0]; |
| 192 | 194 | } |
| 193 | 195 | } |
| 194 | 196 | |
| @@ -201,41 +203,41 @@ int ff_vk_decode_prepare_frame_sdr(FFVulkanDecodeContext *dec, AVFrame *pic, · 6 unmodified lines |
| 201 | 203 | { |
| 202 | 204 | int err; |
| 203 | 205 | FFVulkanDecodeShared *ctx = dec->shared_ctx; |
| 206 | + AVHWFramesContext *frames = (AVHWFramesContext *)pic->hw_frames_ctx->data; |
| 204 | 207 | |
| 205 | 208 | vkpic->slices_size = 0; |
| 206 | 209 | |
| 207 | | − if (vkpic->img_view_ref) |
| 210 | + if (vkpic->view.ref[0]) |
| 208 | 211 | return 0; |
| 209 | 212 | |
| 210 | 213 | init_frame(dec, vkpic); |
| 211 | 214 | |
| 212 | | − if (ctx->common.layered_dpb && alloc_dpb) { |
| 213 | | − vkpic->img_view_ref = ctx->common.layered_view; |
| 214 | | − vkpic->img_aspect_ref = ctx->common.layered_aspect; |
| 215 | | − } else if (alloc_dpb) { |
| 216 | | − vkpic->dpb_frame = vk_get_dpb_pool(ctx); |
| 217 | | − if (!vkpic->dpb_frame) |
| 218 | | − return AVERROR(ENOMEM); |
| 215 | + for (int i = 0; i < av_pix_fmt_count_planes(frames->sw_format); i++) { |
| 216 | + if (alloc_dpb) { |
| 217 | + vkpic->dpb_frame = vk_get_dpb_pool(ctx); |
| 218 | + if (!vkpic->dpb_frame) |
| 219 | + return AVERROR(ENOMEM); |
| 219 | 220 | |
| 220 | | − err = ff_vk_create_imageview(&ctx->s, |
| 221 | | − &vkpic->img_view_ref, &vkpic->img_aspect_ref, |
| 222 | | − vkpic->dpb_frame, 0, rep_fmt); |
| 223 | | − if (err < 0) |
| 224 | | − return err; |
| 221 | + err = ff_vk_create_imageview(&ctx->s, |
| 222 | + &vkpic->view.ref[i], &vkpic->view.aspect_ref[i], |
| 223 | + vkpic->dpb_frame, i, rep_fmt); |
| 224 | + if (err < 0) |
| 225 | + return err; |
| 225 | 226 | |
| 226 | | − vkpic->img_view_dest = vkpic->img_view_ref; |
| 227 | | − } |
| 227 | + vkpic->view.dst[i] = vkpic->view.ref[i]; |
| 228 | + } |
| 228 | 229 | |
| 229 | | − if (!alloc_dpb || is_current) { |
| 230 | | − err = ff_vk_create_imageview(&ctx->s, |
| 231 | | − &vkpic->img_view_out, &vkpic->img_aspect, |
| 232 | | − pic, 0, rep_fmt); |
| 233 | | − if (err < 0) |
| 234 | | − return err; |
| 230 | + if (!alloc_dpb || is_current) { |
| 231 | + err = ff_vk_create_imageview(&ctx->s, |
| 232 | + &vkpic->view.out[i], &vkpic->view.aspect[i], |
| 233 | + pic, i, rep_fmt); |
| 234 | + if (err < 0) |
| 235 | + return err; |
| 235 | 236 | |
| 236 | | − if (!alloc_dpb) { |
| 237 | | − vkpic->img_view_ref = vkpic->img_view_out; |
| 238 | | − vkpic->img_aspect_ref = vkpic->img_aspect; |
| 237 | + if (!alloc_dpb) { |
| 238 | + vkpic->view.ref[i] = vkpic->view.out[i]; |
| 239 | + vkpic->view.aspect_ref[i] = vkpic->view.aspect[i]; |
| 240 | + } |
| 239 | 241 | } |
| 240 | 242 | } |
| 241 | 243 | |
| @@ -467,7 +469,7 @@ int ff_vk_decode_frame(AVCodecContext *avctx, · 225 unmodified lines |
| 467 | 469 | .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, |
| 468 | 470 | .image = vkf->img[0], |
| 469 | 471 | .subresourceRange = (VkImageSubresourceRange) { |
| 470 | | − .aspectMask = vp->img_aspect, |
| 472 | + .aspectMask = vp->view.aspect[0], |
| 471 | 473 | .layerCount = 1, |
| 472 | 474 | .levelCount = 1, |
| 473 | 475 | }, |
| @@ -523,7 +525,7 @@ int ff_vk_decode_frame(AVCodecContext *avctx, · 49 unmodified lines |
| 523 | 525 | .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, |
| 524 | 526 | .image = rvkf->img[0], |
| 525 | 527 | .subresourceRange = (VkImageSubresourceRange) { |
| 526 | | − .aspectMask = rvp->img_aspect_ref, |
| 528 | + .aspectMask = rvp->view.aspect_ref[0], |
| 527 | 529 | .layerCount = 1, |
| 528 | 530 | .levelCount = 1, |
| 529 | 531 | }, |
| @@ -533,7 +535,7 @@ int ff_vk_decode_frame(AVCodecContext *avctx, · 3 unmodified lines |
| 533 | 535 | } |
| 534 | 536 | } |
| 535 | 537 | } else if (vp->decode_info.referenceSlotCount || |
| 536 | | − vp->img_view_out != vp->img_view_ref) { |
| 538 | + vp->view.out[0] != vp->view.ref[0]) { |
| 537 | 539 | /* Single barrier for a single layered ref */ |
| 538 | 540 | err = ff_vk_exec_add_dep_frame(&ctx->s, exec, ctx->common.layered_frame, |
| 539 | 541 | VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR, |
| @@ -580,12 +582,14 @@ void ff_vk_decode_free_frame(AVHWDeviceContext *dev_ctx, FFVulkanDecodePicture * · 40 unmodified lines |
| 580 | 582 | av_buffer_unref(&vp->slices_buf); |
| 581 | 583 | |
| 582 | 584 | /* Destroy image view (out) */ |
| 583 | | − if (vp->img_view_out && vp->img_view_out != vp->img_view_dest) |
| 584 | | − vp->destroy_image_view(hwctx->act_dev, vp->img_view_out, hwctx->alloc); |
| 585 | + for (int i = 0; i < AV_NUM_DATA_POINTERS; i++) { |
| 586 | + if (vp->view.out[i] && vp->view.out[i] != vp->view.dst[i]) |
| 587 | + vp->destroy_image_view(hwctx->act_dev, vp->view.out[i], hwctx->alloc); |
| 585 | 588 | |
| 586 | | − /* Destroy image view (ref, unlayered) */ |
| 587 | | − if (vp->img_view_dest) |
| 588 | | − vp->destroy_image_view(hwctx->act_dev, vp->img_view_dest, hwctx->alloc); |
| 589 | + /* Destroy image view (ref, unlayered) */ |
| 590 | + if (vp->view.dst[i]) |
| 591 | + vp->destroy_image_view(hwctx->act_dev, vp->view.dst[i], hwctx->alloc); |
| 592 | + } |
| 589 | 593 | |
| 590 | 594 | av_frame_free(&vp->dpb_frame); |
| 591 | 595 | } |