You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
vulkan_decode: allow using NULL offsets/nb_slices in ff_vk_decode_add_slice()
For codecs like VP9 which use a single slice.
This commit is contained in:
@ -257,7 +257,7 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp,
|
|||||||
|
|
||||||
static const uint8_t startcode_prefix[3] = { 0x0, 0x0, 0x1 };
|
static const uint8_t startcode_prefix[3] = { 0x0, 0x0, 0x1 };
|
||||||
const size_t startcode_len = add_startcode ? sizeof(startcode_prefix) : 0;
|
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;
|
uint8_t *slices;
|
||||||
uint32_t *slice_off;
|
uint32_t *slice_off;
|
||||||
FFVkBuffer *vkbuf;
|
FFVkBuffer *vkbuf;
|
||||||
@ -266,13 +266,16 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp,
|
|||||||
ctx->caps.minBitstreamBufferSizeAlignment;
|
ctx->caps.minBitstreamBufferSizeAlignment;
|
||||||
new_size = FFALIGN(new_size, ctx->caps.minBitstreamBufferSizeAlignment);
|
new_size = FFALIGN(new_size, ctx->caps.minBitstreamBufferSizeAlignment);
|
||||||
|
|
||||||
slice_off = av_fast_realloc(dec->slice_off, &dec->slice_off_max,
|
if (offsets) {
|
||||||
(nb + 1)*sizeof(slice_off));
|
slice_off = av_fast_realloc(dec->slice_off, &dec->slice_off_max,
|
||||||
if (!slice_off)
|
(nb + 1)*sizeof(slice_off));
|
||||||
return AVERROR(ENOMEM);
|
if (!slice_off)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
*offsets = dec->slice_off = slice_off;
|
*offsets = dec->slice_off = slice_off;
|
||||||
slice_off[nb] = vp->slices_size;
|
|
||||||
|
slice_off[nb] = vp->slices_size;
|
||||||
|
}
|
||||||
|
|
||||||
vkbuf = vp->slices_buf ? (FFVkBuffer *)vp->slices_buf->data : NULL;
|
vkbuf = vp->slices_buf ? (FFVkBuffer *)vp->slices_buf->data : NULL;
|
||||||
if (!vkbuf || vkbuf->size < new_size) {
|
if (!vkbuf || vkbuf->size < new_size) {
|
||||||
@ -318,7 +321,9 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp,
|
|||||||
/* Slice data */
|
/* Slice data */
|
||||||
memcpy(slices + vp->slices_size + startcode_len, data, size);
|
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;
|
vp->slices_size += startcode_len + size;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user