[MPlayer-cvslog] r38380 - in trunk: libmpcodecs/dec_video.c mplayer.c

reimar subversion at mplayerhq.hu
Fri Aug 26 15:34:47 EEST 2022


Author: reimar
Date: Fri Aug 26 15:34:47 2022
New Revision: 38380

Log:
mplayer.c, dec_video.c: ensure video filters are always freed.

They would previously leak if we failed to initialize
the video codec.
Fixes trac issue #2390.

Modified:
   trunk/libmpcodecs/dec_video.c
   trunk/mplayer.c

Modified: trunk/libmpcodecs/dec_video.c
==============================================================================
--- trunk/libmpcodecs/dec_video.c	Fri Aug 26 14:52:50 2022	(r38379)
+++ trunk/libmpcodecs/dec_video.c	Fri Aug 26 15:34:47 2022	(r38380)
@@ -173,6 +173,10 @@ int get_current_video_decoder_lag(sh_vid
 
 void uninit_video(sh_video_t *sh_video)
 {
+    if (sh_video->vfilter) {
+        vf_uninit_filter_chain(sh_video->vfilter);
+        sh_video->vfilter = NULL;
+    }
     if (!sh_video->initialized)
         return;
     mp_msg(MSGT_DECVIDEO, MSGL_V, "Uninit video: %s\n", codec_idx2str(sh_video->codec->drv_idx));
@@ -182,8 +186,6 @@ void uninit_video(sh_video_t *sh_video)
     if (sh_video->dec_handle)
         dlclose(sh_video->dec_handle);
 #endif
-    vf_uninit_filter_chain(sh_video->vfilter);
-    sh_video->vfilter = NULL;
     eosd_uninit();
     sh_video->initialized = 0;
 }

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Fri Aug 26 14:52:50 2022	(r38379)
+++ trunk/mplayer.c	Fri Aug 26 15:34:47 2022	(r38380)
@@ -580,6 +580,7 @@ void uninit_player(unsigned int mask)
         mpctx->mixer.afilter = NULL;
     }
 
+    // VCODEC is also used for video filters
     if (mask & INITIALIZED_VCODEC) {
         initialized_flags &= ~INITIALIZED_VCODEC;
         current_module     = "uninit_vcodec";
@@ -2345,6 +2346,8 @@ int reinit_video_chain(void)
     if (stream_control(mpctx->demuxer->stream, STREAM_CTRL_GET_ASPECT_RATIO, &ar) != STREAM_UNSUPPORTED)
         mpctx->sh_video->stream_aspect = ar;
     current_module = "init_video_filters";
+    // Used also for video filters
+    initialized_flags |= INITIALIZED_VCODEC;
     {
         char *vf_arg[] = { "_oldargs_", (char *)mpctx->video_out, NULL };
         if (sh_video->vfilter) vf_uninit_filter_chain(sh_video->vfilter);
@@ -2404,6 +2407,7 @@ int reinit_video_chain(void)
         goto err_out;
     }
 
+    // This should already be set as it's also used for video filters
     initialized_flags |= INITIALIZED_VCODEC;
 
     if (sh_video->codec)
@@ -2431,7 +2435,7 @@ int reinit_video_chain(void)
     return 1;
 
 err_out:
-    mpctx->sh_video = mpctx->sh_video->ds = NULL;
+    uninit_player(INITIALIZED_VCODEC);
     return 0;
 }
 


More information about the MPlayer-cvslog mailing list