]> git.sesse.net Git - vlc/blobdiff - modules/codec/ogt/cvd.c
string review
[vlc] / modules / codec / ogt / cvd.c
index 498d068a02fd0d6e1e943a3f32c8e7a0ea69ac2b..21da13d1c55edeed42cda0451c7cf5d8534c690e 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * cvd.c : CVD Subtitle decoder thread
  *****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: cvd.c,v 1.6 2004/01/03 12:54:56 rocky Exp $
+ * Copyright (C) 2003, 2004 VideoLAN
+ * $Id: cvd.c,v 1.14 2004/01/25 18:20:12 bigben Exp $
  *
  * Authors: Rocky Bernstein
  *   based on code from:
@@ -48,9 +48,23 @@ vlc_module_begin();
     set_callbacks( DecoderOpen, VCDSubClose );
 
     add_integer ( MODULE_STRING "-debug", 0, NULL,
-                  N_("set debug mask for additional debugging."),
+                  N_("Set debug mask for additional debugging."),
                   N_(DEBUG_LONGTEXT), VLC_TRUE );
 
+    add_integer ( MODULE_STRING "-horizontal-correct", 0, NULL,
+                  HORIZONTAL_CORRECT, HORIZONTAL_CORRECT_LONGTEXT, VLC_FALSE );
+
+    add_integer ( MODULE_STRING "-vertical-correct", 0, NULL,
+                  VERTICAL_CORRECT, VERTICAL_CORRECT_LONGTEXT, VLC_FALSE );
+
+    add_string( MODULE_STRING "-aspect-ratio", "", NULL,
+                SUB_ASPECT_RATIO_TEXT, SUB_ASPECT_RATIO_LONGTEXT, 
+               VLC_TRUE );
+
+    add_integer( MODULE_STRING "-duration-scaling", 9, NULL,
+                DURATION_SCALE_TEXT, DURATION_SCALE_LONGTEXT,
+                VLC_TRUE );
+
     add_submodule();
     set_description( _("Chaoji VCD subtitle packetizer") );
     set_capability( "packetizer", 50 );
