]> git.sesse.net Git - vlc/blobdiff - plugins/spudec/spu_decoder.c
* ALL: new module API. Makes a few things a lot simpler, and we gain
[vlc] / plugins / spudec / spu_decoder.c
index ac68502651bead054eff8c6a10334229fecbe41d..c23a6a363c8b820978ba05a204af41ededc9adb1 100644 (file)
@@ -2,7 +2,7 @@
  * spu_decoder.c : spu decoder thread
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: spu_decoder.c,v 1.29 2002/06/27 19:46:32 sam Exp $
+ * $Id: spu_decoder.c,v 1.31 2002/07/31 20:56:52 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Rudolf Cornelissen <rag.cornelissen@inter.nl.net>
@@ -45,8 +45,8 @@
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int  decoder_Probe ( u8 * );
-static int  decoder_Run   ( decoder_fifo_t * );
+static int  OpenDecoder   ( vlc_object_t * );      
+static int  RunDecoder    ( decoder_fifo_t * );
 static int  InitThread    ( spudec_thread_t * );
 static void EndThread     ( spudec_thread_t * );
 
@@ -56,49 +56,38 @@ static int  ParseControlSequences( spudec_thread_t *, subpicture_t * );
 static int  ParseRLE             ( spudec_thread_t *, subpicture_t *, u8 * );
 static void RenderSPU            ( vout_thread_t *, picture_t *,
                                    const subpicture_t * );
-
-/*****************************************************************************
- * Capabilities
- *****************************************************************************/
-void _M( spudec_getfunctions )( function_list_t * p_function_list )
-{
-    p_function_list->functions.dec.pf_probe = decoder_Probe;
-    p_function_list->functions.dec.pf_run   = decoder_Run;
-}
-
 /*****************************************************************************
- * Build configuration tree.
+ * Module descriptor.
  *****************************************************************************/
-MODULE_CONFIG_START
-MODULE_CONFIG_STOP
-
-MODULE_INIT_START
-    SET_DESCRIPTION( _("DVD subtitles decoder module") )
-    ADD_CAPABILITY( DECODER, 50 )
-MODULE_INIT_STOP
-
-MODULE_ACTIVATE_START
-    _M( spudec_getfunctions )( &p_module->p_functions->dec );
-MODULE_ACTIVATE_STOP
-
-MODULE_DEACTIVATE_START
-MODULE_DEACTIVATE_STOP
+vlc_module_begin();
+    set_description( _("DVD subtitles decoder module") );
+    set_capability( "decoder", 50 );
+    set_callbacks( OpenDecoder, NULL );
+vlc_module_end();
 
 /*****************************************************************************
- * decoder_Probe: probe the decoder and return score
+ * OpenDecoder: probe the decoder and return score
  *****************************************************************************
  * Tries to launch a decoder and return score so that the interface is able 
  * to chose.
  *****************************************************************************/
-static int decoder_Probe( u8 *pi_type )
+static int OpenDecoder( vlc_object_t *p_this )
 {
-    return ( *pi_type == DVD_SPU_ES ) ? 0 : -1;
+    decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
+
+    if( p_fifo->i_fourcc == VLC_FOURCC('s','p','u',' ') )
+    {   
+        p_fifo->pf_run = RunDecoder;
+        return VLC_SUCCESS;
+    }
+    
+    return VLC_EGENERIC;
 }
 
 /*****************************************************************************
- * decoder_Run: this function is called just after the thread is created
+ * RunDecoder: this function is called just after the thread is created
  *****************************************************************************/
-static int decoder_Run( decoder_fifo_t * p_fifo )
+static int RunDecoder( decoder_fifo_t * p_fifo )
 {
     spudec_thread_t *     p_spudec;
    
@@ -862,9 +851,9 @@ static void RenderSPU( vout_thread_t *p_vout, picture_t *p_pic,
     switch( p_vout->output.i_chroma )
     {
     /* I420 target, no scaling */
-    case FOURCC_I420:
-    case FOURCC_IYUV:
-    case FOURCC_YV12:
+    case VLC_FOURCC('I','4','2','0'):
+    case VLC_FOURCC('I','Y','U','V'):
+    case VLC_FOURCC('Y','V','1','2'):
 
     p_dest = p_pic->Y_PIXELS + p_spu->i_x + p_spu->i_width
               + p_pic->Y_PITCH * ( p_spu->i_y + p_spu->i_height );
@@ -916,7 +905,7 @@ static void RenderSPU( vout_thread_t *p_vout, picture_t *p_pic,
     break;
 
     /* RV16 target, scaling */
-    case FOURCC_RV16:
+    case VLC_FOURCC('R','V','1','6'):
 
     /* XXX: this is a COMPLETE HACK, memcpy is unable to do u16s anyway */
     /* FIXME: get this from the DVD */
@@ -1030,8 +1019,8 @@ static void RenderSPU( vout_thread_t *p_vout, picture_t *p_pic,
     break;
 
     /* RV32 target, scaling */
-    case FOURCC_RV24:
-    case FOURCC_RV32:
+    case VLC_FOURCC('R','V','2','4'):
+    case VLC_FOURCC('R','V','3','2'):
 
     /* XXX: this is a COMPLETE HACK, memcpy is unable to do u32s anyway */
     /* FIXME: get this from the DVD */
@@ -1143,7 +1132,7 @@ static void RenderSPU( vout_thread_t *p_vout, picture_t *p_pic,
     break;
 
     /* NVidia overlay, no scaling */
-    case FOURCC_YUY2:
+    case VLC_FOURCC('Y','U','Y','2'):
 
     p_dest = p_pic->p->p_pixels +
               (p_spu->i_x + p_spu->i_width +