diff options
author | Timo Rothenpieler <timo@rothenpieler.org> | 2020-10-01 21:20:48 +0300 |
---|---|---|
committer | Timo Rothenpieler <timo@rothenpieler.org> | 2020-10-01 23:18:05 +0300 |
commit | 0c7dc6105224cd199b8e966bc76aafaeaacb2061 (patch) | |
tree | 050a1ee528837655a540818c948e80b9806d7a7f /libavcodec | |
parent | 968836e233ce296f74a48efc20f286aa77d43b21 (diff) |
avcodec/cuviddec: backport extradata fixes
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/cuviddec.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index bd1a5ca0ce..8b98bc6cdf 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -815,7 +815,7 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) CUcontext dummy; const AVBitStreamFilter *bsf; uint8_t *extradata; - uint32_t extradata_size; + int extradata_size; int ret = 0; enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_CUDA, @@ -985,20 +985,21 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) extradata = ctx->bsf->par_out->extradata; extradata_size = ctx->bsf->par_out->extradata_size; - } else if (avctx->extradata_size > 0) { + } else { extradata = avctx->extradata; extradata_size = avctx->extradata_size; } ctx->cuparse_ext = av_mallocz(sizeof(*ctx->cuparse_ext) - + FFMAX(extradata_size - sizeof(ctx->cuparse_ext->raw_seqhdr_data), 0)); + + FFMAX(extradata_size - (int)sizeof(ctx->cuparse_ext->raw_seqhdr_data), 0)); if (!ctx->cuparse_ext) { ret = AVERROR(ENOMEM); goto error; } - ctx->cuparse_ext->format.seqhdr_data_length = avctx->extradata_size; - memcpy(ctx->cuparse_ext->raw_seqhdr_data, extradata, extradata_size); + if (extradata_size > 0) + memcpy(ctx->cuparse_ext->raw_seqhdr_data, extradata, extradata_size); + ctx->cuparse_ext->format.seqhdr_data_length = extradata_size; ctx->cuparseinfo.pExtVideoInfo = ctx->cuparse_ext; |