]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/cuvid: Fully re-initialize the parser after a flush.
authorPhilip Langdale <philipl@overt.org>
Thu, 15 Sep 2016 02:56:07 +0000 (19:56 -0700)
committerTimo Rothenpieler <timo@rothenpieler.org>
Sat, 17 Sep 2016 12:08:53 +0000 (14:08 +0200)
I'm not really sure how this worked at all before, but we do need to
reinitalize the parser with the stream extradata.

Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
libavcodec/cuvid.c

index 19a7772258edf84b2d817d0810a08c81ab984e9a..131000591eca798dcc804ade06f78dd368bc7d21 100644 (file)
@@ -706,6 +706,7 @@ static void cuvid_flush(AVCodecContext *avctx)
     AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)ctx->hwdevice->data;
     AVCUDADeviceContext *device_hwctx = device_ctx->hwctx;
     CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx;
+    CUVIDSOURCEDATAPACKET seq_pkt = { 0 };
     int ret;
 
     ctx->ever_flushed = 1;
@@ -736,6 +737,15 @@ static void cuvid_flush(AVCodecContext *avctx)
     if (ret < 0)
         goto error;
 
+    seq_pkt.payload = ctx->cuparse_ext.raw_seqhdr_data;
+    seq_pkt.payload_size = ctx->cuparse_ext.format.seqhdr_data_length;
+
+    if (seq_pkt.payload && seq_pkt.payload_size) {
+        ret = CHECK_CU(cuvidParseVideoData(ctx->cuparser, &seq_pkt));
+        if (ret < 0)
+            goto error;
+    }
+
     ret = CHECK_CU(cuCtxPopCurrent(&dummy));
     if (ret < 0)
         goto error;