1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-02-04 06:08:26 +02:00

vulkan_decode: clean up slice handling

Move the slice offsets buffer to the thread decode context.
It isn't part of the resources for frame decoding, the driver
has to process and finish with it at submission time.
That way, it doesn't need to be alloc'd + freed on every frame.
This commit is contained in:
Lynne 2023-06-20 03:37:34 +02:00
parent 237c400727
commit ba8a803236
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
4 changed files with 6 additions and 9 deletions

View File

@ -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;
}

View File

@ -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;
/**

View File

@ -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) {

View File

@ -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) {