ffmpeg | branch: master | Lynne <d...@lynne.ee> | Thu Mar 27 12:49:06 2025 +0000| [193610d9bac1fc00f99975f13c1370aec816f930] | committer: Lynne
vulkan_decode: allow using NULL offsets/nb_slices in ff_vk_decode_add_slice() For codecs like VP9 which use a single slice. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=193610d9bac1fc00f99975f13c1370aec816f930 --- libavcodec/vulkan_decode.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c index cab1028e2c..93aa0ce5b3 100644 --- a/libavcodec/vulkan_decode.c +++ b/libavcodec/vulkan_decode.c @@ -257,7 +257,7 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp, static const uint8_t startcode_prefix[3] = { 0x0, 0x0, 0x1 }; const size_t startcode_len = add_startcode ? sizeof(startcode_prefix) : 0; - const int nb = *nb_slices; + const int nb = nb_slices ? *nb_slices : 0; uint8_t *slices; uint32_t *slice_off; FFVkBuffer *vkbuf; @@ -266,13 +266,16 @@ 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(dec->slice_off, &dec->slice_off_max, - (nb + 1)*sizeof(slice_off)); - if (!slice_off) - return AVERROR(ENOMEM); + if (offsets) { + slice_off = av_fast_realloc(dec->slice_off, &dec->slice_off_max, + (nb + 1)*sizeof(slice_off)); + if (!slice_off) + return AVERROR(ENOMEM); - *offsets = dec->slice_off = slice_off; - slice_off[nb] = vp->slices_size; + *offsets = dec->slice_off = slice_off; + + slice_off[nb] = vp->slices_size; + } vkbuf = vp->slices_buf ? (FFVkBuffer *)vp->slices_buf->data : NULL; if (!vkbuf || vkbuf->size < new_size) { @@ -318,7 +321,9 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp, /* Slice data */ memcpy(slices + vp->slices_size + startcode_len, data, size); - *nb_slices = nb + 1; + if (nb_slices) + *nb_slices = nb + 1; + vp->slices_size += startcode_len + size; return 0; _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".