Commit 14dd917d authored by Laurent Aimar's avatar Laurent Aimar

Removed unused or redondant fields from subpicture.

I removed:
 i_x/i_y: redondant with region i_x/i_y. Now a subpicture always represent the
 whole video.
 i_flags: unused anywhere in the core.

 I may have broken a few video filters (osdmenu mainly). I will fix it if you
report the problem and the way to reproduce it.
parent 3318cf72
...@@ -353,14 +353,11 @@ struct subpicture_t ...@@ -353,14 +353,11 @@ struct subpicture_t
* changed by the video output thread, or simply ignored depending of the * changed by the video output thread, or simply ignored depending of the
* subtitle type. */ * subtitle type. */
/**@{*/ /**@{*/
int i_x; /**< offset from alignment position */
int i_y; /**< offset from alignment position */
int i_alpha; /**< transparency */
int i_original_picture_width; /**< original width of the movie */ int i_original_picture_width; /**< original width of the movie */
int i_original_picture_height;/**< original height of the movie */ int i_original_picture_height;/**< original height of the movie */
bool b_absolute; /**< position is absolute */
int i_flags; /**< position flags */
bool b_subtitle; /**< the picture is a movie subtitle */ bool b_subtitle; /**< the picture is a movie subtitle */
bool b_absolute; /**< position is absolute */
int i_alpha; /**< transparency */
/**@}*/ /**@}*/
/** Pointer to function that renders this subtitle in a picture */ /** Pointer to function that renders this subtitle in a picture */
......
...@@ -357,8 +357,8 @@ static subpicture_t *Subtitle( decoder_t *p_dec, char *psz_subtitle, char *psz_h ...@@ -357,8 +357,8 @@ static subpicture_t *Subtitle( decoder_t *p_dec, char *psz_subtitle, char *psz_h
/* Decode and format the subpicture unit */ /* Decode and format the subpicture unit */
/* Normal text subs, easy markup */ /* Normal text subs, easy markup */
p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM;// | SUBPICTURE_ALIGN_LEFT;// | p_sys->i_align; p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM;// | SUBPICTURE_ALIGN_LEFT;// | p_sys->i_align;
p_spu->i_x = 0; //p_sys->i_align ? 20 : 0; p_spu->p_region->i_x = 0; //p_sys->i_align ? 20 : 0;
p_spu->i_y = 10; p_spu->p_region->i_y = 10;
p_spu->p_region->psz_text = psz_subtitle; p_spu->p_region->psz_text = psz_subtitle;
p_spu->p_region->psz_html = psz_html; p_spu->p_region->psz_html = psz_html;
......
...@@ -204,8 +204,6 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -204,8 +204,6 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
memcpy( p_spu->p_sys->p_subs_data, p_block->p_buffer, memcpy( p_spu->p_sys->p_subs_data, p_block->p_buffer,
p_block->i_buffer ); p_block->i_buffer );
p_spu->i_x = 0;
p_spu->i_y = 0;
p_spu->i_start = p_block->i_pts; p_spu->i_start = p_block->i_pts;
p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->i_stop = p_block->i_pts + p_block->i_length;
p_spu->b_ephemer = false; p_spu->b_ephemer = false;
......
...@@ -504,9 +504,6 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data ) ...@@ -504,9 +504,6 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
p_spu = p_dec->pf_spu_buffer_new( p_dec ); p_spu = p_dec->pf_spu_buffer_new( p_dec );
if( !p_spu ) return NULL; if( !p_spu ) return NULL;
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_start = p_data->i_pts;
p_spu->i_stop = p_data->i_pts + p_sys->i_duration; p_spu->i_stop = p_data->i_pts + p_sys->i_duration;
p_spu->b_ephemer = true; p_spu->b_ephemer = true;
...@@ -526,7 +523,9 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data ) ...@@ -526,7 +523,9 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
} }
p_spu->p_region = p_region; p_spu->p_region = p_region;
p_region->i_x = p_region->i_y = 0; p_region->i_x = p_sys->i_x_start;
p_region->i_x = p_region->i_x * 3 / 4; /* FIXME: use aspect ratio for x? */
p_region->i_y = p_sys->i_y_start;
/* Build palette */ /* Build palette */
fmt.p_palette->i_entries = 4; fmt.p_palette->i_entries = 4;
......
...@@ -1446,10 +1446,42 @@ static subpicture_t *render( decoder_t *p_dec ) ...@@ -1446,10 +1446,42 @@ static subpicture_t *render( decoder_t *p_dec )
subpicture_t *p_spu; subpicture_t *p_spu;
subpicture_region_t **pp_spu_region; subpicture_region_t **pp_spu_region;
int i, j, i_timeout = 0; int i, j, i_timeout = 0;
int i_base_x;
int i_base_y;
/* Allocate the subpicture internal data. */ /* Allocate the subpicture internal data. */
p_spu = p_dec->pf_spu_buffer_new( p_dec ); p_spu = p_dec->pf_spu_buffer_new( p_dec );
if( !p_spu ) return NULL; if( !p_spu )
return NULL;
p_spu->b_absolute = p_sys->b_absolute;
/* Set the pf_render callback */
p_spu->i_start = (mtime_t) p_sys->i_pts;
//p_spu->i_stop = (mtime_t) 0;
p_spu->b_ephemer = true;
//p_spu->b_fade = true;
//p_spu->i_stop = p_spu->i_start + (mtime_t) (i_timeout * 1000000);
/* Correct positioning of SPU */
i_base_x = p_sys->i_spu_x;
i_base_y = p_sys->i_spu_y;
p_spu->i_original_picture_width = 720;
p_spu->i_original_picture_height = 576;
if( p_sys->p_display )
{
p_spu->i_original_picture_width = p_sys->p_display->i_width;
p_spu->i_original_picture_height = p_sys->p_display->i_height;
if( p_sys->p_display->b_windowed )
{
/* TODO: check that this actually works */
p_spu->i_original_picture_width = p_sys->p_display->i_max_x - p_sys->p_display->i_x;
p_spu->i_original_picture_height = p_sys->p_display->i_max_y - p_sys->p_display->i_y;
i_base_x += p_sys->p_display->i_x;
i_base_y += p_sys->p_display->i_y;
}
}
pp_spu_region = &p_spu->p_region; pp_spu_region = &p_spu->p_region;
...@@ -1519,8 +1551,8 @@ static subpicture_t *render( decoder_t *p_dec ) ...@@ -1519,8 +1551,8 @@ static subpicture_t *render( decoder_t *p_dec )
msg_Err( p_dec, "cannot allocate SPU region" ); msg_Err( p_dec, "cannot allocate SPU region" );
continue; continue;
} }
p_spu_region->i_x = p_regiondef->i_x; p_spu_region->i_x = i_base_x + p_regiondef->i_x;
p_spu_region->i_y = p_regiondef->i_y; p_spu_region->i_y = i_base_y + p_regiondef->i_y;
p_spu_region->i_align = p_sys->i_spu_position; p_spu_region->i_align = p_sys->i_spu_position;
*pp_spu_region = p_spu_region; *pp_spu_region = p_spu_region;
pp_spu_region = &p_spu_region->p_next; pp_spu_region = &p_spu_region->p_next;
...@@ -1574,43 +1606,14 @@ static subpicture_t *render( decoder_t *p_dec ) ...@@ -1574,43 +1606,14 @@ static subpicture_t *render( decoder_t *p_dec )
} }
p_spu_region->psz_text = strdup( p_object_def->psz_text ); p_spu_region->psz_text = strdup( p_object_def->psz_text );
p_spu_region->i_x = p_regiondef->i_x + p_object_def->i_x; p_spu_region->i_x = i_base_x + p_regiondef->i_x + p_object_def->i_x;
p_spu_region->i_y = p_regiondef->i_y + p_object_def->i_y; p_spu_region->i_y = i_base_y + p_regiondef->i_y + p_object_def->i_y;
p_spu_region->i_align = p_sys->i_spu_position; p_spu_region->i_align = p_sys->i_spu_position;
*pp_spu_region = p_spu_region; *pp_spu_region = p_spu_region;
pp_spu_region = &p_spu_region->p_next; pp_spu_region = &p_spu_region->p_next;
} }
} }
/* Set the pf_render callback */
p_spu->i_start = (mtime_t) p_sys->i_pts;
//p_spu->i_stop = (mtime_t) 0;
p_spu->b_ephemer = true;
//p_spu->b_fade = true;
//p_spu->i_stop = p_spu->i_start + (mtime_t) (i_timeout * 1000000);
/* Correct positioning of SPU */
p_spu->b_absolute = p_sys->b_absolute;
p_spu->i_x = p_sys->i_spu_x;
p_spu->i_y = p_sys->i_spu_y;
p_spu->i_original_picture_width = 720;
p_spu->i_original_picture_height = 576;
if( p_sys->p_display )
{
p_spu->i_original_picture_width = p_sys->p_display->i_width;
p_spu->i_original_picture_height = p_sys->p_display->i_height;
if( p_sys->p_display->b_windowed )
{
/* TODO: check that this actually works */
p_spu->i_original_picture_width = p_sys->p_display->i_max_x - p_sys->p_display->i_x;
p_spu->i_original_picture_height = p_sys->p_display->i_max_y - p_sys->p_display->i_y;
p_spu->i_x += p_sys->p_display->i_x;
p_spu->i_y += p_sys->p_display->i_y;
}
}
return p_spu; return p_spu;
} }
...@@ -2092,8 +2095,8 @@ static void encode_page_composition( encoder_t *p_enc, bs_t *s, ...@@ -2092,8 +2095,8 @@ static void encode_page_composition( encoder_t *p_enc, bs_t *s,
} }
else else
{ {
bs_write( s, 16, p_subpic->i_x + p_region->i_x ); bs_write( s, 16, p_region->i_x );
bs_write( s, 16, p_subpic->i_y + p_region->i_y ); bs_write( s, 16, p_region->i_y );
} }
} }
} }
......
...@@ -272,8 +272,6 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ...@@ -272,8 +272,6 @@ static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
memcpy( p_spu->p_sys->p_subs_data, p_block->p_buffer, memcpy( p_spu->p_sys->p_subs_data, p_block->p_buffer,
p_block->i_buffer ); p_block->i_buffer );
p_spu->i_x = 0;
p_spu->i_y = 0;
p_spu->i_start = p_block->i_pts; p_spu->i_start = p_block->i_pts;
p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->i_stop = p_block->i_pts + p_block->i_length;
p_spu->b_ephemer = true; p_spu->b_ephemer = true;
......
...@@ -44,6 +44,8 @@ typedef struct ...@@ -44,6 +44,8 @@ typedef struct
{ {
int i_width; int i_width;
int i_height; int i_height;
int i_x;
int i_y;
} spu_properties_t; } spu_properties_t;
static int ParseControlSeq( decoder_t *, subpicture_t *, subpicture_data_t *, static int ParseControlSeq( decoder_t *, subpicture_t *, subpicture_data_t *,
...@@ -277,15 +279,15 @@ static int ParseControlSeq( decoder_t *p_dec, subpicture_t *p_spu, ...@@ -277,15 +279,15 @@ static int ParseControlSeq( decoder_t *p_dec, subpicture_t *p_spu,
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_spu->i_x = (p_sys->buffer[i_index+1]<<4)| p_spu_properties->i_x = (p_sys->buffer[i_index+1]<<4)|
((p_sys->buffer[i_index+2]>>4)&0x0f); ((p_sys->buffer[i_index+2]>>4)&0x0f);
p_spu_properties->i_width = (((p_sys->buffer[i_index+2]&0x0f)<<8)| p_spu_properties->i_width = (((p_sys->buffer[i_index+2]&0x0f)<<8)|
p_sys->buffer[i_index+3]) - p_spu->i_x + 1; p_sys->buffer[i_index+3]) - p_spu_properties->i_x + 1;
p_spu->i_y = (p_sys->buffer[i_index+4]<<4)| p_spu_properties->i_y = (p_sys->buffer[i_index+4]<<4)|
((p_sys->buffer[i_index+5]>>4)&0x0f); ((p_sys->buffer[i_index+5]>>4)&0x0f);
p_spu_properties->i_height = (((p_sys->buffer[i_index+5]&0x0f)<<8)| p_spu_properties->i_height = (((p_sys->buffer[i_index+5]&0x0f)<<8)|
p_sys->buffer[i_index+6]) - p_spu->i_y + 1; p_sys->buffer[i_index+6]) - p_spu_properties->i_y + 1;
/* Auto crop fullscreen subtitles */ /* Auto crop fullscreen subtitles */
if( p_spu_properties->i_height > 250 ) if( p_spu_properties->i_height > 250 )
...@@ -672,8 +674,8 @@ static void Render( decoder_t *p_dec, subpicture_t *p_spu, ...@@ -672,8 +674,8 @@ static void Render( decoder_t *p_dec, subpicture_t *p_spu,
return; return;
} }
p_spu->p_region->i_x = 0; p_spu->p_region->i_x = p_spu_properties->i_x;
p_spu->p_region->i_y = p_spu_data->i_y_top_offset; p_spu->p_region->i_y = p_spu_properties->i_y + p_spu_data->i_y_top_offset;
p_p = p_spu->p_region->picture.p->p_pixels; p_p = p_spu->p_region->picture.p->p_pixels;
i_pitch = p_spu->p_region->picture.p->i_pitch; i_pitch = p_spu->p_region->picture.p->i_pitch;
......
...@@ -127,8 +127,8 @@ void ParseSSAString( decoder_t *p_dec, ...@@ -127,8 +127,8 @@ void ParseSSAString( decoder_t *p_dec,
if( p_style == NULL ) if( p_style == NULL )
{ {
p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
p_spu->i_x = p_sys->i_align ? 20 : 0; p_spu->p_region->i_x = p_sys->i_align ? 20 : 0;
p_spu->i_y = 10; p_spu->p_region->i_y = 10;
} }
else else
{ {
...@@ -137,13 +137,13 @@ void ParseSSAString( decoder_t *p_dec, ...@@ -137,13 +137,13 @@ void ParseSSAString( decoder_t *p_dec,
p_spu->p_region->i_align = p_style->i_align; p_spu->p_region->i_align = p_style->i_align;
if( p_style->i_align & SUBPICTURE_ALIGN_LEFT ) if( p_style->i_align & SUBPICTURE_ALIGN_LEFT )
{ {
p_spu->i_x = (i_margin_l) ? i_margin_l : p_style->i_margin_h; p_spu->p_region->i_x = (i_margin_l) ? i_margin_l : p_style->i_margin_h;
} }
else if( p_style->i_align & SUBPICTURE_ALIGN_RIGHT ) else if( p_style->i_align & SUBPICTURE_ALIGN_RIGHT )
{ {
p_spu->i_x = (i_margin_r) ? i_margin_r : p_style->i_margin_h; p_spu->p_region->i_x = (i_margin_r) ? i_margin_r : p_style->i_margin_h;
} }
p_spu->i_y = (i_margin_v) ? i_margin_v : p_style->i_margin_v; p_spu->p_region->i_y = (i_margin_v) ? i_margin_v : p_style->i_margin_v;
} }
} }
......
...@@ -427,8 +427,8 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block ) ...@@ -427,8 +427,8 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
{ {
/* Normal text subs, easy markup */ /* Normal text subs, easy markup */
p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
p_spu->i_x = p_sys->i_align ? 20 : 0; p_spu->p_region->i_x = p_sys->i_align ? 20 : 0;
p_spu->i_y = 10; p_spu->p_region->i_y = 10;
/* Remove formatting from string */ /* Remove formatting from string */
...@@ -616,8 +616,8 @@ static char *CreateHtmlSubtitle( int *pi_align, char *psz_subtitle ) ...@@ -616,8 +616,8 @@ static char *CreateHtmlSubtitle( int *pi_align, char *psz_subtitle )
/* Check for forced alignment */ /* Check for forced alignment */
if( !strncmp( psz_subtitle, "{\\an", 4 ) && psz_subtitle[4] >= '1' && psz_subtitle[4] <= '9' && psz_subtitle[5] == '}' ) if( !strncmp( psz_subtitle, "{\\an", 4 ) && psz_subtitle[4] >= '1' && psz_subtitle[4] <= '9' && psz_subtitle[5] == '}' )
{ {
static const pi_vertical[3] = { SUBPICTURE_ALIGN_BOTTOM, 0, SUBPICTURE_ALIGN_TOP }; static const int pi_vertical[3] = { SUBPICTURE_ALIGN_BOTTOM, 0, SUBPICTURE_ALIGN_TOP };
static const pi_horizontal[3] = { SUBPICTURE_ALIGN_LEFT, 0, SUBPICTURE_ALIGN_RIGHT }; static const int pi_horizontal[3] = { SUBPICTURE_ALIGN_LEFT, 0, SUBPICTURE_ALIGN_RIGHT };
const int i_id = psz_subtitle[4] - '1'; const int i_id = psz_subtitle[4] - '1';
*pi_align = pi_vertical[i_id/3] | pi_horizontal[i_id%3]; *pi_align = pi_vertical[i_id/3] | pi_horizontal[i_id%3];
......
...@@ -473,8 +473,6 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data ) ...@@ -473,8 +473,6 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
p_spu = p_dec->pf_spu_buffer_new( p_dec ); p_spu = p_dec->pf_spu_buffer_new( p_dec );
if( !p_spu ) return NULL; if( !p_spu ) return NULL;
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_start = p_data->i_pts;
p_spu->i_stop = p_data->i_pts + p_sys->i_duration; p_spu->i_stop = p_data->i_pts + p_sys->i_duration;
p_spu->b_ephemer = true; p_spu->b_ephemer = true;
...@@ -506,7 +504,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data ) ...@@ -506,7 +504,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
p_region->fmt.i_aspect = VOUT_ASPECT_FACTOR; p_region->fmt.i_aspect = VOUT_ASPECT_FACTOR;
p_spu->p_region = p_region; p_spu->p_region = p_region;
p_region->i_x = p_region->i_y = 0; p_region->i_x = p_sys->i_x_start;
p_region->i_y = p_sys->i_y_start;
/* Build palette */ /* Build palette */
fmt.p_palette->i_entries = 4; fmt.p_palette->i_entries = 4;
......
...@@ -717,10 +717,10 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block ) ...@@ -717,10 +717,10 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
/* Normal text subs, easy markup */ /* Normal text subs, easy markup */
p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align; p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
p_spu->i_x = p_sys->i_align ? 20 : 0; p_spu->p_region->i_x = p_sys->i_align ? 20 : 0;
p_spu->i_y = 10; p_spu->p_region->i_y = 10;
p_spu->p_region->psz_text = strdup(psz_text); p_spu->p_region->psz_text = strdup(psz_text);
p_spu->i_start = p_block->i_pts; p_spu->i_start = p_block->i_pts;
p_spu->i_stop = p_block->i_pts + p_block->i_length; p_spu->i_stop = p_block->i_pts + p_block->i_length;
p_spu->b_ephemer = (p_block->i_length == 0); p_spu->b_ephemer = (p_block->i_length == 0);
......
...@@ -495,9 +495,6 @@ static subpicture_t *Subpicture( decoder_t *p_dec, video_format_t *p_fmt, ...@@ -495,9 +495,6 @@ static subpicture_t *Subpicture( decoder_t *p_dec, video_format_t *p_fmt,
p_spu->p_region->i_y = 0; p_spu->p_region->i_y = 0;
p_spu->p_region->i_align = i_align; p_spu->p_region->i_align = i_align;
/* Normal text subs, easy markup */
p_spu->i_flags = SUBPICTURE_ALIGN_BOTTOM;
p_spu->i_start = i_pts; p_spu->i_start = i_pts;
p_spu->i_stop = 0; p_spu->i_stop = 0;
p_spu->b_ephemer = true; p_spu->b_ephemer = true;
......
...@@ -337,9 +337,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -337,9 +337,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
return NULL; return NULL;
} }
p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
p_spu->i_x = 0;
p_spu->i_y = 0;
p_spu->b_absolute = true; p_spu->b_absolute = true;
p_spu->i_start = date; p_spu->i_start = date;
p_spu->i_stop = 0; p_spu->i_stop = 0;
......
...@@ -888,8 +888,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -888,8 +888,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
p_spu->b_absolute = false; p_spu->b_absolute = false;
} }
p_spu->i_x = p_sys->posx; p_region->i_x = p_sys->posx;
p_spu->i_y = p_sys->posy; p_region->i_y = p_sys->posy;
p_spu->p_region = p_region; p_spu->p_region = p_region;
......
...@@ -317,8 +317,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -317,8 +317,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
p_spu->b_absolute = false; p_spu->b_absolute = false;
} }
p_spu->i_x = p_sys->i_xoff; p_spu->p_region->i_x = p_sys->i_xoff;
p_spu->i_y = p_sys->i_yoff; p_spu->p_region->i_y = p_sys->i_yoff;
p_spu->p_region->p_style = p_sys->p_style; p_spu->p_region->p_style = p_sys->p_style;
......
...@@ -458,7 +458,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -458,7 +458,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
p_spu->i_stop = 0; p_spu->i_stop = 0;
p_spu->b_ephemer = true; p_spu->b_ephemer = true;
p_spu->i_alpha = p_sys->i_alpha; p_spu->i_alpha = p_sys->i_alpha;
p_spu->i_flags = p_sys->i_align;
p_spu->b_absolute = false; p_spu->b_absolute = false;
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
......
...@@ -451,6 +451,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) ...@@ -451,6 +451,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date )
filter_sys_t *p_sys = p_filter->p_sys; filter_sys_t *p_sys = p_filter->p_sys;
subpicture_t *p_spu = NULL; subpicture_t *p_spu = NULL;
subpicture_region_t *p_region = NULL; subpicture_region_t *p_region = NULL;
int i_x, i_y;
if( !p_sys->b_update || (p_sys->i_update <= 0) ) if( !p_sys->b_update || (p_sys->i_update <= 0) )
return NULL; return NULL;
...@@ -472,7 +473,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) ...@@ -472,7 +473,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date )
p_spu->b_absolute = true; p_spu->b_absolute = true;
else else
p_spu->b_absolute = p_sys->b_absolute; p_spu->b_absolute = p_sys->b_absolute;
p_spu->i_flags = p_sys->i_position;
/* Determine the duration of the subpicture */ /* Determine the duration of the subpicture */
if( p_sys->i_end_date > 0 ) if( p_sys->i_end_date > 0 )
...@@ -505,8 +505,11 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) ...@@ -505,8 +505,11 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date )
NULL ); NULL );
/* proper positioning of OSD menu image */ /* proper positioning of OSD menu image */
p_spu->i_x = p_filter->p_sys->p_menu->p_state->i_x; p_region->i_x = p_filter->p_sys->p_menu->p_state->i_x;
p_spu->i_y = p_filter->p_sys->p_menu->p_state->i_y; p_region->i_y = p_filter->p_sys->p_menu->p_state->i_y;
/* FIXME is it needed ?
p_region->i_align = p_sys->i_position;
*/
p_spu->p_region = p_region; p_spu->p_region = p_region;
p_spu->i_alpha = 0xFF; /* Picture is completely non transparent. */ p_spu->i_alpha = 0xFF; /* Picture is completely non transparent. */
return p_spu; return p_spu;
...@@ -535,14 +538,16 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) ...@@ -535,14 +538,16 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date )
/* proper positioning of OSD menu image */ /* proper positioning of OSD menu image */
if( p_filter->p_sys->p_menu->i_style == OSD_MENU_STYLE_CONCAT ) if( p_filter->p_sys->p_menu->i_style == OSD_MENU_STYLE_CONCAT )
{ {
p_spu->i_x = p_filter->p_sys->p_menu->p_button->i_x; i_x = p_filter->p_sys->p_menu->p_button->i_x;
p_spu->i_y = p_filter->p_sys->p_menu->p_button->i_y; i_y = p_filter->p_sys->p_menu->p_button->i_y;
} }
else else
{ {
p_spu->i_x = p_filter->p_sys->p_menu->p_state->i_x; i_x = p_filter->p_sys->p_menu->p_state->i_x;
p_spu->i_y = p_filter->p_sys->p_menu->p_state->i_y; i_y = p_filter->p_sys->p_menu->p_state->i_y;
} }
p_region->i_x = i_x;
p_region->i_y = i_y;
if( p_filter->p_sys->p_menu->i_style == OSD_MENU_STYLE_CONCAT ) if( p_filter->p_sys->p_menu->i_style == OSD_MENU_STYLE_CONCAT )
{ {
...@@ -582,8 +587,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) ...@@ -582,8 +587,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date )
} }
else else
{ {
p_new->i_x = p_region_tail->fmt.i_visible_width; p_new->i_x = i_x+p_region_tail->fmt.i_visible_width;
p_new->i_y = p_button->i_y; p_new->i_y = i_y+p_button->i_y;
p_region_tail->p_next = p_new; p_region_tail->p_next = p_new;
p_region_tail = p_new; p_region_tail = p_new;
} }
......
...@@ -1182,8 +1182,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -1182,8 +1182,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
p_spu->b_absolute = false; p_spu->b_absolute = false;
p_spu->i_x = 0;
p_spu->i_y = 0;
p_spu->i_original_picture_width = 0; /*Let vout core do the horizontal scaling */ p_spu->i_original_picture_width = 0; /*Let vout core do the horizontal scaling */
p_spu->i_original_picture_height = fmt.i_height; p_spu->i_original_picture_height = fmt.i_height;
......
...@@ -530,9 +530,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -530,9 +530,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
p_spu->b_absolute = false; p_spu->b_absolute = false;
} }
p_spu->i_x = p_sys->i_xoff;
p_spu->i_y = p_sys->i_yoff;
p_spu->p_region->p_style = p_sys->p_style; p_spu->p_region->p_style = p_sys->p_style;
if( p_feed->p_pic ) if( p_feed->p_pic )
...@@ -558,6 +555,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -558,6 +555,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
} }
else else
{ {
p_region->i_x = p_sys->i_xoff;
p_region->i_y = p_sys->i_yoff;
vout_CopyPicture( p_filter, &p_region->picture, p_pic ); vout_CopyPicture( p_filter, &p_region->picture, p_pic );
p_spu->p_region->p_next = p_region; p_spu->p_region->p_next = p_region;
} }
......
...@@ -127,44 +127,10 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel, ...@@ -127,44 +127,10 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel,
int i_flags, int i_hmargin, int i_vmargin, int i_flags, int i_hmargin, int i_vmargin,
mtime_t i_start, mtime_t i_stop ) mtime_t i_start, mtime_t i_stop )
{ {
subpicture_t *p_spu; return osd_ShowTextAbsolute( p_vout->p_spu, i_channel,
video_format_t fmt; psz_string, p_style,
i_flags, i_hmargin, i_vmargin,
if( !psz_string ) return VLC_EGENERIC; i_start, i_stop );
p_spu = spu_CreateSubpicture( p_vout->p_spu );
if( !p_spu ) return VLC_EGENERIC;
/* Create a new subpicture region */
memset( &fmt, 0, sizeof(video_format_t) );
fmt.i_chroma = VLC_FOURCC('T','E','X','T');
fmt.i_aspect = 0;
fmt.i_width = fmt.i_height = 0;
fmt.i_x_offset = fmt.i_y_offset = 0;
p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_vout), &fmt );
if( !p_spu->p_region )
{
msg_Err( p_vout, "cannot allocate SPU region" );
spu_DestroySubpicture( p_vout->p_spu, p_spu );
return VLC_EGENERIC;
}
p_spu->p_region->psz_text = strdup( psz_string );
p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK;
p_spu->p_region->p_style = p_style;
p_spu->i_start = i_start;
p_spu->i_stop = i_stop;
p_spu->b_ephemer = false;
p_spu->b_absolute = false;
p_spu->i_x = i_hmargin;
p_spu->i_y = i_vmargin;
p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK;
p_spu->i_channel = i_channel;
spu_DisplaySubpicture( p_vout->p_spu, p_spu );
return VLC_SUCCESS;
} }
......
...@@ -79,7 +79,14 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel, ...@@ -79,7 +79,14 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
if( !psz_string ) return VLC_EGENERIC; if( !psz_string ) return VLC_EGENERIC;
p_spu = spu_CreateSubpicture( p_spu_channel ); p_spu = spu_CreateSubpicture( p_spu_channel );
if( !p_spu ) return VLC_EGENERIC; if( !p_spu )
return VLC_EGENERIC;
p_spu->i_channel = i_channel;
p_spu->i_start = i_start;
p_spu->i_stop = i_stop;
p_spu->b_ephemer = true;
p_spu->b_absolute = false;
/* Create a new subpicture region */ /* Create a new subpicture region */
memset( &fmt, 0, sizeof(video_format_t) ); memset( &fmt, 0, sizeof(video_format_t) );
...@@ -97,15 +104,8 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel, ...@@ -97,15 +104,8 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
p_spu->p_region->psz_text = strdup( psz_string ); p_spu->p_region->psz_text = strdup( psz_string );
p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK; p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK;
p_spu->i_start = i_start; p_spu->p_region->i_x = i_hmargin;
p_spu->i_stop = i_stop; p_spu->p_region->i_y = i_vmargin;
p_spu->b_ephemer = true;
p_spu->b_absolute = false;
p_spu->i_x = i_hmargin;
p_spu->i_y = i_vmargin;
p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK;
p_spu->i_channel = i_channel;
spu_DisplaySubpicture( p_spu_channel, p_spu ); spu_DisplaySubpicture( p_spu_channel, p_spu );
......
...@@ -81,7 +81,16 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel, ...@@ -81,7 +81,16 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
if( !psz_string ) return VLC_EGENERIC; if( !psz_string ) return VLC_EGENERIC;
p_spu = spu_CreateSubpicture( p_vout->p_spu ); p_spu = spu_CreateSubpicture( p_vout->p_spu );
if( !p_spu ) return VLC_EGENERIC; if( !p_spu )
return VLC_EGENERIC;
p_spu->i_channel = i_channel;
p_spu->i_start = i_start;
p_spu->i_stop = i_stop;
p_spu->b_ephemer = true;
p_spu->b_absolute = false;
p_spu->b_fade = true;
/* Create a new subpicture region */ /* Create a new subpicture region */
memset( &fmt, 0, sizeof(video_format_t) ); memset( &fmt, 0, sizeof(video_format_t) );
...@@ -99,16 +108,8 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel, ...@@ -99,16 +108,8 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
p_spu->p_region->psz_text = strdup( psz_string ); p_spu->p_region->psz_text = strdup( psz_string );
p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK; p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK;
p_spu->i_start = i_start; p_spu->p_region->i_x = i_hmargin;
p_spu->i_stop = i_stop; p_spu->p_region->i_y = i_vmargin;
p_spu->b_ephemer = true;
p_spu->b_absolute = false;
p_spu->b_fade = true;
p_spu->i_x = i_hmargin;
p_spu->i_y = i_vmargin;
p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK;
p_spu->i_channel = i_channel;
spu_DisplaySubpicture( p_vout->p_spu, p_spu ); spu_DisplaySubpicture( p_vout->p_spu, p_spu );
......
...@@ -660,20 +660,10 @@ static void SpuRegionPlace( int *pi_x, int *pi_y, ...@@ -660,20 +660,10 @@ static void SpuRegionPlace( int *pi_x, int *pi_y,
const video_format_t *p_fmt, const video_format_t *p_fmt,
const subpicture_t *p_subpic, const subpicture_t *p_subpic,
const subpicture_region_t *p_region, const subpicture_region_t *p_region,
int i_subpic_x, int i_inv_scale_x, int i_inv_scale_y )
int i_inv_scale_x, int i_inv_scale_y,
int i_scale_width, int i_scale_height )
{ {
/* FIXME i_delta_x/y and i_x/y in absolute mode does not use the same int i_delta_x = p_region->i_x * i_inv_scale_x / SCALE_UNIT;
* it seems weird unless I missed something int i_delta_y = p_region->i_y * i_inv_scale_y / SCALE_UNIT;
* At this point we have:
* i_subpic_x == p_subpic->i_x * i_scale_width / SCALE_UNIT
* p_region->i_x/i_y have already been scaled by i_scale_width/i_scale_height.
* */
int i_delta_x = ( i_subpic_x + p_region->i_x ) *
i_inv_scale_x / SCALE_UNIT;
int i_delta_y = ( p_subpic->i_y + p_region->i_y ) *
i_inv_scale_y / SCALE_UNIT;
int i_x, i_y; int i_x, i_y;
if( p_region->i_align & SUBPICTURE_ALIGN_TOP ) if( p_region->i_align & SUBPICTURE_ALIGN_TOP )
...@@ -704,10 +694,8 @@ static void SpuRegionPlace( int *pi_x, int *pi_y, ...@@ -704,10 +694,8 @@ static void SpuRegionPlace( int *pi_x, int *pi_y,
if( p_subpic->b_absolute ) if( p_subpic->b_absolute )
{ {
i_x = (p_region->i_x + i_subpic_x * i_scale_width / SCALE_UNIT) * i_x = i_delta_x;
i_inv_scale_x / SCALE_UNIT; i_y = i_delta_y;
i_y = (p_region->i_y + p_subpic->i_y * i_scale_height / SCALE_UNIT) *
i_inv_scale_y / SCALE_UNIT;
} }
*pi_x = __MAX( i_x, 0 ); *pi_x = __MAX( i_x, 0 );
...@@ -718,7 +706,6 @@ static void SpuRenderRegion( spu_t *p_spu, ...@@ -718,7 +706,6 @@ static void SpuRenderRegion( spu_t *p_spu,
picture_t *p_pic_dst, picture_t *p_pic_dst,
subpicture_t *p_subpic, subpicture_region_t *p_region, subpicture_t *p_subpic, subpicture_region_t *p_region,
const int i_scale_width_orig, const int i_scale_height_orig, const int i_scale_width_orig, const int i_scale_height_orig,
const int pi_subpic_x[SCALE_SIZE],
const int pi_scale_width[SCALE_SIZE], const int pi_scale_width[SCALE_SIZE],
const int pi_scale_height[SCALE_SIZE], const int pi_scale_height[SCALE_SIZE],
const video_format_t *p_fmt ) const video_format_t *p_fmt )
...@@ -869,9 +856,8 @@ static void SpuRenderRegion( spu_t *p_spu, ...@@ -869,9 +856,8 @@ static void SpuRenderRegion( spu_t *p_spu,
/* */ /* */
SpuRegionPlace( &i_x_offset, &i_y_offset, SpuRegionPlace( &i_x_offset, &i_y_offset,
p_fmt, p_subpic, p_region, pi_subpic_x[i_scale_idx], p_fmt, p_subpic, p_region,
i_inv_scale_x, i_inv_scale_y, i_inv_scale_x, i_inv_scale_y );
pi_scale_width[i_scale_idx], pi_scale_height[i_scale_idx] );
if( p_spu->i_margin != 0 && !b_force_crop ) if( p_spu->i_margin != 0 && !b_force_crop )
{ {
...@@ -1059,7 +1045,6 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, ...@@ -1059,7 +1045,6 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
subpicture_region_t *p_region; subpicture_region_t *p_region;
int pi_scale_width[ SCALE_SIZE ]; int pi_scale_width[ SCALE_SIZE ];
int pi_scale_height[ SCALE_SIZE ]; int pi_scale_height[ SCALE_SIZE ];
int pi_subpic_x[ SCALE_SIZE ];
int k; int k;
if( !p_subpic->p_region ) if( !p_subpic->p_region )
...@@ -1171,19 +1156,15 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, ...@@ -1171,19 +1156,15 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
} }
/* Take care of the aspect ratio */ /* Take care of the aspect ratio */
for( k = 0; k < SCALE_SIZE ; k++ )
pi_subpic_x[k] = p_subpic->i_x;
if( ( p_region->fmt.i_sar_num * p_fmt->i_sar_den ) != if( ( p_region->fmt.i_sar_num * p_fmt->i_sar_den ) !=
( p_region->fmt.i_sar_den * p_fmt->i_sar_num ) ) ( p_region->fmt.i_sar_den * p_fmt->i_sar_num ) )
{ {
/* FIXME FIXME what about region->i_x/i_y ? */
for( k = 0; k < SCALE_SIZE; k++ ) for( k = 0; k < SCALE_SIZE; k++ )
{ {
pi_scale_width[k] = pi_scale_width[k] * pi_scale_width[k] = pi_scale_width[k] *
(int64_t)p_region->fmt.i_sar_num * p_fmt->i_sar_den / (int64_t)p_region->fmt.i_sar_num * p_fmt->i_sar_den /
p_region->fmt.i_sar_den / p_fmt->i_sar_num; p_region->fmt.i_sar_den / p_fmt->i_sar_num;
pi_subpic_x[k] = p_subpic->i_x * pi_scale_width[ k ] / SCALE_UNIT;
} }
} }
...@@ -1191,7 +1172,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, ...@@ -1191,7 +1172,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
for( ; p_region != NULL; p_region = p_region->p_next ) for( ; p_region != NULL; p_region = p_region->p_next )
SpuRenderRegion( p_spu, p_pic_dst, SpuRenderRegion( p_spu, p_pic_dst,
p_subpic, p_region, i_scale_width_orig, i_scale_height_orig, p_subpic, p_region, i_scale_width_orig, i_scale_height_orig,
pi_subpic_x, pi_scale_width, pi_scale_height, pi_scale_width, pi_scale_height,
p_fmt ); p_fmt );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment