[vlc-commits] Fixed motiondetect packed YUV filter function.

Laurent Aimar git at videolan.org
Sat Jan 7 00:59:08 CET 2012


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Jan  7 00:35:15 2012 +0100| [76821fb12d7e3a5cf6be62f023852c8091b09a69] | committer: Laurent Aimar

Fixed motiondetect packed YUV filter function.

A filter shall not return an input buffer.
It closes #5748.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=76821fb12d7e3a5cf6be62f023852c8091b09a69
---

 modules/video_filter/motiondetect.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/modules/video_filter/motiondetect.c b/modules/video_filter/motiondetect.c
index 289f365..d14f377 100644
--- a/modules/video_filter/motiondetect.c
+++ b/modules/video_filter/motiondetect.c
@@ -277,40 +277,44 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_inpic )
     const video_format_t *p_fmt = &p_filter->fmt_in.video;
     picture_t *p_outpic;
 
-    const uint8_t *p_inpix = p_inpic->p[Y_PLANE].p_pixels;
-    const int i_src_pitch = p_inpic->p[Y_PLANE].i_pitch;
-
     uint8_t *p_oldpix   = p_sys->p_old->p[Y_PLANE].p_pixels;
     const int i_old_pitch = p_sys->p_old->p[Y_PLANE].i_pitch;
     uint32_t *p_buf = p_sys->p_buf;
     uint32_t *p_buf2= p_sys->p_buf2;
 
-    int i_y_offset, i_u_offset, i_v_offset;
-
     unsigned x, y;
 
-    if( GetPackedYuvOffsets( p_fmt->i_chroma,
-                             &i_y_offset, &i_u_offset, &i_v_offset ) )
+    if( !p_inpic )
+        return NULL;
+
+    const uint8_t *p_inpix = p_inpic->p[Y_PLANE].p_pixels;
+    const int i_src_pitch = p_inpic->p[Y_PLANE].i_pitch;
+
+    p_outpic = filter_NewPicture( p_filter );
+    if( !p_outpic )
     {
-        msg_Warn( p_filter, "Unsupported input chroma (%4.4s)",
-                  (char*)&p_fmt->i_chroma );
-        return p_inpic;
+        picture_Release( p_inpic );
+        return NULL;
     }
+    picture_Copy( p_outpic, p_inpic );
 
     if( !p_sys->b_old )
     {
         picture_Copy( p_sys->p_old, p_inpic );
+        picture_Release( p_inpic );
         p_sys->b_old = true;
-        return p_inpic;
+        return p_outpic;
     }
 
-    p_outpic = filter_NewPicture( p_filter );
-    if( !p_outpic )
+    int i_y_offset, i_u_offset, i_v_offset;
+    if( GetPackedYuvOffsets( p_fmt->i_chroma,
+                             &i_y_offset, &i_u_offset, &i_v_offset ) )
     {
+        msg_Warn( p_filter, "Unsupported input chroma (%4.4s)",
+                  (char*)&p_fmt->i_chroma );
         picture_Release( p_inpic );
-        return NULL;
+        return p_outpic;
     }
-    picture_Copy( p_outpic, p_inpic );
 
     /* Substract all planes at once */
 



More information about the vlc-commits mailing list