]> git.sesse.net Git - vlc/blobdiff - modules/codec/svcdsub.c
jvlc: wait for correct player status before releasing libvlc
[vlc] / modules / codec / svcdsub.c
index d97d04c23d07dd59f77f1fceaaebeba457323f22..b7bf4a9f9a1f26633b97f12c0733dd4ccc21ff93 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <vlc/vlc.h>
-#include <vlc/decoder.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_codec.h>
+#include <vlc_osd.h>
 #include "vlc_bits.h"
 
 /*****************************************************************************
@@ -39,27 +44,26 @@ static int  DecoderOpen   ( vlc_object_t * );
 static int  PacketizerOpen( vlc_object_t * );
 static void DecoderClose  ( vlc_object_t * );
 
-#define DEBUG_TEXT \
-     "If nonzero, this gives additional debug information." \
+#define DEBUG_TEXT N_("Enable debug")
 
-#define DEBUG_LONGTEXT \
-    "This integer when viewed in binary is a debugging mask\n" \
+#define DEBUG_LONGTEXT  \
+    N_("This integer when viewed in binary is a debugging mask\n" \
     "calls                 1\n" \
-    "packet assembly info  2\n"
+    "packet assembly info  2\n" )
 
 vlc_module_begin();
-    set_description( _("Philips OGT (SVCD subtitle) decoder") );
-    set_shortname( N_("SVCD subtitles"));
+    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, VLC_TRUE );
+                  DEBUG_TEXT, DEBUG_LONGTEXT, true );
 
     add_submodule();
-    set_description( _("Philips OGT (SVCD subtitle) packetizer") );
+    set_description( N_("Philips OGT (SVCD subtitle) packetizer") );
     set_capability( "packetizer", 50 );
     set_callbacks( PacketizerOpen, DecoderClose );
 vlc_module_end();
@@ -110,15 +114,15 @@ struct decoder_sys_t
   uint16_t i_image;       /* image number in the subtitle stream */
   uint8_t  i_packet;      /* packet number for above image number */
 
-  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 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 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" */
@@ -257,7 +261,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;
@@ -346,12 +350,12 @@ 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, "subtitle packets size=%d should be %d",
+            msg_Warn( p_dec, "subtitle packets size=%zu should be %zu",
                       p_spu->i_buffer, p_sys->i_spu_size );
         }
 
-       dbg_print( (DECODE_DBG_PACKET),
-                 "subtitle packet complete, size=%d", p_spu->i_buffer );
+    dbg_print( (DECODE_DBG_PACKET),
+                 "subtitle packet complete, size=%zu", p_spu->i_buffer );
 
         p_sys->i_state = SUBTITLE_BLOCK_EMPTY;
         p_sys->p_spu = 0;
@@ -366,14 +370,14 @@ static block_t *Reassemble( decoder_t *p_dec, block_t *p_block )
  
    size     description
    -------------------------------------------
-   byte     subtitle channel (0..7) in bits 0-3 
+   byte     subtitle channel (0..7) in bits 0-3
    byte     subtitle packet number of this subtitle image 0-N,
             if the subtitle packet is complete, the top bit of the byte is 1.
    u_int16  subtitle image number
    u_int16  length in bytes of the rest
    byte     option flags, unknown meaning except bit 3 (0x08) indicates
             presence of the duration field
-   byte     unknown 
+   byte     unknown
    u_int32  duration in 1/90000ths of a second (optional), start time
             is as indicated by the PTS in the PES header
    u_int32  xpos
@@ -386,7 +390,7 @@ static block_t *Reassemble( decoder_t *p_dec, block_t *p_block )
             cmd>>6==1 indicates shift
             (cmd>>4)&3 is direction from, (0=top,1=left,2=right,3=bottom)
    u_int32  shift duration in 1/90000ths of a second
-   u_int16  offset of odd-numbered scanlines - subtitle images are 
+   u_int16  offset of odd-numbered scanlines - subtitle images are
             given in interlace order
    byte[]   limited RLE image data in interlace order (0,2,4... 1,3,5) with
             2-bits per palette number
@@ -430,20 +434,20 @@ 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 && p_sys->i_debug & DECODE_DBG_PACKET)
   {
       msg_Dbg( p_dec, "x-start: %d, y-start: %d, width: %d, height %d, "
-              "spu size: %d, duration: %lu (d:%d p:%d)",
-              p_sys->i_x_start, p_sys->i_y_start, 
-              p_sys->i_width, p_sys->i_height, 
-              p_sys->i_spu_size, (long unsigned int) p_sys->i_duration,
-              p_sys->i_image_length, p_sys->i_image_offset);
-      
+           "spu size: %zu, duration: %"PRIu64" (d:%zu p:%"PRIu16")",
+           p_sys->i_x_start, p_sys->i_y_start,
+           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,
-                  p_sys->p_palette[i][3], p_sys->p_palette[i][0], 
-                  p_sys->p_palette[i][1], p_sys->p_palette[i][2] );
+           p_sys->p_palette[i][3], p_sys->p_palette[i][0],
+           p_sys->p_palette[i][1], p_sys->p_palette[i][2] );
       }
   }
 }
@@ -466,11 +470,13 @@ 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 = true;
+
     p_spu->i_x = p_sys->i_x_start;
     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 subtitle region */
     memset( &fmt, 0, sizeof(video_format_t) );
@@ -497,7 +503,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
     }
 
     p_region->fmt.i_aspect = VOUT_ASPECT_FACTOR;
-    
     p_spu->p_region = p_region;
     p_region->i_x = p_region->i_y = 0;
 
@@ -535,7 +541,7 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
  interlacing will also be removed.
  *****************************************************************************/
 static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data,
-                               subpicture_region_t *p_region )
+                subpicture_region_t *p_region )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
     uint8_t *p_dest = p_region->picture.Y_PIXELS;