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>
This commit is contained in:
leozhang 2020-11-20 11:23:43 +08:00 committed by Timo Rothenpieler
parent 4fe9e2fc16
commit 7ce7d33d15
1 changed files with 7 additions and 0 deletions

View File

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