Commit 23cc599d authored by Laurent Aimar's avatar Laurent Aimar

Patch by Bernie Purcell :

"This is part of a former submission stripped out for easier
 assimilation. It modifies vout_subpictures to use the existing alignment
 field on each region, rather than the alignment on the subpicture plane
 itself. Modifications are made to everywhere that depended on the former
 behaviour, to make it use the new alignment location instead."
parent 877cfa02
......@@ -306,6 +306,8 @@ struct subpicture_t
#define SUBPICTURE_ALIGN_RIGHT 0x2
#define SUBPICTURE_ALIGN_TOP 0x4
#define SUBPICTURE_ALIGN_BOTTOM 0x8
#define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
/*****************************************************************************
* Prototypes
......
......@@ -1492,6 +1492,7 @@ static subpicture_t *render( decoder_t *p_dec )
}
p_spu_region->i_x = p_regiondef->i_x;
p_spu_region->i_y = p_regiondef->i_y;
p_spu_region->i_align = p_sys->i_spu_position;
*pp_spu_region = p_spu_region;
pp_spu_region = &p_spu_region->p_next;
......@@ -1546,6 +1547,7 @@ static subpicture_t *render( decoder_t *p_dec )
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_y = p_regiondef->i_y + p_object_def->i_y;
p_spu_region->i_align = p_sys->i_spu_position;
*pp_spu_region = p_spu_region;
pp_spu_region = &p_spu_region->p_next;
}
......
......@@ -448,7 +448,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
p_dec->fmt_in.i_codec != VLC_FOURCC('u','s','f',' ') )
{
/* Normal text subs, easy markup */
p_spu->i_flags = 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->i_y = 10;
......@@ -574,7 +574,7 @@ static void ParseUSFString( decoder_t *p_dec, char *psz_subtitle, subpicture_t *
if( p_style == NULL )
{
p_spu->i_flags = 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->i_y = 10;
}
......@@ -582,7 +582,7 @@ static void ParseUSFString( decoder_t *p_dec, char *psz_subtitle, subpicture_t *
{
msg_Dbg( p_dec, "style is: %s", p_style->psz_stylename);
p_spu->p_region->p_style = &p_style->font_style;
p_spu->i_flags = p_style->i_align;
p_spu->p_region->i_align = p_style->i_align;
}
}
......@@ -678,7 +678,7 @@ static void ParseSSAString( decoder_t *p_dec, char *psz_subtitle, subpicture_t *
p_spu->p_region->psz_text = psz_new_subtitle;
if( p_style == NULL )
{
p_spu->i_flags = 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->i_y = 10;
}
......@@ -686,7 +686,7 @@ static void ParseSSAString( decoder_t *p_dec, char *psz_subtitle, subpicture_t *
{
msg_Dbg( p_dec, "style is: %s", p_style->psz_stylename);
p_spu->p_region->p_style = &p_style->font_style;
p_spu->i_flags = p_style->i_align;
p_spu->p_region->i_align = p_style->i_align;
if( p_style->i_align & SUBPICTURE_ALIGN_LEFT )
{
p_spu->i_x = (i_margin_l) ? i_margin_l : p_style->i_margin_h;
......@@ -1147,7 +1147,7 @@ static void ParseSSAHeader( decoder_t *p_dec )
//p_style->font_style.f_angle = f_angle;
p_style->i_align = 0;
if( i_align == 0x1 || i_align == 0x4 || i_align == 0x1 ) p_style->i_align |= SUBPICTURE_ALIGN_LEFT;
if( i_align == 0x1 || i_align == 0x4 || i_align == 0x7 ) p_style->i_align |= SUBPICTURE_ALIGN_LEFT;
if( i_align == 0x3 || i_align == 0x6 || i_align == 0x9 ) p_style->i_align |= SUBPICTURE_ALIGN_RIGHT;
if( i_align == 0x7 || i_align == 0x8 || i_align == 0x9 ) p_style->i_align |= SUBPICTURE_ALIGN_TOP;
if( i_align == 0x1 || i_align == 0x2 || i_align == 0x3 ) p_style->i_align |= SUBPICTURE_ALIGN_BOTTOM;
......
......@@ -711,7 +711,7 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
}
/* Normal text subs, easy markup */
p_spu->i_flags = 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->i_y = 10;
......
......@@ -882,14 +882,14 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
/* where to locate the logo: */
if( p_sys->posx < 0 || p_sys->posy < 0 )
{ /* set to one of the 9 relative locations */
p_spu->i_flags = p_sys->pos;
p_spu->p_region->i_align = p_sys->pos;
p_spu->i_x = 0;
p_spu->i_y = 0;
p_spu->b_absolute = VLC_FALSE;
}
else
{ /* set to an absolute xy, referenced to upper left corner */
p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
p_spu->i_x = p_sys->posx;
p_spu->i_y = p_sys->posy;
p_spu->b_absolute = VLC_TRUE;
......
......@@ -296,14 +296,14 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
/* where to locate the string: */
if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )
{ /* set to one of the 9 relative locations */
p_spu->i_flags = p_sys->i_pos;
p_spu->p_region->i_align = p_sys->i_pos;
p_spu->i_x = 0;
p_spu->i_y = 0;
p_spu->b_absolute = VLC_FALSE;
}
else
{ /* set to an absolute xy, referenced to upper left corner */
p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
p_spu->i_x = p_sys->i_xoff;
p_spu->i_y = p_sys->i_yoff;
p_spu->b_absolute = VLC_TRUE;
......
......@@ -710,6 +710,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
+ ( i_row * p_sys->i_borderh ) / p_sys->i_rows
+ ( row_inner_height - fmt_out.i_height ) / 2;
}
p_region->i_align = p_sys->i_align;
if( p_region_prev == NULL )
{
......
......@@ -482,14 +482,14 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
/* where to locate the string: */
if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )
{ /* set to one of the 9 relative locations */
p_spu->i_flags = p_sys->i_pos;
p_spu->p_region->i_align = p_sys->i_pos;
p_spu->i_x = 0;
p_spu->i_y = 0;
p_spu->b_absolute = VLC_FALSE;
}
else
{ /* set to an absolute xy, referenced to upper left corner */
p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
p_spu->i_x = p_sys->i_xoff;
p_spu->i_y = p_sys->i_yoff;
p_spu->b_absolute = VLC_TRUE;
......
......@@ -146,6 +146,7 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel,
}
p_spu->p_region->psz_text = strdup( psz_string );
p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK;
p_spu->i_start = i_start;
p_spu->i_stop = i_stop;
p_spu->b_ephemer = VLC_FALSE;
......@@ -153,7 +154,7 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel,
p_spu->i_x = i_hmargin;
p_spu->i_y = i_vmargin;
p_spu->i_flags = i_flags;
p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK;
p_spu->i_channel = i_channel;
spu_DisplaySubpicture( p_vout->p_spu, p_spu );
......
......@@ -92,6 +92,7 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
}
p_spu->p_region->psz_text = strdup( psz_string );
p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK;
p_spu->i_start = i_start;
p_spu->i_stop = i_stop;
p_spu->b_ephemer = VLC_TRUE;
......@@ -99,7 +100,7 @@ int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
p_spu->i_x = i_hmargin;
p_spu->i_y = i_vmargin;
p_spu->i_flags = i_flags;
p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK;
p_spu->i_channel = i_channel;
spu_DisplaySubpicture( p_spu_channel, p_spu );
......
......@@ -93,6 +93,7 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
}
p_spu->p_region->psz_text = strdup( psz_string );
p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK;
p_spu->i_start = i_start;
p_spu->i_stop = i_stop;
p_spu->b_ephemer = VLC_TRUE;
......@@ -101,7 +102,7 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
p_spu->i_x = i_hmargin;
p_spu->i_y = i_vmargin;
p_spu->i_flags = i_flags;
p_spu->i_flags = i_flags & ~SUBPICTURE_ALIGN_MASK;
p_spu->i_channel = i_channel;
spu_DisplaySubpicture( p_vout->p_spu, p_spu );
......
......@@ -661,8 +661,6 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
{
if( p_spu->p_text && p_spu->p_text->p_module )
{
p_region->i_align = p_subpic->i_flags;
if( p_spu->p_text->pf_render_html && p_region->psz_html )
{
p_spu->p_text->pf_render_html( p_spu->p_text,
......@@ -728,6 +726,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
p_region->p_cache->fmt = p_spu->p_scale->fmt_out.video;
p_region->p_cache->i_x = p_region->i_x * i_scale_width / 1000;
p_region->p_cache->i_y = p_region->i_y * i_scale_height / 1000;
p_region->p_cache->i_align = p_region->i_align;
p_pic = p_spu->p_scale->pf_video_filter(
p_spu->p_scale, &p_region->p_cache->picture );
......@@ -745,22 +744,22 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
p_region = p_region->p_cache;
}
if( p_subpic->i_flags & SUBPICTURE_ALIGN_BOTTOM )
if( p_region->i_align & SUBPICTURE_ALIGN_BOTTOM )
{
i_y_offset = p_fmt->i_height - p_region->fmt.i_height -
p_subpic->i_y;
p_subpic->i_y - p_region->i_y;
}
else if ( !(p_subpic->i_flags & SUBPICTURE_ALIGN_TOP) )
else if ( !(p_region->i_align & SUBPICTURE_ALIGN_TOP) )
{
i_y_offset = p_fmt->i_height / 2 - p_region->fmt.i_height / 2;
}
if( p_subpic->i_flags & SUBPICTURE_ALIGN_RIGHT )
if( p_region->i_align & SUBPICTURE_ALIGN_RIGHT )
{
i_x_offset = p_fmt->i_width - p_region->fmt.i_width -
i_subpic_x;
i_subpic_x - p_region->i_x;
}
else if ( !(p_subpic->i_flags & SUBPICTURE_ALIGN_LEFT) )
else if ( !(p_region->i_align & SUBPICTURE_ALIGN_LEFT) )
{
i_x_offset = p_fmt->i_width / 2 - p_region->fmt.i_width / 2;
}
......
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