* ALL: separation of the SPU engine from the VOUT.
[vlc.git] / modules / codec / ogt / common.c
index fe42611..e12aebf 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
 /*****************************************************************************
- * Common SVCD and VCD subtitle routines.
+ * Common SVCD and CVD subtitle routines.
  *****************************************************************************
  * Copyright (C) 2003, 2004 VideoLAN
  *****************************************************************************
  * Copyright (C) 2003, 2004 VideoLAN
- * $Id: common.c,v 1.10 2004/01/29 11:50:21 rocky Exp $
+ * $Id$
  *
  * Author: Rocky Bernstein <rocky@panix.com>
  *   based on code from:
  *
  * Author: Rocky Bernstein <rocky@panix.com>
  *   based on code from:
@@ -49,26 +49,11 @@ void VCDSubClose( vlc_object_t *p_this )
 
     dbg_print( (DECODE_DBG_CALL|DECODE_DBG_EXT) , "");
 
 
     dbg_print( (DECODE_DBG_CALL|DECODE_DBG_EXT) , "");
 
-    if( !p_sys->b_packetizer )
+    if( !p_sys->b_packetizer && p_sys->p_vout )
     {
         /* FIXME check if it's ok to not lock vout */
     {
         /* FIXME check if it's ok to not lock vout */
-        if( p_sys->p_vout != NULL && p_sys->p_vout->p_subpicture != NULL )
-        {
-            subpicture_t *  p_subpic;
-            int             i_subpic;
-
-            for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
-            {
-                p_subpic = &p_sys->p_vout->p_subpicture[i_subpic];
-
-                if( p_subpic != NULL &&
-                    ( ( p_subpic->i_status == RESERVED_SUBPICTURE ) ||
-                      ( p_subpic->i_status == READY_SUBPICTURE ) ) )
-                {
-                    vout_DestroySubPicture( p_sys->p_vout, p_subpic );
-                }
-            }
-        }
+        spu_Control( p_sys->p_vout->p_spu, SPU_CHANNEL_CLEAR,
+                     p_sys->i_subpic_channel );
     }
 
     if( p_sys->p_block )
     }
 
     if( p_sys->p_block )
@@ -76,6 +61,7 @@ void VCDSubClose( vlc_object_t *p_this )
         block_ChainRelease( p_sys->p_block );
     }
 
         block_ChainRelease( p_sys->p_block );
     }
 
+    free(p_sys->subtitle_data);
     free( p_sys );
 }
 
     free( p_sys );
 }
 
@@ -348,7 +334,7 @@ VCDSubHandleScaling( subpicture_t *p_spu, decoder_t *p_dec )
   vlc_object_t * p_input = p_spu->p_sys->p_input;
   vout_thread_t *p_vout = vlc_object_find( p_input, VLC_OBJECT_VOUT, 
                                            FIND_CHILD );
   vlc_object_t * p_input = p_spu->p_sys->p_input;
   vout_thread_t *p_vout = vlc_object_find( p_input, VLC_OBJECT_VOUT, 
                                            FIND_CHILD );
-  unsigned int i_aspect_x, i_aspect_y;
+  int i_aspect_x, i_aspect_y;
   uint8_t *p_dest = (uint8_t *)p_spu->p_sys->p_data;
 
   if (p_vout) {
   uint8_t *p_dest = (uint8_t *)p_spu->p_sys->p_data;
 
   if (p_vout) {
@@ -404,11 +390,12 @@ VCDSubHandleScaling( subpicture_t *p_spu, decoder_t *p_dec )
             break;
           }
         /* We get here only for scaled chromas. */
             break;
           }
         /* We get here only for scaled chromas. */
-        vout_AspectRatio( p_vout->render.i_aspect, &i_aspect_y, 
-                          &i_aspect_x );
+        vlc_reduce( &i_aspect_x, &i_aspect_y, p_vout->render.i_aspect,
+                    VOUT_ASPECT_FACTOR, 0 );
       } else {
         /* User knows best? */
       } else {
         /* User knows best? */
-        vout_AspectRatio( i_new_aspect, &i_aspect_x, &i_aspect_y );
+        vlc_reduce( &i_aspect_x, &i_aspect_y, p_vout->render.i_aspect,
+                    VOUT_ASPECT_FACTOR, 0 );
       }
       VCDSubScaleX( p_dec, p_spu, i_aspect_x, i_aspect_y );
     }
       }
       VCDSubScaleX( p_dec, p_spu, i_aspect_x, i_aspect_y );
     }
@@ -489,25 +476,6 @@ void VCDSubDumpImage( uint8_t *p_image, uint32_t i_height, uint32_t i_width )
   printf("\n-------------------------------------\n");
 }
 
   printf("\n-------------------------------------\n");
 }
 
-/***************************************************
-   Color conversion from
-    http://www.inforamp.net/~poynton/notes/colour_and_gamma/ColorFAQ.html#RTFToC30
-    http://people.ee.ethz.ch/~buc/brechbuehler/mirror/color/ColorFAQ.html
-    Thanks to Billy Biggs <vektor@dumbterm.net> for the pointer and
-    the following conversion.
-    R' = [ 1.1644         0    1.5960 ]   ([ Y' ]   [  16 ])
-    G' = [ 1.1644   -0.3918   -0.8130 ] * ([ Cb ] - [ 128 ])
-    B' = [ 1.1644    2.0172         0 ]   ([ Cr ]   [ 128 ])
-
-  See also vlc/modules/video_chroma/i420_rgb.h and
-  vlc/modules/video_chroma/i420_rgb_c.h for a way to do this in a way
-  more optimized for integer arithmetic. Would be nice to merge the
-  two routines.
-***************************************************/
-
 #ifdef HAVE_LIBPNG
 
 #define PALETTE_SIZE  4
 #ifdef HAVE_LIBPNG
 
 #define PALETTE_SIZE  4