* parse.c: Philips OGT (SVCD subtitle) packet parser
*****************************************************************************
* Copyright (C) 2003, 2004 VideoLAN
- * $Id: cvd_parse.c,v 1.9 2004/01/10 13:59:25 rocky Exp $
+ * $Id$
*
* Authors: Rocky Bernstein
* based on code from:
p_sys->metadata_offset = GETINT16(p);
p_sys->metadata_length = p_sys->i_spu_size - p_sys->metadata_offset;
- p_sys->comp_image_offset = 4;
- p_sys->comp_image_length = p_sys->metadata_offset - p_sys->comp_image_offset;
+ p_sys->i_image_offset = 4;
+ p_sys->i_image_length = p_sys->metadata_offset - p_sys->i_image_offset;
dbg_print(DECODE_DBG_PACKET, "total size: %d image size: %d\n",
- p_sys->i_spu_size, p_sys->comp_image_length);
+ p_sys->i_spu_size, p_sys->i_image_length);
}
switch ( p[0] ) {
case 0x04: /* subtitle duration in 1/90000ths of a second */
+ {
+ mtime_t i_duration = (p[1]<<16) + (p[2]<<8) + p[3];
+ mtime_t i_duration_scale = config_GetInt( p_dec, MODULE_STRING
+ "-duration-scaling" );
+
+ dbg_print( DECODE_DBG_PACKET,
+ "subtitle display duration %lu secs (scaled %lu secs)",
+ (long unsigned int) (i_duration / 90000),
+ (long unsigned int) (i_duration * i_duration_scale / 90000)
+ );
+ p_sys->i_duration = i_duration * i_duration_scale ;
+ break;
+ }
- 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,
case 0x47:
/* offset to start of even rows of interlaced image, we correct
- to make it relative to comp_image_offset (usually 4) */
+ to make it relative to i_image_offset (usually 4) */
p_sys->first_field_offset =
- (p[2] << 8) + p[3] - p_sys->comp_image_offset;
+ (p[2] << 8) + p[3] - p_sys->i_image_offset;
dbg_print( DECODE_DBG_PACKET,
"first_field_offset %d", p_sys->first_field_offset);
break;
case 0x4f:
/* offset to start of odd rows of interlaced image, we correct
- to make it relative to comp_image_offset (usually 4) */
+ to make it relative to i_image_offset (usually 4) */
p_sys->second_field_offset =
- (p[2] << 8) + p[3] - p_sys->comp_image_offset;
+ (p[2] << 8) + p[3] - p_sys->i_image_offset;
dbg_print( DECODE_DBG_PACKET,
"second_field_offset %d", p_sys->second_field_offset);
break;
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_EXT) , "");
/* Allocate the subpicture internal data. */
- p_spu = vout_CreateSubPicture( p_sys->p_vout, MEMORY_SUBPICTURE );
- if( p_spu == NULL )
- {
- return;
- }
+ p_spu = spu_CreateSubpicture( p_sys->p_vout->p_spu );
+ if( p_spu == NULL ) return;
+
+ p_spu->i_channel = p_sys->i_subpic_channel;
/* In ParseImage we expand the run-length encoded color 0's; also
we expand pixels and remove the color palette. This should
/* Fill the p_spu structure */
vlc_mutex_init( p_dec, &p_spu->p_sys->lock );
- p_spu->pf_render = VCDSubRender;
+ p_spu->pf_render = VCDSubBlend;
p_spu->pf_destroy = VCDSubDestroySPU;
p_spu->p_sys->p_data = (uint8_t*)p_spu->p_sys + sizeof( subpicture_sys_t );
p_spu->p_sys->i_x_end = p_sys->i_x_start + p_sys->i_width - 1;
p_spu->p_sys->i_y_end = p_sys->i_y_start + p_sys->i_height - 1;
+ p_spu->i_x = p_sys->i_x_start
+ + config_GetInt( p_dec, MODULE_STRING "-horizontal-correct" );
+
+ p_spu->p_sys->p_palette[0] = p_sys->p_palette[0];
+ p_spu->p_sys->p_palette[1] = p_sys->p_palette[1];
+ p_spu->p_sys->p_palette[2] = p_sys->p_palette[2];
+ p_spu->p_sys->p_palette[3] = p_sys->p_palette[3];
+
/* FIXME: use aspect ratio for x? */
- p_spu->i_x = p_sys->i_x_start * 3 / 4;
- p_spu->i_y = p_sys->i_y_start;
+ p_spu->i_x = (p_spu->i_x * 3) / 4;
+ p_spu->i_y = p_sys->i_y_start
+ + config_GetInt( p_dec, MODULE_STRING "-vertical-correct" );
+
p_spu->i_width = p_sys->i_width;
p_spu->i_height = p_sys->i_height;
if( ParseImage( p_dec, p_spu ) )
{
/* There was a parse error, delete the subpicture */
- vout_DestroySubPicture( p_sys->p_vout, p_spu );
+ spu_DestroySubpicture( p_sys->p_vout->p_spu, p_spu );
return;
}
/* SPU is finished - we can ask the video output to display it */
- vout_DisplaySubPicture( p_sys->p_vout, p_spu );
+ spu_DisplaySubpicture( p_sys->p_vout->p_spu, p_spu );
}
uint8_t i_pending = 0; /* number of pixels to fill with
color zero 0..3 */
ogt_color_t i_color=0; /* current pixel color: 0..3 */
- uint8_t *p = p_sys->subtitle_data + p_sys->comp_image_offset;
- uint8_t *maxp = p + p_sys->comp_image_length;
+ uint8_t *p = p_sys->subtitle_data + p_sys->i_image_offset;
+ uint8_t *maxp = p + p_sys->i_image_length;
dbg_print( (DECODE_DBG_CALL) , "width x height: %dx%d",
i_width, i_height);
}
#endif /*HAVE_LIBPNG*/
- VCDInlinePalette( p_dest, p_sys, i_height, i_width );
-
- /* The video is automatically scaled. However subtitle bitmaps
- assume a 1:1 aspect ratio. So we need to scale to compensate for
- or undo the effects of video output scaling.
-
- Perhaps this should go in the Render routine? The advantage would
- be that it will deal with a dynamically changing aspect ratio.
- The downside is having to scale many times for each render call.
- */
-
- {
- vout_thread_t *p_vout = vlc_object_find( p_spu->p_sys->p_input,
- VLC_OBJECT_VOUT,
- FIND_CHILD );
- unsigned int i_aspect_x, i_aspect_y;
- if (p_vout) {
- vout_AspectRatio( p_vout->render.i_aspect, &i_aspect_x, &i_aspect_y );
- VCDSubScaleX( p_dec, p_spu, i_aspect_y, i_aspect_x );
- }
- }
+ VCDSubHandleScaling( p_spu, p_dec );
- /* To be finished...*/
return VLC_SUCCESS;
}