]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/motionblur.c
Clone video filter : fix potential memleak.
[vlc] / modules / video_filter / motionblur.c
index 441c378851439fc80b0822a59a88125771117908..4b9bafeb7172fa7a6e02b2ef0d13c3b4f60fd57c 100644 (file)
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_vout.h>
 #include <vlc_filter.h>
+#include "filter_picture.h"
 
 /*****************************************************************************
  * Local protypes
@@ -95,10 +96,7 @@ static int Create( vlc_object_t *p_this )
     /* Allocate structure */
     p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
     if( p_filter->p_sys == NULL )
-    {
-        msg_Err( p_filter, "out of memory" );
         return VLC_ENOMEM;
-    }
 
     p_filter->pf_video_filter = Filter;
 
@@ -129,17 +127,6 @@ static void Destroy( vlc_object_t *p_this )
     free( p_filter->p_sys );
 }
 
-#define RELEASE( pic ) \
-        if( pic ->pf_release ) \
-            pic ->pf_release( pic );
-
-#define INITPIC( dst, src ) \
-    dst ->date = src ->date; \
-    dst ->b_force = src ->b_force; \
-    dst ->i_nb_fields = src ->i_nb_fields; \
-    dst ->b_progressive = src->b_progressive; \
-    dst ->b_top_field_first = src ->b_top_field_first;
-
 /*****************************************************************************
  * Filter
  *****************************************************************************/
@@ -150,14 +137,12 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
 
     if( !p_pic ) return NULL;
 
-    p_outpic = p_filter->pf_vout_buffer_new( p_filter );
+    p_outpic = filter_NewPicture( p_filter );
     if( !p_outpic )
     {
-        msg_Warn( p_filter, "can't get output picture" );
-        RELEASE( p_pic );
+        picture_Release( p_pic );
         return NULL;
     }
-    INITPIC( p_outpic, p_pic );
 
     if( !p_sys->pp_planes )
     {
@@ -178,8 +163,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
     RenderBlur( p_sys, p_pic, p_outpic );
     Copy( p_filter, p_outpic );
 
-    RELEASE( p_pic );
-    return p_outpic;
+    return CopyInfoAndRelease( p_outpic, p_pic );
 }
 
 /*****************************************************************************