]> git.sesse.net Git - vlc/commitdiff
Change the chain module so it allows chaining more than 2 chroma modules (you'll...
authorAntoine Cellerier <dionoea@videolan.org>
Thu, 10 Jan 2008 21:20:16 +0000 (21:20 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Thu, 10 Jan 2008 21:20:16 +0000 (21:20 +0000)
modules/video_chroma/chain.c

index ba7114c51374aa14e04c5253684d2c453459b869..aa72b96d5c9474d043d20349143e08e359b65308 100644 (file)
@@ -69,21 +69,22 @@ static const vlc_fourcc_t pi_allowed_chromas[] = {
  *****************************************************************************/
 static int Activate( vlc_object_t *p_this )
 {
-    static int hack = 0;
+    static int hack = 1;
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    if( hack )
+    hack++;
+    if( hack > MAX_CHROMAS )
     {
-        msg_Err( p_this, "Preventing chain chroma reccursion" );
+        hack--;
+        msg_Err( p_this, "Preventing chain chroma reccursion (already %d long)",
+                 hack );
         return VLC_EGENERIC;
     }
 
-    hack = 1;
-
     chroma_sys_t *p_sys = (chroma_sys_t *)malloc( sizeof( chroma_sys_t ) );
     if( !p_sys )
     {
-        hack = 0;
+        hack--;
         return VLC_ENOMEM;
     }
     memset( p_sys, 0, sizeof( chroma_sys_t ) );
@@ -123,12 +124,13 @@ static int Activate( vlc_object_t *p_this )
         p_sys->i_chroma = pi_allowed_chromas[i];
         p_vout->chroma.pf_convert = Chain;
         p_vout->chroma.p_sys = p_sys;
-        hack = 0;
+        hack--;
+        printf("Init: p_sys->p_tmp= %p\n", p_sys->p_tmp );
         return VLC_SUCCESS;
     }
 
     free( p_sys );
-    hack = 0;
+    hack--;
     return VLC_EGENERIC;
 }
 
@@ -150,6 +152,7 @@ static void Destroy( vlc_object_t *p_this )
         free( chroma.p_sys->p_tmp );
     }
     free( chroma.p_sys );
+    chroma.p_sys = NULL;
 }
 
 /*****************************************************************************
@@ -176,6 +179,10 @@ static void Chain( vout_thread_t *p_vout, picture_t *p_source,
         p_tmp->p_sys = NULL;
     }
 
+    vout_chroma_t chroma = p_vout->chroma;
+    p_vout->chroma = p_sys->chroma1;
     p_sys->chroma1.pf_convert( p_vout, p_source, p_sys->p_tmp );
+    p_vout->chroma = p_sys->chroma2;
     p_sys->chroma2.pf_convert( p_vout, p_sys->p_tmp, p_dest );
+    p_vout->chroma = chroma;
 }