]> git.sesse.net Git - vlc/blobdiff - modules/codec/svcdsub.c
Use var_Inherit instead of var_CreateGet + var_Destroy.
[vlc] / modules / codec / svcdsub.c
index c8572bdbd8cb605a650adba2e531a3838e968bc9..78dcd3c152ba1c46bcf2c6b1bc9abcafb42d1100 100644 (file)
@@ -35,7 +35,7 @@
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
 #include <vlc_osd.h>
-#include "vlc_bits.h"
+#include <vlc_bits.h>
 
 /*****************************************************************************
  * Module descriptor.
@@ -51,22 +51,22 @@ static void DecoderClose  ( vlc_object_t * );
     "calls                 1\n" \
     "packet assembly info  2\n" )
 
-vlc_module_begin();
-    set_description( N_("Philips OGT (SVCD subtitle) decoder") );
-    set_shortname( N_("SVCD subtitles") );
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_SCODEC );
-    set_capability( "decoder", 50 );
-    set_callbacks( DecoderOpen, DecoderClose );
+vlc_module_begin ()
+    set_description( N_("Philips OGT (SVCD subtitle) decoder") )
+    set_shortname( N_("SVCD subtitles") )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_SCODEC )
+    set_capability( "decoder", 50 )
+    set_callbacks( DecoderOpen, DecoderClose )
 
     add_integer ( MODULE_STRING "-debug", 0, NULL,
-                  DEBUG_TEXT, DEBUG_LONGTEXT, true );
+                  DEBUG_TEXT, DEBUG_LONGTEXT, true )
 
-    add_submodule();
-    set_description( N_("Philips OGT (SVCD subtitle) packetizer") );
-    set_capability( "packetizer", 50 );
-    set_callbacks( PacketizerOpen, DecoderClose );
-vlc_module_end();
+    add_submodule ()
+    set_description( N_("Philips OGT (SVCD subtitle) packetizer") )
+    set_capability( "packetizer", 50 )
+    set_callbacks( PacketizerOpen, DecoderClose )
+vlc_module_end ()
 
 /*****************************************************************************
  * Local prototypes
@@ -142,23 +142,21 @@ static int DecoderOpen( vlc_object_t *p_this )
     decoder_t     *p_dec = (decoder_t*)p_this;
     decoder_sys_t *p_sys;
 
-    if( p_dec->fmt_in.i_codec != VLC_FOURCC( 'o','g','t',' ' ) )
-    {
+    if( p_dec->fmt_in.i_codec != VLC_CODEC_OGT )
         return VLC_EGENERIC;
-    }
 
     p_dec->p_sys = p_sys = calloc( 1, sizeof( decoder_sys_t ) );
     if( p_sys == NULL )
         return VLC_ENOMEM;
 
-    p_sys->i_debug       = config_GetInt( p_this, MODULE_STRING "-debug" );
+    p_sys->i_debug = var_InheritInteger( p_this, MODULE_STRING "-debug" );
 
-    p_sys->i_image       = -1;
+    p_sys->i_image = -1;
 
     p_sys->i_state = SUBTITLE_BLOCK_EMPTY;
     p_sys->p_spu   = NULL;
 
-    es_format_Init( &p_dec->fmt_out, SPU_ES, VLC_FOURCC( 'o','g','t',' ' ) );
+    es_format_Init( &p_dec->fmt_out, SPU_ES, VLC_CODEC_OGT );
 
     p_dec->pf_decode_sub = Decode;
     p_dec->pf_packetize  = Packetize;
@@ -437,7 +435,7 @@ static void ParseHeader( decoder_t *p_dec, block_t *p_block )
     p_sys->i_image_length  = p_sys->i_spu_size - p_sys->i_image_offset;
     p_sys->metadata_length = p_sys->i_image_offset;
 
-  if (p_sys && p_sys->i_debug & DECODE_DBG_PACKET)
+  if( p_sys->i_debug & DECODE_DBG_PACKET )
   {
       msg_Dbg( p_dec, "x-start: %d, y-start: %d, width: %d, height %d, "
            "spu size: %zu, duration: %"PRIu64" (d:%zu p:%"PRIu16")",
@@ -445,7 +443,7 @@ static void ParseHeader( decoder_t *p_dec, block_t *p_block )
            p_sys->i_width, p_sys->i_height,
            p_sys->i_spu_size, p_sys->i_duration,
            p_sys->i_image_length, p_sys->i_image_offset);
+
       for( i = 0; i < 4; i++ )
       {
           msg_Dbg( p_dec, "palette[%d]= T: %2x, Y: %2x, u: %2x, v: %2x", i,
@@ -471,7 +469,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
     int i;
 
     /* Allocate the subpicture internal data. */
-    p_spu = p_dec->pf_spu_buffer_new( p_dec );
+    p_spu = decoder_NewSubpicture( p_dec );
     if( !p_spu ) return NULL;
 
     p_spu->i_start = p_data->i_pts;
@@ -480,7 +478,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
 
     /* Create new subtitle region */
     memset( &fmt, 0, sizeof(video_format_t) );
-    fmt.i_chroma = VLC_FOURCC('Y','U','V','P');
+    fmt.i_chroma = VLC_CODEC_YUVP;
 
     /**
        The video on which the subtitle sits, is scaled, probably
@@ -490,7 +488,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
        Two candidates are the video and the other possibility would be
        the access module.
     */
-    fmt.i_aspect = VOUT_ASPECT_FACTOR;
+    fmt.i_sar_num = p_sys->i_height;
+    fmt.i_sar_den = p_sys->i_width;
 
     fmt.i_width = fmt.i_visible_width = p_sys->i_width;
     fmt.i_height = fmt.i_visible_height = p_sys->i_height;
@@ -509,7 +508,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
     if( !p_region )
     {
         msg_Err( p_dec, "cannot allocate SVCD subtitle region" );
-        p_dec->pf_spu_buffer_del( p_dec, p_spu );
+        decoder_DeleteSubpicture( p_dec, p_spu );
         return NULL;
     }