* Module descriptor.
*****************************************************************************/
-vlc_module_begin();
- set_capability( "decoder", 40 );
- set_shortname( N_("USFSubs"));
- set_description( N_("USF subtitles decoder") );
- set_callbacks( OpenDecoder, CloseDecoder );
- set_category( CAT_INPUT );
- set_subcategory( SUBCAT_INPUT_SCODEC );
+vlc_module_begin ()
+ set_capability( "decoder", 40 )
+ set_shortname( N_("USFSubs"))
+ set_description( N_("USF subtitles decoder") )
+ set_callbacks( OpenDecoder, CloseDecoder )
+ set_category( CAT_INPUT )
+ set_subcategory( SUBCAT_INPUT_SCODEC )
/* We inherit subsdec-align and subsdec-formatted from subsdec.c */
-vlc_module_end();
+vlc_module_end ()
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
return VLC_ENOMEM;
p_dec->pf_decode_sub = DecodeBlock;
+ p_dec->fmt_out.i_cat = SPU_ES;
+ p_dec->fmt_out.i_codec = 0;
/* Unused fields of p_sys - not needed for USF decoding */
p_sys->b_ass = false;
continue;
free( p_sys->pp_ssa_styles[i]->psz_stylename );
+ //FIXME: Make font_style a pointer and use text_style_* functions
free( p_sys->pp_ssa_styles[i]->font_style.psz_fontname );
free( p_sys->pp_ssa_styles[i] );
}
}
/* Create the subpicture unit */
- p_spu = p_dec->pf_spu_buffer_new( p_dec );
+ p_spu = decoder_NewSubpicture( p_dec );
if( !p_spu )
{
msg_Warn( p_dec, "can't get spu buffer" );
static ssa_style_t *ParseStyle( decoder_sys_t *p_sys, char *psz_subtitle )
{
- ssa_style_t *p_style = NULL;
+ ssa_style_t *p_ssa_style = NULL;
char *psz_style = GrabAttributeValue( "style", psz_subtitle );
if( psz_style )
for( i = 0; i < p_sys->i_ssa_styles; i++ )
{
if( !strcmp( p_sys->pp_ssa_styles[i]->psz_stylename, psz_style ) )
- p_style = p_sys->pp_ssa_styles[i];
+ p_ssa_style = p_sys->pp_ssa_styles[i];
}
free( psz_style );
}
- return p_style;
+ return p_ssa_style;
}
static int ParsePositionAttributeList( char *psz_subtitle, int *i_align,
/* Create a new subpicture region */
memset( &fmt, 0, sizeof(video_format_t) );
- fmt.i_chroma = VLC_FOURCC('T','E','X','T');
+ fmt.i_chroma = VLC_CODEC_TEXT;
fmt.i_aspect = 0;
fmt.i_width = fmt.i_height = 0;
fmt.i_x_offset = fmt.i_y_offset = 0;
if( p_text_region != NULL )
{
- ssa_style_t *p_style = NULL;
+ ssa_style_t *p_ssa_style = NULL;
p_text_region->psz_text = NULL;
p_text_region->psz_html = strndup( psz_subtitle, i_len );
return NULL;
}
- p_style = ParseStyle( p_sys, p_text_region->psz_html );
- if( !p_style )
+ p_ssa_style = ParseStyle( p_sys, p_text_region->psz_html );
+ if( !p_ssa_style )
{
int i;
for( i = 0; i < p_sys->i_ssa_styles; i++ )
{
if( !strcasecmp( p_sys->pp_ssa_styles[i]->psz_stylename, "Default" ) )
- p_style = p_sys->pp_ssa_styles[i];
+ p_ssa_style = p_sys->pp_ssa_styles[i];
}
}
- if( p_style )
+ if( p_ssa_style )
{
- msg_Dbg( p_dec, "style is: %s", p_style->psz_stylename );
+ msg_Dbg( p_dec, "style is: %s", p_ssa_style->psz_stylename );
- p_text_region->p_style = &p_style->font_style;
- p_text_region->i_align = p_style->i_align;
+ p_text_region->p_style = text_style_Duplicate( &p_ssa_style->font_style );
+ p_text_region->i_align = p_ssa_style->i_align;
/* TODO: Setup % based offsets properly, without adversely affecting
* everything else in vlc. Will address with separate patch,
* to prevent this one being any more complicated.
- * p_style->i_margin_percent_h;
- * p_style->i_margin_percent_v;
+ * p_ssa_style->i_margin_percent_h;
+ * p_ssa_style->i_margin_percent_v;
*/
- p_text_region->i_x = p_style->i_margin_h;
- p_text_region->i_y = p_style->i_margin_v;
+ p_text_region->i_x = p_ssa_style->i_margin_h;
+ p_text_region->i_y = p_ssa_style->i_margin_v;
}
else
{
input_attachment_t *p_attach = pp_attachments[k];
- vlc_fourcc_t type = 0;
-
- if( ( !strcmp( p_attach->psz_mime, "image/bmp" ) ) || /* BMP */
- ( !strcmp( p_attach->psz_mime, "image/x-bmp" ) ) ||
- ( !strcmp( p_attach->psz_mime, "image/x-bitmap" ) ) ||
- ( !strcmp( p_attach->psz_mime, "image/x-ms-bmp" ) ) )
- {
- type = VLC_FOURCC('b','m','p',' ');
- }
- else if( ( !strcmp( p_attach->psz_mime, "image/x-portable-anymap" ) ) || /* PNM */
- ( !strcmp( p_attach->psz_mime, "image/x-portable-bitmap" ) ) || /* PBM */
- ( !strcmp( p_attach->psz_mime, "image/x-portable-graymap" ) ) || /* PGM */
- ( !strcmp( p_attach->psz_mime, "image/x-portable-pixmap" ) ) ) /* PPM */
- {
- type = VLC_FOURCC('p','n','m',' ');
- }
- else if ( !strcmp( p_attach->psz_mime, "image/gif" ) ) /* GIF */
- type = VLC_FOURCC('g','i','f',' ');
- else if ( !strcmp( p_attach->psz_mime, "image/jpeg" ) ) /* JPG, JPEG */
- type = VLC_FOURCC('j','p','e','g');
- else if ( !strcmp( p_attach->psz_mime, "image/pcx" ) ) /* PCX */
- type = VLC_FOURCC('p','c','x',' ');
- else if ( !strcmp( p_attach->psz_mime, "image/png" ) ) /* PNG */
- type = VLC_FOURCC('p','n','g',' ');
- else if ( !strcmp( p_attach->psz_mime, "image/tiff" ) ) /* TIF, TIFF */
- type = VLC_FOURCC('t','i','f','f');
- else if ( !strcmp( p_attach->psz_mime, "image/x-tga" ) ) /* TGA */
- type = VLC_FOURCC('t','g','a',' ');
- else if ( !strcmp( p_attach->psz_mime, "image/x-xpixmap") ) /* XPM */
- type = VLC_FOURCC('x','p','m',' ');
+ vlc_fourcc_t type = image_Mime2Fourcc( p_attach->psz_mime );
if( ( type != 0 ) &&
( p_attach->i_data > 0 ) &&
memset( &fmt_out, 0, sizeof( video_format_t));
fmt_in.i_chroma = type;
- fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
+ fmt_out.i_chroma = VLC_CODEC_YUVA;
/* Find a suitable decoder module */
if( module_exists( "sdl_image" ) )
{
decoder_sys_t *p_sys = p_dec->p_sys;
char *psz_node;
- ssa_style_t *p_style = NULL;
+ ssa_style_t *p_ssa_style = NULL;
int i_style_level = 0;
int i_metadata_level = 0;
case 2:
if( !strcasecmp( "style", psz_node ) )
{
- TAB_APPEND( p_sys->i_ssa_styles, p_sys->pp_ssa_styles, p_style );
+ TAB_APPEND( p_sys->i_ssa_styles, p_sys->pp_ssa_styles, p_ssa_style );
- p_style = NULL;
+ p_ssa_style = NULL;
i_style_level--;
}
break;
{
i_style_level++;
- p_style = calloc( 1, sizeof(ssa_style_t) );
- if( ! p_style )
+ p_ssa_style = calloc( 1, sizeof(ssa_style_t) );
+ if( !p_ssa_style )
{
free( psz_node );
- break;
+ return;
}
/* All styles are supposed to default to Default, and then
* one or more settings are over-ridden.
{
ssa_style_t *p_default_style = p_sys->pp_ssa_styles[i];
- memcpy( p_style, p_default_style, sizeof( ssa_style_t ) );
- p_style->font_style.psz_fontname = strdup( p_style->font_style.psz_fontname );
- p_style->psz_stylename = NULL;
+ memcpy( p_ssa_style, p_default_style, sizeof( ssa_style_t ) );
+ //FIXME: Make font_style a pointer. Actually we double copy some data here,
+ // we use text_style_Copy to avoid copying psz_fontname, though .
+ text_style_Copy( &p_ssa_style->font_style, &p_default_style->font_style );
+ p_ssa_style->psz_stylename = NULL;
}
}
if( psz_name && psz_value )
{
if( !strcasecmp( "name", psz_name ) )
- p_style->psz_stylename = strdup( psz_value);
+ p_ssa_style->psz_stylename = strdup( psz_value );
}
free( psz_name );
free( psz_value );
{
if( !strcasecmp( "face", psz_name ) )
{
- free( p_style->font_style.psz_fontname );
- p_style->font_style.psz_fontname = strdup( psz_value );
+ free( p_ssa_style->font_style.psz_fontname );
+ p_ssa_style->font_style.psz_fontname = strdup( psz_value );
}
else if( !strcasecmp( "size", psz_name ) )
{
int i_value = atoi( psz_value );
if( ( i_value >= -5 ) && ( i_value <= 5 ) )
- p_style->font_style.i_font_size +=
- ( i_value * p_style->font_style.i_font_size ) / 10;
+ p_ssa_style->font_style.i_font_size +=
+ ( i_value * p_ssa_style->font_style.i_font_size ) / 10;
else if( i_value < -5 )
- p_style->font_style.i_font_size = - i_value;
+ p_ssa_style->font_style.i_font_size = - i_value;
else if( i_value > 5 )
- p_style->font_style.i_font_size = i_value;
+ p_ssa_style->font_style.i_font_size = i_value;
}
else
- p_style->font_style.i_font_size = atoi( psz_value );
+ p_ssa_style->font_style.i_font_size = atoi( psz_value );
}
else if( !strcasecmp( "italic", psz_name ) )
{
if( !strcasecmp( "yes", psz_value ))
- p_style->font_style.i_style_flags |= STYLE_ITALIC;
+ p_ssa_style->font_style.i_style_flags |= STYLE_ITALIC;
else
- p_style->font_style.i_style_flags &= ~STYLE_ITALIC;
+ p_ssa_style->font_style.i_style_flags &= ~STYLE_ITALIC;
}
else if( !strcasecmp( "weight", psz_name ) )
{
if( !strcasecmp( "bold", psz_value ))
- p_style->font_style.i_style_flags |= STYLE_BOLD;
+ p_ssa_style->font_style.i_style_flags |= STYLE_BOLD;
else
- p_style->font_style.i_style_flags &= ~STYLE_BOLD;
+ p_ssa_style->font_style.i_style_flags &= ~STYLE_BOLD;
}
else if( !strcasecmp( "underline", psz_name ) )
{
if( !strcasecmp( "yes", psz_value ))
- p_style->font_style.i_style_flags |= STYLE_UNDERLINE;
+ p_ssa_style->font_style.i_style_flags |= STYLE_UNDERLINE;
else
- p_style->font_style.i_style_flags &= ~STYLE_UNDERLINE;
+ p_ssa_style->font_style.i_style_flags &= ~STYLE_UNDERLINE;
}
else if( !strcasecmp( "color", psz_name ) )
{
if( *psz_value == '#' )
{
unsigned long col = strtol(psz_value+1, NULL, 16);
- p_style->font_style.i_font_color = (col & 0x00ffffff);
- p_style->font_style.i_font_alpha = (col >> 24) & 0xff;
+ p_ssa_style->font_style.i_font_color = (col & 0x00ffffff);
+ p_ssa_style->font_style.i_font_alpha = (col >> 24) & 0xff;
}
}
else if( !strcasecmp( "outline-color", psz_name ) )
if( *psz_value == '#' )
{
unsigned long col = strtol(psz_value+1, NULL, 16);
- p_style->font_style.i_outline_color = (col & 0x00ffffff);
- p_style->font_style.i_outline_alpha = (col >> 24) & 0xff;
+ p_ssa_style->font_style.i_outline_color = (col & 0x00ffffff);
+ p_ssa_style->font_style.i_outline_alpha = (col >> 24) & 0xff;
}
}
else if( !strcasecmp( "outline-level", psz_name ) )
{
- p_style->font_style.i_outline_width = atoi( psz_value );
+ p_ssa_style->font_style.i_outline_width = atoi( psz_value );
}
else if( !strcasecmp( "shadow-color", psz_name ) )
{
if( *psz_value == '#' )
{
unsigned long col = strtol(psz_value+1, NULL, 16);
- p_style->font_style.i_shadow_color = (col & 0x00ffffff);
- p_style->font_style.i_shadow_alpha = (col >> 24) & 0xff;
+ p_ssa_style->font_style.i_shadow_color = (col & 0x00ffffff);
+ p_ssa_style->font_style.i_shadow_alpha = (col >> 24) & 0xff;
}
}
else if( !strcasecmp( "shadow-level", psz_name ) )
{
- p_style->font_style.i_shadow_width = atoi( psz_value );
+ p_ssa_style->font_style.i_shadow_width = atoi( psz_value );
}
else if( !strcasecmp( "back-color", psz_name ) )
{
if( *psz_value == '#' )
{
unsigned long col = strtol(psz_value+1, NULL, 16);
- p_style->font_style.i_karaoke_background_color = (col & 0x00ffffff);
- p_style->font_style.i_karaoke_background_alpha = (col >> 24) & 0xff;
+ p_ssa_style->font_style.i_karaoke_background_color = (col & 0x00ffffff);
+ p_ssa_style->font_style.i_karaoke_background_alpha = (col >> 24) & 0xff;
}
}
else if( !strcasecmp( "spacing", psz_name ) )
{
- p_style->font_style.i_spacing = atoi( psz_value );
+ p_ssa_style->font_style.i_spacing = atoi( psz_value );
}
}
free( psz_name );
if( !strcasecmp( "alignment", psz_name ) )
{
if( !strcasecmp( "TopLeft", psz_value ) )
- p_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
+ p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "TopCenter", psz_value ) )
- p_style->i_align = SUBPICTURE_ALIGN_TOP;
+ p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP;
else if( !strcasecmp( "TopRight", psz_value ) )
- p_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_RIGHT;
+ p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_RIGHT;
else if( !strcasecmp( "MiddleLeft", psz_value ) )
- p_style->i_align = SUBPICTURE_ALIGN_LEFT;
+ p_ssa_style->i_align = SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "MiddleCenter", psz_value ) )
- p_style->i_align = 0;
+ p_ssa_style->i_align = 0;
else if( !strcasecmp( "MiddleRight", psz_value ) )
- p_style->i_align = SUBPICTURE_ALIGN_RIGHT;
+ p_ssa_style->i_align = SUBPICTURE_ALIGN_RIGHT;
else if( !strcasecmp( "BottomLeft", psz_value ) )
- p_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT;
+ p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "BottomCenter", psz_value ) )
- p_style->i_align = SUBPICTURE_ALIGN_BOTTOM;
+ p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM;
else if( !strcasecmp( "BottomRight", psz_value ) )
- p_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT;
+ p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT;
}
else if( !strcasecmp( "horizontal-margin", psz_name ) )
{
if( strchr( psz_value, '%' ) )
{
- p_style->i_margin_h = 0;
- p_style->i_margin_percent_h = atoi( psz_value );
+ p_ssa_style->i_margin_h = 0;
+ p_ssa_style->i_margin_percent_h = atoi( psz_value );
}
else
{
- p_style->i_margin_h = atoi( psz_value );
- p_style->i_margin_percent_h = 0;
+ p_ssa_style->i_margin_h = atoi( psz_value );
+ p_ssa_style->i_margin_percent_h = 0;
}
}
else if( !strcasecmp( "vertical-margin", psz_name ) )
{
if( strchr( psz_value, '%' ) )
{
- p_style->i_margin_v = 0;
- p_style->i_margin_percent_v = atoi( psz_value );
+ p_ssa_style->i_margin_v = 0;
+ p_ssa_style->i_margin_percent_v = atoi( psz_value );
}
else
{
- p_style->i_margin_v = atoi( psz_value );
- p_style->i_margin_percent_v = 0;
+ p_ssa_style->i_margin_v = atoi( psz_value );
+ p_ssa_style->i_margin_percent_v = 0;
}
}
}
break;
}
}
- free( p_style );
+ free( p_ssa_style );
}
/* Display the feed's image */
memset( &fmt_out, 0, sizeof( video_format_t));
- fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
+ fmt_out.i_chroma = VLC_CODEC_YUVA;
fmt_out.i_aspect = VOUT_ASPECT_FACTOR;
fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
fmt_out.i_width =
msg_Err( p_dec, "cannot allocate SPU region" );
return NULL;
}
- assert( p_pic->format.i_chroma == VLC_FOURCC('Y','U','V','A') );
+ assert( p_pic->format.i_chroma == VLC_CODEC_YUVA );
/* FIXME the copy is probably not needed anymore */
picture_CopyPixels( p_region->p_picture, p_pic );
int i_u = ( ( -38 * i_r - 74 * i_g + 112 * i_b + 128 ) >> 8 ) + 128 ;
int i_v = ( ( 112 * i_r - 94 * i_g - 18 * i_b + 128 ) >> 8 ) + 128 ;
- assert( p_region->fmt.i_chroma == VLC_FOURCC('Y','U','V','A') );
+ assert( p_region->fmt.i_chroma == VLC_CODEC_YUVA );
for( unsigned int y = 0; y < p_region->fmt.i_height; y++ )
{
for( unsigned int x = 0; x < p_region->fmt.i_width; x++ )