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

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
207207 ctx->caps.minBitstreamBufferSizeAlignment;
208208 new_size = FFALIGN(new_size, ctx->caps.minBitstreamBufferSizeAlignment);
209209
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,
211211 (nb + 1)*sizeof(slice_off));
212212 if (!slice_off)
213213 return AVERROR(ENOMEM);
214214
215− *offsets = vp->slice_off = slice_off;
215+ *offsets = dec->slice_off = slice_off;
216216 slice_off[nb] = vp->slices_size;
217217
218218 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
538538 /* Free slices data */
539539 av_buffer_unref(&vp->slices_buf);
540540
541− /* TODO: use a pool in the decode context instead to avoid per-frame allocs. */
542− av_freep(&vp->slice_off);
543−
544541 /* Destroy image view (out) */
545542 if (vp->img_view_out && vp->img_view_out != vp->img_view_dest)
546543 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
10351032 av_buffer_pool_uninit(&dec->tmp_pool);
10361033 av_buffer_unref(&dec->session_params);
10371034 av_buffer_unref(&dec->shared_ref);
1035+ av_freep(&dec->slice_off);
10381036 return 0;
10391037 }
10401038
libavcodec/vulkan_decode.h+3−2
@@ -66,6 +66,9 @@ typedef struct FFVulkanDecodeContext { · 65 unmodified lines
6666 AVBufferPool *tmp_pool; /* Pool for temporary data, if needed (HEVC) */
6767 size_t tmp_pool_ele_size;
6868 int params_changed;
69+
70+ uint32_t *slice_off;
71+ unsigned int slice_off_max;
6972 } FFVulkanDecodeContext;
7073
7174 typedef struct FFVulkanDecodePicture {
@@ -94,8 +97,6 @@ typedef struct FFVulkanDecodePicture { · 22 unmodified lines
9497 /* Slice data */
9598 AVBufferRef *slices_buf;
9699 size_t slices_size;
97− uint32_t *slice_off;
98− unsigned int slice_off_max;
99100 } FFVulkanDecodePicture;
100101
101102 /**
libavcodec/vulkan_h264.c+0−1
@@ -463,7 +463,6 @@ static int vk_h264_start_frame(AVCodecContext *avctx, · 462 unmodified lines
463463 hp->h264_pic_info = (VkVideoDecodeH264PictureInfoKHR) {
464464 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_KHR,
465465 .pStdPictureInfo = &hp->h264pic,
466− .sliceCount = 0,
467466 };
468467
469468 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
855855 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR,
856856 .pStdPictureInfo = &hp->h265pic,
857857 .sliceSegmentCount = 0,
858− .pSliceSegmentOffsets = vp->slice_off,
859858 };
860859
861860 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