]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/deinterlace.c
Clone video filter : fix potential memleak.
[vlc] / modules / video_filter / deinterlace.c
index 26b8f0bfb3f832d2168cb50a20c6f519f917a08d..4ec8333340263f2b8b58aac34e0be95215aaf830 100644 (file)
@@ -420,6 +420,11 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
+    if( p_vout->p_sys->p_vout )
+        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
@@ -428,13 +433,7 @@ static void End( vout_thread_t *p_vout )
     }
 
     if( p_vout->p_sys->p_vout )
-    {
-        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-        vlc_object_detach( p_vout->p_sys->p_vout );
-        vlc_object_release( p_vout->p_sys->p_vout );
-    }
-
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
+        vout_CloseAndRelease( p_vout->p_sys->p_vout );
 }
 
 /*****************************************************************************
@@ -2061,11 +2060,11 @@ static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd,
     }
 
     /* We need to kill the old vout */
-
-    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-
-    vlc_object_detach( p_vout->p_sys->p_vout );
-    vlc_object_release( p_vout->p_sys->p_vout );
+    if( p_vout->p_sys->p_vout )
+    {
+        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+        vout_CloseAndRelease( p_vout->p_sys->p_vout );
+    }
 
     /* Try to open a new video output */
     p_vout->p_sys->p_vout = SpawnRealVout( p_vout );
@@ -2107,12 +2106,9 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic )
     picture_t *p_pic_dst;
 
     /* Request output picture */
-    p_pic_dst = p_filter->pf_vout_buffer_new( p_filter );
+    p_pic_dst = filter_NewPicture( p_filter );
     if( p_pic_dst == NULL )
-    {
-        msg_Warn( p_filter, "can't get output picture" );
-        return NULL;
-    }
+        return p_pic;
 
     switch( p_vout->p_sys->i_mode )
     {
@@ -2121,7 +2117,7 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic )
             RenderDiscard( p_vout, p_pic_dst, p_pic, 0 );
 #endif
             msg_Err( p_vout, "discarding lines is not supported yet" );
-            p_pic_dst->pf_release( p_pic_dst );
+            picture_Release( p_pic_dst );
             return p_pic;
             break;
 
@@ -2138,7 +2134,7 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic )
             RenderLinear( p_vout, pp_outpic[1], p_pic, 1 );
 #endif
             msg_Err( p_vout, "doubling the frame rate is not supported yet" );
-            p_pic_dst->pf_release( p_pic_dst );
+            picture_Release( p_pic_dst );
             return p_pic;
             break;
 
@@ -2155,13 +2151,10 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic )
             break;
     }
 
-    p_pic_dst->date = p_pic->date;
-    p_pic_dst->b_force = p_pic->b_force;
-    p_pic_dst->i_nb_fields = p_pic->i_nb_fields;
+    picture_CopyProperties( p_pic_dst, p_pic );
     p_pic_dst->b_progressive = true;
-    p_pic_dst->b_top_field_first = p_pic->b_top_field_first;
 
-    p_pic->pf_release( p_pic );
+    picture_Release( p_pic );
     return p_pic_dst;
 }