diff mbox

[FFmpeg-devel,5/5] avcodec/cuviddec: explicitly synchronize cuMemcpy calls

Message ID 20180508183640.13605-5-timo@rothenpieler.org
State New
Headers show

Commit Message

Timo Rothenpieler May 8, 2018, 6:36 p.m. UTC
---
 libavcodec/cuviddec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 122c28f6e8..4d3caf924e 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -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) {