]> git.sesse.net Git - vlc/blobdiff - modules/codec/cvdsub.c
Added RGBA and YUVA support (it will enhance subtitle scaling).
[vlc] / modules / codec / cvdsub.c
index faaa42dbc5f18dabf6707d5f654a7a4e830cdd43..48da421c6c9cd6d0c14b8a660380407d5b747653 100644 (file)
@@ -31,7 +31,8 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_vout.h>
 #include <vlc_codec.h>
 
@@ -47,12 +48,12 @@ static int  PacketizerOpen( vlc_object_t * );
 static void DecoderClose  ( vlc_object_t * );
 
 vlc_module_begin();
-    set_description( _("CVD subtitle decoder") );
+    set_description( N_("CVD subtitle decoder") );
     set_capability( "decoder", 50 );
     set_callbacks( DecoderOpen, DecoderClose );
 
     add_submodule();
-    set_description( _("Chaoji VCD subtitle packetizer") );
+    set_description( N_("Chaoji VCD subtitle packetizer") );
     set_capability( "packetizer", 50 );
     set_callbacks( PacketizerOpen, DecoderClose );
 vlc_module_end();
@@ -80,16 +81,16 @@ struct decoder_sys_t
 
   block_t  *p_spu;   /* Bytes of the packet. */
 
-  int     i_spu_size;     /* goal for subtitle_data_pos while gathering,
+  size_t   i_spu_size;     /* goal for subtitle_data_pos while gathering,
                              size of used subtitle_data later */
 
   uint16_t i_image_offset;      /* offset from subtitle_data to compressed
                                    image data */
-  int i_image_length;           /* size of the compressed image data */
-  int first_field_offset;       /* offset of even raster lines */
-  int second_field_offset;      /* offset of odd raster lines */
-  int metadata_offset;          /* offset to data describing the image */
-  int metadata_length;          /* length of metadata */
+  size_t i_image_length;           /* size of the compressed image data */
+  size_t first_field_offset;       /* offset of even raster lines */
+  size_t second_field_offset;      /* offset of odd raster lines */
+  size_t metadata_offset;          /* offset to data describing the image */
+  size_t metadata_length;          /* length of metadata */
 
   mtime_t i_duration;   /* how long to display the image, 0 stands
                            for "until next subtitle" */
@@ -116,8 +117,10 @@ static int DecoderOpen( vlc_object_t *p_this )
     }
 
     p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
+    if( !p_sys )
+        return VLC_ENOMEM;
 
-    p_sys->b_packetizer  = VLC_FALSE;
+    p_sys->b_packetizer  = false;
 
     p_sys->i_state = SUBTITLE_BLOCK_EMPTY;
     p_sys->p_spu   = NULL;
@@ -139,7 +142,7 @@ static int PacketizerOpen( vlc_object_t *p_this )
 
     if( DecoderOpen( p_this ) != VLC_SUCCESS ) return VLC_EGENERIC;
 
-    p_dec->p_sys->b_packetizer = VLC_TRUE;
+    p_dec->p_sys->b_packetizer = true;
 
     return VLC_SUCCESS;
 }
@@ -217,7 +220,7 @@ static block_t *Reassemble( decoder_t *p_dec, block_t *p_block )
 
     if( p_block->i_buffer < SPU_HEADER_LEN )
     {
-        msg_Dbg( p_dec, "invalid packet header (size %d < %d)" ,
+        msg_Dbg( p_dec, "invalid packet header (size %zu < %u)" ,
                  p_block->i_buffer, SPU_HEADER_LEN );
         block_Release( p_block );
         return NULL;
@@ -250,11 +253,11 @@ static block_t *Reassemble( decoder_t *p_dec, block_t *p_block )
 
         if( p_spu->i_buffer != p_sys->i_spu_size )
         {
-            msg_Warn( p_dec, "SPU packets size=%d should be %d",
+            msg_Warn( p_dec, "SPU packets size=%zu should be %zu",
                       p_spu->i_buffer, p_sys->i_spu_size );
         }
 
-        msg_Dbg( p_dec, "subtitle packet complete, size=%d", p_spu->i_buffer);
+        msg_Dbg( p_dec, "subtitle packet complete, size=%zuu", p_spu->i_buffer);
 
         ParseMetaInfo( p_dec, p_spu );
 
@@ -312,7 +315,7 @@ static void ParseHeader( decoder_t *p_dec, block_t *p_block )
     p_sys->i_image_length = p_sys->metadata_offset - p_sys->i_image_offset;
 
 #ifdef DEBUG_CVDSUB
-    msg_Dbg( p_dec, "total size: %d  image size: %d",
+    msg_Dbg( p_dec, "total size: %zu  image size: %zu",
              p_sys->i_spu_size, p_sys->i_image_length );
 #endif
 }
@@ -458,7 +461,8 @@ static void ParseMetaInfo( decoder_t *p_dec, block_t *p_spu  )
             p_sys->first_field_offset =
                 (p[2] << 8) + p[3] - p_sys->i_image_offset;
 #ifdef DEBUG_CVDSUB
-            msg_Dbg( p_dec, "1st_field_offset %d", p_sys->first_field_offset );
+            msg_Dbg( p_dec, "1st_field_offset %zu",
+                     p_sys->first_field_offset );
 #endif
             break;
 
@@ -468,7 +472,8 @@ static void ParseMetaInfo( decoder_t *p_dec, block_t *p_spu  )
             p_sys->second_field_offset =
                 (p[2] << 8) + p[3] - p_sys->i_image_offset;
 #ifdef DEBUG_CVDSUB
-            msg_Dbg( p_dec, "2nd_field_offset %d", p_sys->second_field_offset);
+            msg_Dbg( p_dec, "2nd_field_offset %zu",
+                     p_sys->second_field_offset);
 #endif
             break;
 
@@ -499,14 +504,14 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
     p_spu = p_dec->pf_spu_buffer_new( p_dec );
     if( !p_spu ) return NULL;
 
-    p_spu->b_pausable = VLC_TRUE;
+    p_spu->b_pausable = true;
 
     p_spu->i_x = p_sys->i_x_start;
     p_spu->i_x = p_spu->i_x * 3 / 4; /* FIXME: use aspect ratio for x? */
     p_spu->i_y = p_sys->i_y_start;
     p_spu->i_start = p_data->i_pts;
     p_spu->i_stop  = p_data->i_pts + p_sys->i_duration;
-    p_spu->b_ephemer = VLC_TRUE;
+    p_spu->b_ephemer = true;
 
     /* Create new SPU region */
     memset( &fmt, 0, sizeof(video_format_t) );