summaryrefslogtreecommitdiff
path: root/libavcodec/nvenc.c
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2019-09-27 18:30:10 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2019-09-27 20:00:59 +0200
commit51a23343d9c736217d8845b7442fafc373726433 (patch)
tree2604b423e4c5b4acf0c503c32f67bf0b1c7fe9f9 /libavcodec/nvenc.c
parent567b5e33d9d77919ee920c091f4273c5b38fc821 (diff)
downloadffmpeg-51a23343d9c736217d8845b7442fafc373726433.tar.gz
avcodec/nvenc: pass CUstream to nvenc when available
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r--libavcodec/nvenc.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 8a7347b84e..2de2bfdacb 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -460,6 +460,7 @@ static av_cold int nvenc_check_device(AVCodecContext *avctx, int idx)
goto fail;
ctx->cu_context = ctx->cu_context_internal;
+ ctx->cu_stream = NULL;
if ((ret = nvenc_pop_context(avctx)) < 0)
goto fail2;
@@ -546,6 +547,7 @@ static av_cold int nvenc_setup_device(AVCodecContext *avctx)
if (cuda_device_hwctx) {
ctx->cu_context = cuda_device_hwctx->cuda_ctx;
+ ctx->cu_stream = cuda_device_hwctx->stream;
}
#if CONFIG_D3D11VA
else if (d3d11_device_hwctx) {
@@ -1245,15 +1247,25 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
return res;
nv_status = p_nvenc->nvEncInitializeEncoder(ctx->nvencoder, &ctx->init_encode_params);
+ if (nv_status != NV_ENC_SUCCESS) {
+ nvenc_pop_context(avctx);
+ return nvenc_print_error(avctx, nv_status, "InitializeEncoder failed");
+ }
+
+#ifdef NVENC_HAVE_CUSTREAM_PTR
+ if (ctx->cu_context) {
+ nv_status = p_nvenc->nvEncSetIOCudaStreams(ctx->nvencoder, &ctx->cu_stream, &ctx->cu_stream);
+ if (nv_status != NV_ENC_SUCCESS) {
+ nvenc_pop_context(avctx);
+ return nvenc_print_error(avctx, nv_status, "SetIOCudaStreams failed");
+ }
+ }
+#endif
res = nvenc_pop_context(avctx);
if (res < 0)
return res;
- if (nv_status != NV_ENC_SUCCESS) {
- return nvenc_print_error(avctx, nv_status, "InitializeEncoder failed");
- }
-
if (ctx->encode_config.frameIntervalP > 1)
avctx->has_b_frames = 2;