aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2018-05-08 12:12:01 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2018-05-10 00:34:22 +0200
commit9b82e333b7c4235a3de7ce8d8fe115c53c11f50c (patch)
tree3702d9fb5ab9e56c2025d31a52dce992eb3d172a /libavutil
parent880236e898fdc2610a60b644b8d802bc299e4d71 (diff)
downloadffmpeg-9b82e333b7c4235a3de7ce8d8fe115c53c11f50c.tar.gz
avutil/hwcontext_cuda: explicitly synchronize cuMemcpy calls
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/hwcontext_cuda.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
index f3e81680e9..668293bffc 100644
--- a/libavutil/hwcontext_cuda.c
+++ b/libavutil/hwcontext_cuda.c
@@ -258,13 +258,19 @@ static int cuda_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,
.Height = src->height >> (i ? priv->shift_height : 0),
};
- err = cu->cuMemcpy2D(&cpy);
+ err = cu->cuMemcpy2DAsync(&cpy, device_hwctx->stream);
if (err != CUDA_SUCCESS) {
av_log(ctx, AV_LOG_ERROR, "Error transferring the data from the CUDA frame\n");
return AVERROR_UNKNOWN;
}
}
+ err = cu->cuStreamSynchronize(device_hwctx->stream);
+ if (err != CUDA_SUCCESS) {
+ av_log(ctx, AV_LOG_ERROR, "Error synchronizing CUDA stream\n");
+ return AVERROR_UNKNOWN;
+ }
+
cu->cuCtxPopCurrent(&dummy);
return 0;
@@ -297,13 +303,19 @@ static int cuda_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
.Height = src->height >> (i ? priv->shift_height : 0),
};
- err = cu->cuMemcpy2D(&cpy);
+ err = cu->cuMemcpy2DAsync(&cpy, device_hwctx->stream);
if (err != CUDA_SUCCESS) {
- av_log(ctx, AV_LOG_ERROR, "Error transferring the data from the CUDA frame\n");
+ av_log(ctx, AV_LOG_ERROR, "Error transferring the data to the CUDA frame\n");
return AVERROR_UNKNOWN;
}
}
+ err = cu->cuStreamSynchronize(device_hwctx->stream);
+ if (err != CUDA_SUCCESS) {
+ av_log(ctx, AV_LOG_ERROR, "Error synchronizing CUDA stream\n");
+ return AVERROR_UNKNOWN;
+ }
+
cu->cuCtxPopCurrent(&dummy);
return 0;