avcodec/cuviddec: explicitly synchronize cuMemcpy calls
authorTimo Rothenpieler <timo@rothenpieler.org>
Tue, 8 May 2018 11:56:51 +0000 (13:56 +0200)
committerTimo Rothenpieler <timo@rothenpieler.org>
Wed, 9 May 2018 22:34:22 +0000 (00:34 +0200)
libavcodec/cuviddec.c

index 122c28f..4d3caf9 100644 (file)
@@ -550,12 +550,16 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame)
                     .Height        = avctx->height >> (i ? 1 : 0),
                 };
 
-                ret = CHECK_CU(ctx->cudl->cuMemcpy2D(&cpy));
+                ret = CHECK_CU(ctx->cudl->cuMemcpy2DAsync(&cpy, device_hwctx->stream));
                 if (ret < 0)
                     goto error;
 
                 offset += avctx->height;
             }
+
+            ret = CHECK_CU(ctx->cudl->cuStreamSynchronize(device_hwctx->stream));
+            if (ret < 0)
+                goto error;
         } else if (avctx->pix_fmt == AV_PIX_FMT_NV12 ||
                    avctx->pix_fmt == AV_PIX_FMT_P010 ||
                    avctx->pix_fmt == AV_PIX_FMT_P016) {