1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avutil/hwcontext_cuda: explicitly synchronize cuMemcpy calls

This commit is contained in:
Timo Rothenpieler 2018-05-08 12:12:01 +02:00
parent 880236e898
commit 9b82e333b7

View File

@ -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;