[FFmpeg-cvslog] avcodec/cuviddec: backport extradata fixes

Timo Rothenpieler git at videolan.org
Thu Oct 1 23:34:56 EEST 2020


ffmpeg | branch: release/3.4 | Timo Rothenpieler <timo at rothenpieler.org> | Thu Oct  1 20:20:48 2020 +0200| [8f5e16b5f129f6d62b5135bd095c41e64998d2ed] | committer: Timo Rothenpieler

avcodec/cuviddec: backport extradata fixes

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8f5e16b5f129f6d62b5135bd095c41e64998d2ed
---

 libavcodec/cuvid.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index fba252995d..c93d85adcc 100644
--- a/libavcodec/cuvid.c
+++ b/libavcodec/cuvid.c
@@ -802,7 +802,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,
@@ -972,20 +972,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;
 



More information about the ffmpeg-cvslog mailing list