]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/deinterlace.c
* ALL: use i_visible_lines in plane_t.
[vlc] / modules / video_filter / deinterlace.c
index f766d4a6989cd5c6c0615e9828b811c6f5a72b35..47d3234f00fd4019ea2e91bc74cf946209fa99c8 100644 (file)
 #include <vlc/vlc.h>
 #include <vlc/vout.h>
 
+#ifdef HAVE_ALTIVEC_H
+#   include <altivec.h>
+#endif
+
 #include "filter_common.h"
 
 #define DEINTERLACE_DISCARD 1
@@ -59,13 +63,13 @@ static void MergeGeneric ( void *, const void *, const void *, size_t );
 #if defined(CAN_COMPILE_C_ALTIVEC)
 static void MergeAltivec ( void *, const void *, const void *, size_t );
 #endif
-#if defined(CAN_COMPILE_MMX)
+#if defined(CAN_COMPILE_MMXEXT)
 static void MergeMMX     ( void *, const void *, const void *, size_t );
 #endif
 #if defined(CAN_COMPILE_SSE)
 static void MergeSSE2    ( void *, const void *, const void *, size_t );
 #endif
-#if defined(CAN_COMPILE_MMX) || defined(CAN_COMPILE_SSE)
+#if defined(CAN_COMPILE_MMXEXT) || defined(CAN_COMPILE_SSE)
 static void EndMMX       ( void );
 #endif
 
@@ -125,6 +129,14 @@ struct vout_sys_t
     void (*pf_end_merge) ( void );
 };
 
+/*****************************************************************************
+ * Control: control facility for the vout (forwards to child vout)
+ *****************************************************************************/
+static int Control( vout_thread_t *p_vout, int i_query, va_list args )
+{
+    return vout_vaControl( p_vout->p_sys->p_vout, i_query, args );
+}
+
 /*****************************************************************************
  * Create: allocates Deinterlace video thread output method
  *****************************************************************************
@@ -148,10 +160,12 @@ static int Create( vlc_object_t *p_this )
     p_vout->pf_manage = NULL;
     p_vout->pf_render = Render;
     p_vout->pf_display = NULL;
+    p_vout->pf_control = Control;
 
     p_vout->p_sys->i_mode = DEINTERLACE_DISCARD;
     p_vout->p_sys->b_double_rate = 0;
     p_vout->p_sys->last_date = 0;
+    p_vout->p_sys->p_vout = 0;
     vlc_mutex_init( p_vout, &p_vout->p_sys->filter_lock );
 
 #if defined(CAN_COMPILE_C_ALTIVEC)
@@ -170,7 +184,7 @@ static int Create( vlc_object_t *p_this )
     }
     else
 #endif
-#if defined(CAN_COMPILE_MMX)
+#if defined(CAN_COMPILE_MMXEXT)
     if( p_vout->p_libvlc->i_cpu & CPU_CAPABILITY_MMX )
     {
         p_vout->p_sys->pf_merge = MergeMMX;
@@ -370,10 +384,12 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-
-    vlc_object_detach( p_vout->p_sys->p_vout );
-    vout_Destroy( p_vout->p_sys->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 );
+        vout_Destroy( p_vout->p_sys->p_vout );
+    }
 
     DEL_PARENT_CALLBACKS( SendEventsToChild );
 
@@ -492,7 +508,7 @@ static void RenderDiscard( vout_thread_t *p_vout,
 
         p_out = p_outpic->p[i_plane].p_pixels;
         p_out_end = p_out + p_outpic->p[i_plane].i_pitch
-                             * p_outpic->p[i_plane].i_lines;
+                             * p_outpic->p[i_plane].i_visible_lines;
 
         switch( p_vout->render.i_chroma )
         {
@@ -561,7 +577,7 @@ static void RenderBob( vout_thread_t *p_vout,
         p_in = p_pic->p[i_plane].p_pixels;
         p_out = p_outpic->p[i_plane].p_pixels;
         p_out_end = p_out + p_outpic->p[i_plane].i_pitch
-                             * p_outpic->p[i_plane].i_lines;
+                             * p_outpic->p[i_plane].i_visible_lines;
 
         switch( p_vout->render.i_chroma )
         {
@@ -681,7 +697,7 @@ static void RenderLinear( vout_thread_t *p_vout,
         p_in = p_pic->p[i_plane].p_pixels;
         p_out = p_outpic->p[i_plane].p_pixels;
         p_out_end = p_out + p_outpic->p[i_plane].i_pitch
-                             * p_outpic->p[i_plane].i_lines;
+                             * p_outpic->p[i_plane].i_visible_lines;
 
         /* For BOTTOM field we need to add the first line */
         if( i_field == 1 )
@@ -737,7 +753,7 @@ static void RenderMean( vout_thread_t *p_vout,
 
         p_out = p_outpic->p[i_plane].p_pixels;
         p_out_end = p_out + p_outpic->p[i_plane].i_pitch
-                             * p_outpic->p[i_plane].i_lines;
+                             * p_outpic->p[i_plane].i_visible_lines;
 
         /* All lines: mean value */
         for( ; p_out < p_out_end ; )
@@ -766,7 +782,7 @@ static void RenderBlend( vout_thread_t *p_vout,
 
         p_out = p_outpic->p[i_plane].p_pixels;
         p_out_end = p_out + p_outpic->p[i_plane].i_pitch
-                             * p_outpic->p[i_plane].i_lines;
+                             * p_outpic->p[i_plane].i_visible_lines;
 
         switch( p_vout->render.i_chroma )
         {
@@ -855,7 +871,7 @@ static void MergeGeneric( void *_p_dest, const void *_p_s1,
     }
 }
 
-#if defined(CAN_COMPILE_MMX)
+#if defined(CAN_COMPILE_MMXEXT)
 static void MergeMMX( void *_p_dest, const void *_p_s1, const void *_p_s2,
                       size_t i_bytes )
 {
@@ -891,11 +907,12 @@ static void MergeSSE2( void *_p_dest, const void *_p_s1, const void *_p_s2,
     uint8_t* p_dest = (uint8_t*)_p_dest;
     const uint8_t *p_s1 = (const uint8_t *)_p_s1;
     const uint8_t *p_s2 = (const uint8_t *)_p_s2;
+    uint8_t* p_end;
     while( (int)p_s1 % 16 )
     {
         *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
     }        
-    uint8_t* p_end = p_dest + i_bytes - 16;
+    p_end = p_dest + i_bytes - 16;
     while( p_dest < p_end )
     {
         __asm__  __volatile__( "movdqu %2,%%xmm1;"
@@ -917,7 +934,7 @@ static void MergeSSE2( void *_p_dest, const void *_p_s1, const void *_p_s2,
 }
 #endif
 
-#if defined(CAN_COMPILE_MMX) || defined(CAN_COMPILE_SSE)
+#if defined(CAN_COMPILE_MMXEXT) || defined(CAN_COMPILE_SSE)
 static void EndMMX( void )
 {
     __asm__ __volatile__( "emms" :: );