postproc: factor common code
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 24 Jul 2014 16:11:01 +0000 (19:11 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 24 Jul 2014 16:12:03 +0000 (19:12 +0300)
modules/video_filter/postproc.c

index 8ca5507..3ee8882 100644 (file)
@@ -286,11 +286,6 @@ static picture_t *PostprocPict( filter_t *p_filter, picture_t *p_pic )
 {
     filter_sys_t *p_sys = p_filter->p_sys;
 
-    const uint8_t *src[3];
-    uint8_t *dst[3];
-    int i_plane;
-    int i_src_stride[3], i_dst_stride[3];
-
     picture_t *p_outpic = filter_NewPicture( p_filter );
     if( !p_outpic )
     {
@@ -300,29 +295,30 @@ static picture_t *PostprocPict( filter_t *p_filter, picture_t *p_pic )
 
     /* Lock to prevent issues if pp_mode is changed */
     vlc_mutex_lock( &p_sys->lock );
-    if( !p_sys->pp_mode )
+    if( p_sys->pp_mode != NULL )
     {
-        vlc_mutex_unlock( &p_sys->lock );
-        picture_CopyPixels( p_outpic, p_pic );
-        return CopyInfoAndRelease( p_outpic, p_pic );
-    }
+        const uint8_t *src[3];
+        uint8_t *dst[3];
+        int i_src_stride[3], i_dst_stride[3];
 
+        for( int i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
+        {
+            src[i_plane] = p_pic->p[i_plane].p_pixels;
+            dst[i_plane] = p_outpic->p[i_plane].p_pixels;
 
-    for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
-    {
-        src[i_plane] = p_pic->p[i_plane].p_pixels;
-        dst[i_plane] = p_outpic->p[i_plane].p_pixels;
+            /* I'm not sure what happens if i_pitch != i_visible_pitch ...
+             * at least it shouldn't crash. */
+            i_src_stride[i_plane] = p_pic->p[i_plane].i_pitch;
+            i_dst_stride[i_plane] = p_outpic->p[i_plane].i_pitch;
+        }
 
-        /* I'm not sure what happens if i_pitch != i_visible_pitch ...
-         * at least it shouldn't crash. */
-        i_src_stride[i_plane] = p_pic->p[i_plane].i_pitch;
-        i_dst_stride[i_plane] = p_outpic->p[i_plane].i_pitch;
+        pp_postprocess( src, i_src_stride, dst, i_dst_stride,
+                        p_filter->fmt_in.video.i_width,
+                        p_filter->fmt_in.video.i_height, NULL, 0,
+                        p_sys->pp_mode, p_sys->pp_context, 0 );
     }
-
-    pp_postprocess( src, i_src_stride, dst, i_dst_stride,
-                    p_filter->fmt_in.video.i_width,
-                    p_filter->fmt_in.video.i_height, NULL, 0,
-                    p_sys->pp_mode, p_sys->pp_context, 0 );
+    else
+        picture_CopyPixels( p_outpic, p_pic );
     vlc_mutex_unlock( &p_sys->lock );
 
     return CopyInfoAndRelease( p_outpic, p_pic );