summaryrefslogtreecommitdiff
path: root/libavcodec/cuviddec.c
diff options
context:
space:
mode:
authorleozhang <nowerzt@gmail.com>2020-11-20 11:23:43 +0800
committerTimo Rothenpieler <timo@rothenpieler.org>2020-11-21 21:56:51 +0100
commit7ce7d33d1537bebe3e11b4046466d6c694f2e9c7 (patch)
treee6841fc605359c52237545e65aff8318971baee9 /libavcodec/cuviddec.c
parent4fe9e2fc162a9d3258eb39dd16677970c657c122 (diff)
avcodec/cuviddec: fix missing context push/pop
Test command like below: cuda-memcheck ./ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input_file -c:v h264_nvenc -f null - Signed-off-by: leozhang <nowerzt@gmail.com> Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Diffstat (limited to 'libavcodec/cuviddec.c')
-rw-r--r--libavcodec/cuviddec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 5e698d4cd0..61d7f36c79 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -673,15 +673,22 @@ static int cuvid_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
static av_cold int cuvid_decode_end(AVCodecContext *avctx)
{
CuvidContext *ctx = avctx->priv_data;
+ AVHWDeviceContext *device_ctx = (AVHWDeviceContext *)ctx->hwdevice->data;
+ AVCUDADeviceContext *device_hwctx = device_ctx->hwctx;
+ CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx;
av_fifo_freep(&ctx->frame_queue);
+ ctx->cudl->cuCtxPushCurrent(cuda_ctx);
+
if (ctx->cuparser)
ctx->cvdl->cuvidDestroyVideoParser(ctx->cuparser);
if (ctx->cudecoder)
ctx->cvdl->cuvidDestroyDecoder(ctx->cudecoder);
+ ctx->cudl->cuCtxPopCurrent(&dummy);
+
ctx->cudl = NULL;
av_buffer_unref(&ctx->hwframe);