diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c index d4395e32e4..685e300e8a 100644 --- a/libavcodec/vulkan_decode.c +++ b/libavcodec/vulkan_decode.c @@ -207,12 +207,12 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp, ctx->caps.minBitstreamBufferSizeAlignment; new_size = FFALIGN(new_size, ctx->caps.minBitstreamBufferSizeAlignment); - slice_off = av_fast_realloc(vp->slice_off, &vp->slice_off_max, + slice_off = av_fast_realloc(dec->slice_off, &dec->slice_off_max, (nb + 1)*sizeof(slice_off)); if (!slice_off) return AVERROR(ENOMEM); - *offsets = vp->slice_off = slice_off; + *offsets = dec->slice_off = slice_off; slice_off[nb] = vp->slices_size; vkbuf = vp->slices_buf ? (FFVkVideoBuffer *)vp->slices_buf->data : NULL; @@ -538,9 +538,6 @@ void ff_vk_decode_free_frame(AVHWDeviceContext *dev_ctx, FFVulkanDecodePicture * /* Free slices data */ av_buffer_unref(&vp->slices_buf); - /* TODO: use a pool in the decode context instead to avoid per-frame allocs. */ - av_freep(&vp->slice_off); - /* Destroy image view (out) */ if (vp->img_view_out && vp->img_view_out != vp->img_view_dest) destroy_image_view(hwctx->act_dev, vp->img_view_out, hwctx->alloc); @@ -1035,6 +1032,7 @@ int ff_vk_decode_uninit(AVCodecContext *avctx) av_buffer_pool_uninit(&dec->tmp_pool); av_buffer_unref(&dec->session_params); av_buffer_unref(&dec->shared_ref); + av_freep(&dec->slice_off); return 0; } diff --git a/libavcodec/vulkan_decode.h b/libavcodec/vulkan_decode.h index bb53100429..776538a335 100644 --- a/libavcodec/vulkan_decode.h +++ b/libavcodec/vulkan_decode.h @@ -66,6 +66,9 @@ typedef struct FFVulkanDecodeContext { AVBufferPool *tmp_pool; /* Pool for temporary data, if needed (HEVC) */ size_t tmp_pool_ele_size; int params_changed; + + uint32_t *slice_off; + unsigned int slice_off_max; } FFVulkanDecodeContext; typedef struct FFVulkanDecodePicture { @@ -94,8 +97,6 @@ typedef struct FFVulkanDecodePicture { /* Slice data */ AVBufferRef *slices_buf; size_t slices_size; - uint32_t *slice_off; - unsigned int slice_off_max; } FFVulkanDecodePicture; /** diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c index 4cfd83fc19..d0b66734d1 100644 --- a/libavcodec/vulkan_h264.c +++ b/libavcodec/vulkan_h264.c @@ -463,7 +463,6 @@ static int vk_h264_start_frame(AVCodecContext *avctx, hp->h264_pic_info = (VkVideoDecodeH264PictureInfoKHR) { .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_KHR, .pStdPictureInfo = &hp->h264pic, - .sliceCount = 0, }; vp->decode_info = (VkVideoDecodeInfoKHR) { diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c index 5ddfd0daf3..a1df0766fa 100644 --- a/libavcodec/vulkan_hevc.c +++ b/libavcodec/vulkan_hevc.c @@ -855,7 +855,6 @@ static int vk_hevc_start_frame(AVCodecContext *avctx, .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR, .pStdPictureInfo = &hp->h265pic, .sliceSegmentCount = 0, - .pSliceSegmentOffsets = vp->slice_off, }; vp->decode_info = (VkVideoDecodeInfoKHR) {