@@ -182,11 +196,11 @@ Packetize( decoder_t *p_dec, block_t **pp_block )
 /*****************************************************************************
  Reassemble:
 
- The data for single screen subtitle may come in one of many
- non-contiguous packets of a stream. This routine is called when the
- next packet in the stream comes in. The job of this routine is to
- parse the header, if this is the beginning, and combine the packets
into one complete subtitle unit.
+ Data for single screen subtitle may come in several non-contiguous
+ packets of a stream. This routine is called when the next packet in
+ the stream comes in. The job of this routine is to parse the header,
+ if this is the beginning, and combine the packets into one complete
+ subtitle unit.
 
  If everything is complete, we will return a block. Otherwise return
  NULL.
@@ -225,10 +239,10 @@ Reassemble( decoder_t *p_dec, block_t **pp_block )
     if( config_GetInt( p_dec, "spu-channel" ) != p_buffer[0] )
       return NULL;
 
-    /* There is little data on the format, but it does not seem to have a
-       good way to detect the first packet in the subtitle.  It seems,
-       however, that it has a valid pts while later packets for the same
-       image don't */
+    /* From the scant data on the format, there is only only way known
+       to detect the first packet in a subtitle.  The first packet
+       seems to have a valid PTS while later packets for the same
+       image don't. */
 
     if ( p_sys->state == SUBTITLE_BLOCK_EMPTY && p_block->i_pts == 0 ) {
       msg_Warn( p_dec, 
@@ -243,164 +257,15 @@ Reassemble( decoder_t *p_dec, block_t **pp_block )
     }
 
     /* FIXME - remove append_data and use chainappend */
-    VCDSubAppendData( p_dec, p_buffer, p_block->i_buffer - SPU_HEADER_LEN );
+    VCDSubAppendData( p_dec, p_buffer + SPU_HEADER_LEN, 
+                     p_block->i_buffer - SPU_HEADER_LEN );
 
     block_ChainAppend( &p_sys->p_block, p_block );
 
     p_sys->i_spu += p_block->i_buffer - SPU_HEADER_LEN;
 
     if ( p_sys->subtitle_data_pos == p_sys->i_spu_size ) {
-      /* last packet in subtitle block. */
-
-      uint8_t *p     = p_sys->subtitle_data + p_sys->metadata_offset+1;
-      uint8_t *p_end = p + p_sys->metadata_length;
-
-      dbg_print( (DECODE_DBG_PACKET),
-                 "subtitle packet complete, size=%d", p_sys->i_spu );
-
-      p_sys->state = SUBTITLE_BLOCK_COMPLETE;
-      p_sys->i_image++;
-
-
-      for ( ; p < p_end; p += 4 ) {
-
-       switch ( p[0] ) {
-         
-       case 0x04:      /* Display duration in 1/90000ths of a second */
-
-         p_sys->i_duration = (p[1]<<16) + (p[2]<<8) + p[3];
-         
-         dbg_print( DECODE_DBG_PACKET, 
-                    "subtitle display duration %u", p_sys->i_duration);
-         break;
-         
-       case 0x0c:      /* Unknown */
-         dbg_print( DECODE_DBG_PACKET, 
-                    "subtitle command unknown 0x%0x 0x%0x 0x%0x 0x%0x\n",
-                   p[0], p[1], p[2], p[3]);
-         break;
-         
-       case 0x17:      /* Position */
-         p_sys->i_x_start = ((p[1]&0x0f)<<6) + (p[2]>>2);
-         p_sys->i_y_start = ((p[2]&0x03)<<8) + p[3];
-         dbg_print( DECODE_DBG_PACKET, 
-                    "start position (%d,%d): %.2x %.2x %.2x", 
-                    p_sys->i_x_start, p_sys->i_y_start,
-                    p[1], p[2], p[3] );
-         break;
-         
-       case 0x1f:      /* Coordinates of the image bottom right */
-         {
-           int lastx = ((p[1]&0x0f)<<6) + (p[2]>>2);
-           int lasty = ((p[2]&0x03)<<8) + p[3];
-           p_sys->i_width  = lastx - p_sys->i_x_start + 1;
-           p_sys->i_height = lasty - p_sys->i_y_start + 1;
-           dbg_print( DECODE_DBG_PACKET, 
-                      "end position: (%d,%d): %.2x %.2x %.2x, w x h: %dx%d",
-                      lastx, lasty, p[1], p[2], p[3], 
-                      p_sys->i_width, p_sys->i_height );
-           break;
-         }
-         
-         
-       case 0x24:
-       case 0x25:
-       case 0x26:
-       case 0x27: 
-         {
-           uint8_t v = p[0]-0x24;
-           
-           /* Primary Palette */
-           dbg_print( DECODE_DBG_PACKET,
-                      "primary palette %d (y,u,v): (0x%0x,0x%0x,0x%0x)",
-                      v, p[1], p[2], p[3]);
-           
-           p_sys->p_palette[v].s.y = p[1];
-           p_sys->p_palette[v].s.u = p[2];
-           p_sys->p_palette[v].s.v = p[3];
-           break;
-         }
-         
-         
-       case 0x2c:
-       case 0x2d:
-       case 0x2e:
-       case 0x2f:
-         {
-           uint8_t v = p[0]-0x2c;
-           
-           dbg_print( DECODE_DBG_PACKET,
-                      "highlight palette %d (y,u,v): (0x%0x,0x%0x,0x%0x)",
-                      v, p[1], p[2], p[3]);
-           
-           /* Highlight Palette */
-           p_sys->p_palette_highlight[v].s.y = p[1];
-           p_sys->p_palette_highlight[v].s.u = p[2];
-           p_sys->p_palette_highlight[v].s.v = p[3];
-           break;
-         }
-
-       case 0x37:
-         /* transparency for primary palette */
-         p_sys->p_palette[0].s.t = p[3] & 0x0f;
-         p_sys->p_palette[1].s.t = p[3] >> 4;
-         p_sys->p_palette[2].s.t = p[2] & 0x0f;
-         p_sys->p_palette[3].s.t = p[2] >> 4;
-
-         dbg_print( DECODE_DBG_PACKET,
-                    "transparancy for primary palette 0..3: "
-                    "0x%0x 0x%0x 0x%0x 0x%0x",
-                    p_sys->p_palette[0].s.t,
-                    p_sys->p_palette[1].s.t,
-                    p_sys->p_palette[2].s.t,
-                    p_sys->p_palette[3].s.t );
-
-         break;
-
-       case 0x3f:
-         /* transparency for highlight palette */
-         p_sys->p_palette_highlight[0].s.t = p[2] & 0x0f;
-         p_sys->p_palette_highlight[1].s.t = p[2] >> 4;
-         p_sys->p_palette_highlight[2].s.t = p[1] & 0x0f;
-         p_sys->p_palette_highlight[3].s.t = p[1] >> 4;
-
-         dbg_print( DECODE_DBG_PACKET,
-                    "transparancy for primary palette 0..3: "
-                    "0x%0x 0x%0x 0x%0x 0x%0x",
-                    p_sys->p_palette_highlight[0].s.t,
-                    p_sys->p_palette_highlight[1].s.t,
-                    p_sys->p_palette_highlight[2].s.t,
-                    p_sys->p_palette_highlight[3].s.t );
-
-         break;
-         
-       case 0x47:
-         /* offset to first field data, we correct to make it relative
-            to comp_image_offset (usually 4) */
-         p_sys->first_field_offset =
-           (p[2] << 8) + p[3] - p_sys->comp_image_offset;
-         dbg_print( DECODE_DBG_PACKET, 
-                    "first_field_offset %d", p_sys->first_field_offset);
-         break;
-         
-       case 0x4f:
-         /* offset to second field data, we correct to make it relative to
-            comp_image_offset (usually 4) */
-         p_sys->second_field_offset =
-           (p[2] << 8) + p[3] - p_sys->comp_image_offset;
-         dbg_print( DECODE_DBG_PACKET, 
-                    "second_field_offset %d", p_sys->second_field_offset);
-         break;
-         
-       default:
-         msg_Warn( p_dec, 
-                   "unknown sequence in control header " 
-                   "0x%0x 0x%0x 0x%0x 0x%0x",
-                   p[0], p[1], p[2], p[3]);
-         
-         p_sys->subtitle_data_pos = 0;
-       }
-      }
+      E_(ParseMetaInfo)( p_dec );
       return p_sys->p_block;
     } else {
       /* Not last block in subtitle, so wait for another. */