[vlc-devel] [PATCH] Support VOUT_ASPECT_CHANGE in deinterlace filter

Marian Ďurkovič md at bts.sk
Fri Sep 12 20:27:28 CEST 2008


Hi all,

  attached please find a patch with introduces support for on-the-fly AR
cahnges via VOUT_ASPECT_CHANGE into deinterlace filter. As fenrir pointed
out, we need to handle AR change differently in case deinterlace reduced
the number of lines. With this patch, on-the-fly AR change works fine
together with deinterlace, other filters need similar changes.
Please review and commit before 0.9.2 release if you find it OK.

    Thanks & kind regards,

        M.
-------------- next part --------------
diff --git a/modules/video_filter/deinterlace.c b/modules/video_filter/deinterlace.c
index d6ffd99..1aa5316 100644
--- a/modules/video_filter/deinterlace.c
+++ b/modules/video_filter/deinterlace.c
@@ -160,6 +160,7 @@ struct vout_sys_t
 {
     int        i_mode;        /* Deinterlace mode */
     bool b_double_rate; /* Shall we double the framerate? */
+    bool b_half_height;
 
     mtime_t    last_date;
     mtime_t    next_date;
@@ -204,6 +205,7 @@ static int Create( vlc_object_t *p_this )
 
     p_vout->p_sys->i_mode = DEINTERLACE_DISCARD;
     p_vout->p_sys->b_double_rate = false;
+    p_vout->p_sys->b_half_height = false;
     p_vout->p_sys->last_date = 0;
     p_vout->p_sys->p_vout = 0;
     vlc_mutex_init( &p_vout->p_sys->filter_lock );
@@ -390,6 +392,7 @@ static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout )
             fmt.i_height /= 2; fmt.i_visible_height /= 2; fmt.i_y_offset /= 2;
             fmt.i_sar_den *= 2;
             p_real_vout = vout_Create( p_vout, &fmt );
+            p_vout->p_sys->b_half_height = true;
             break;
 
         case DEINTERLACE_BOB:
@@ -397,6 +400,7 @@ static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout )
         case DEINTERLACE_LINEAR:
         case DEINTERLACE_X:
             p_real_vout = vout_Create( p_vout, &fmt );
+            p_vout->p_sys->b_half_height = false;
             break;
         }
         break;
@@ -404,6 +408,7 @@ static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout )
     case VLC_FOURCC('I','4','2','2'):
         fmt.i_chroma = VLC_FOURCC('I','4','2','0');
         p_real_vout = vout_Create( p_vout, &fmt );
+        p_vout->p_sys->b_half_height = false;
         break;
 
     default:
@@ -460,6 +465,25 @@ static void Render ( vout_thread_t *p_vout, picture_t *p_pic )
     vout_sys_t *p_sys = p_vout->p_sys;
     picture_t *pp_outpic[2];
 
+    if( p_vout->i_changes & VOUT_ASPECT_CHANGE )
+    {
+        p_vout->i_changes &= ~VOUT_ASPECT_CHANGE;
+        p_sys->p_vout->i_changes |= VOUT_ASPECT_CHANGE;
+
+        p_vout->fmt_out.i_aspect = p_sys->p_vout->fmt_in.i_aspect =
+            p_vout->fmt_in.i_aspect;
+        p_vout->fmt_out.i_sar_num = p_sys->p_vout->fmt_in.i_sar_num =
+            p_vout->fmt_in.i_sar_num;
+        p_vout->fmt_out.i_sar_den = p_sys->p_vout->fmt_in.i_sar_den =
+            p_vout->fmt_in.i_sar_den;
+
+        if( p_vout->p_sys->b_half_height )
+        {
+            p_vout->fmt_out.i_sar_den *= 2;
+            p_sys->p_vout->fmt_in.i_sar_den *= 2;
+        }
+    }
+
     p_vout->fmt_out.i_x_offset = p_sys->p_vout->fmt_in.i_x_offset =
         p_vout->fmt_in.i_x_offset;
     p_vout->fmt_out.i_y_offset = p_sys->p_vout->fmt_in.i_y_offset =


More information about the vlc-devel mailing list