History

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.

Lynne committed 3 years ago

Commit ba8a8031 parent 237c4004 files · +6 −9Browse files

Showing the changes to libavcodec (4 of 4 files). Show all

Unified · Split

4 files
  1. libavcodec/vulkan_decode.c +3 −5
  2. libavcodec/vulkan_decode.h +3 −2
  3. libavcodec/vulkan_h264.c +0 −1
  4. libavcodec/vulkan_hevc.c +0 −1
libavcodec/vulkan_decode.c+3−5
@@ -207,12 +207,12 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp, · 206 unmodified lines
207 ctx->caps.minBitstreamBufferSizeAlignment;207 ctx->caps.minBitstreamBufferSizeAlignment;
208 new_size = FFALIGN(new_size, ctx->caps.minBitstreamBufferSizeAlignment);208 new_size = FFALIGN(new_size, ctx->caps.minBitstreamBufferSizeAlignment);
209 209
210 slice_off = av_fast_realloc(vp->slice_off, &vp->slice_off_max,210 slice_off = av_fast_realloc(dec->slice_off, &dec->slice_off_max,
211 (nb + 1)*sizeof(slice_off));211 (nb + 1)*sizeof(slice_off));
212 if (!slice_off)212 if (!slice_off)
213 return AVERROR(ENOMEM);213 return AVERROR(ENOMEM);
214 214
215 *offsets = vp->slice_off = slice_off;215 *offsets = dec->slice_off = slice_off;
216 slice_off[nb] = vp->slices_size;216 slice_off[nb] = vp->slices_size;
217 217
218 vkbuf = vp->slices_buf ? (FFVkVideoBuffer *)vp->slices_buf->data : NULL;218 vkbuf = vp->slices_buf ? (FFVkVideoBuffer *)vp->slices_buf->data : NULL;
@@ -538,9 +538,6 @@ void ff_vk_decode_free_frame(AVHWDeviceContext *dev_ctx, FFVulkanDecodePicture * · 319 unmodified lines
538 /* Free slices data */538 /* Free slices data */
539 av_buffer_unref(&vp->slices_buf);539 av_buffer_unref(&vp->slices_buf);
540 540
541 /* TODO: use a pool in the decode context instead to avoid per-frame allocs. */
542 av_freep(&vp->slice_off);
543
544 /* Destroy image view (out) */541 /* Destroy image view (out) */
545 if (vp->img_view_out && vp->img_view_out != vp->img_view_dest)542 if (vp->img_view_out && vp->img_view_out != vp->img_view_dest)
546 destroy_image_view(hwctx->act_dev, vp->img_view_out, hwctx->alloc);543 destroy_image_view(hwctx->act_dev, vp->img_view_out, hwctx->alloc);
@@ -1035,6 +1032,7 @@ int ff_vk_decode_uninit(AVCodecContext *avctx) · 488 unmodified lines
1035 av_buffer_pool_uninit(&dec->tmp_pool);1032 av_buffer_pool_uninit(&dec->tmp_pool);
1036 av_buffer_unref(&dec->session_params);1033 av_buffer_unref(&dec->session_params);
1037 av_buffer_unref(&dec->shared_ref);1034 av_buffer_unref(&dec->shared_ref);
1035 av_freep(&dec->slice_off);
1038 return 0;1036 return 0;
1039}1037}
1040 1038
libavcodec/vulkan_decode.h+3−2
@@ -66,6 +66,9 @@ typedef struct FFVulkanDecodeContext { · 65 unmodified lines
66 AVBufferPool *tmp_pool; /* Pool for temporary data, if needed (HEVC) */66 AVBufferPool *tmp_pool; /* Pool for temporary data, if needed (HEVC) */
67 size_t tmp_pool_ele_size;67 size_t tmp_pool_ele_size;
68 int params_changed;68 int params_changed;
69
70 uint32_t *slice_off;
71 unsigned int slice_off_max;
69} FFVulkanDecodeContext;72} FFVulkanDecodeContext;
70 73
71typedef struct FFVulkanDecodePicture {74typedef struct FFVulkanDecodePicture {
@@ -94,8 +97,6 @@ typedef struct FFVulkanDecodePicture { · 22 unmodified lines
94 /* Slice data */97 /* Slice data */
95 AVBufferRef *slices_buf;98 AVBufferRef *slices_buf;
96 size_t slices_size;99 size_t slices_size;
97 uint32_t *slice_off;
98 unsigned int slice_off_max;
99} FFVulkanDecodePicture;100} FFVulkanDecodePicture;
100 101
101/**102/**
libavcodec/vulkan_h264.c+0−1
@@ -463,7 +463,6 @@ static int vk_h264_start_frame(AVCodecContext *avctx, · 462 unmodified lines
463 hp->h264_pic_info = (VkVideoDecodeH264PictureInfoKHR) {463 hp->h264_pic_info = (VkVideoDecodeH264PictureInfoKHR) {
464 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_KHR,464 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_KHR,
465 .pStdPictureInfo = &hp->h264pic,465 .pStdPictureInfo = &hp->h264pic,
466 .sliceCount = 0,
467 };466 };
468 467
469 vp->decode_info = (VkVideoDecodeInfoKHR) {468 vp->decode_info = (VkVideoDecodeInfoKHR) {
libavcodec/vulkan_hevc.c+0−1
@@ -855,7 +855,6 @@ static int vk_hevc_start_frame(AVCodecContext *avctx, · 854 unmodified lines
855 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR,855 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR,
856 .pStdPictureInfo = &hp->h265pic,856 .pStdPictureInfo = &hp->h265pic,
857 .sliceSegmentCount = 0,857 .sliceSegmentCount = 0,
858 .pSliceSegmentOffsets = vp->slice_off,
859 };858 };
860 859
861 vp->decode_info = (VkVideoDecodeInfoKHR) {860 vp->decode_info = (VkVideoDecodeInfoKHR) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t