diff mbox series

[FFmpeg-devel] avfilter/vf_scale_cuda: unload cuModule when uninit

Message ID 20201012115939.1443-1-nowerzt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel] avfilter/vf_scale_cuda: unload cuModule when uninit | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make warning Make failed

Commit Message

leozhang Oct. 12, 2020, 11:59 a.m. UTC
Signed-off-by: leozhang <nowerzt@gmail.com>
---
 libavfilter/vf_scale_cuda.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Timo Rothenpieler Oct. 12, 2020, 7:12 p.m. UTC | #1
applied
diff mbox series

Patch

diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
index 1ffb73f831..46d69b00ee 100644
--- a/libavfilter/vf_scale_cuda.c
+++ b/libavfilter/vf_scale_cuda.c
@@ -119,7 +119,15 @@  static av_cold int cudascale_init(AVFilterContext *ctx)
 static av_cold void cudascale_uninit(AVFilterContext *ctx)
 {
     CUDAScaleContext *s = ctx->priv;
+    CUcontext dummy;
 
+    if (s->hwctx && s->cu_module) {
+        CudaFunctions *cu = s->hwctx->internal->cuda_dl;
+        CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx));
+        CHECK_CU(cu->cuModuleUnload(s->cu_module));
+        s->cu_module = NULL;
+        CHECK_CU(cu->cuCtxPopCurrent(&dummy));
+    }
     av_frame_free(&s->frame);
     av_buffer_unref(&s->frames_ctx);
     av_frame_free(&s->tmp_frame);