Commit 496b159e authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Fix subtitle alignment if we don't have styles. fixes #619

I chose to re-add the align paramter to the subpicture region struct, since adding a style struct for every single subpicture for just an alignment seemed to be overkill to me. 
parent 2ec45e6f
......@@ -207,6 +207,7 @@ struct subpicture_region_t
int i_x; /**< position of region */
int i_y; /**< position of region */
int i_align; /**< alignment within a region */
char *psz_text; /**< text string comprising this region */
text_style_t *p_style; /* a description of the text style formatting */
......
......@@ -406,13 +406,15 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
i_glyph_tmax = __MAX( i_glyph_tmax, p_glyph->top );
}
if( p_region->p_style && p_line->i_width < i_width )
if( p_line->i_width < i_width )
{
if( p_region->p_style->i_text_align == SUBPICTURE_ALIGN_RIGHT )
if( ( p_region->p_style && p_region->p_style->i_text_align == SUBPICTURE_ALIGN_RIGHT ) ||
( !p_region->p_style && (p_region->i_align & 0x3) == SUBPICTURE_ALIGN_RIGHT ) )
{
i_align_offset = i_width - p_line->i_width;
}
else if( p_region->p_style->i_text_align != SUBPICTURE_ALIGN_LEFT )
else if( ( p_region->p_style && p_region->p_style->i_text_align != SUBPICTURE_ALIGN_LEFT ) ||
( !p_region->p_style && (p_region->i_align & 0x3) != SUBPICTURE_ALIGN_LEFT ) )
{
i_align_offset = ( i_width - p_line->i_width ) / 2;
}
......@@ -483,13 +485,15 @@ static void DrawBlack( line_desc_t *p_line, int i_width, subpicture_region_t *p_
i_glyph_tmax = __MAX( i_glyph_tmax, p_glyph->top );
}
if( p_region->p_style && p_line->i_width < i_width )
if( p_line->i_width < i_width )
{
if( p_region->p_style->i_text_align == SUBPICTURE_ALIGN_RIGHT )
if( ( p_region->p_style && p_region->p_style->i_text_align == SUBPICTURE_ALIGN_RIGHT ) ||
( !p_region->p_style && (p_region->i_align & 0x3) == SUBPICTURE_ALIGN_RIGHT ) )
{
i_align_offset = i_width - p_line->i_width;
}
else if( p_region->p_style->i_text_align != SUBPICTURE_ALIGN_LEFT )
else if( ( p_region->p_style && p_region->p_style->i_text_align != SUBPICTURE_ALIGN_LEFT ) ||
( !p_region->p_style && (p_region->i_align & 0x3) != SUBPICTURE_ALIGN_LEFT ) )
{
i_align_offset = ( i_width - p_line->i_width ) / 2;
}
......@@ -633,13 +637,15 @@ static int RenderYUVA( filter_t *p_filter, subpicture_region_t *p_region,
i_glyph_tmax = __MAX( i_glyph_tmax, p_glyph->top );
}
if( p_region->p_style && p_line->i_width < i_width )
if( p_line->i_width < i_width )
{
if( p_region->p_style->i_text_align == SUBPICTURE_ALIGN_RIGHT )
if( ( p_region->p_style && p_region->p_style->i_text_align == SUBPICTURE_ALIGN_RIGHT ) ||
( !p_region->p_style && (p_region->i_align & 0x3) == SUBPICTURE_ALIGN_RIGHT ) )
{
i_align_offset = i_width - p_line->i_width;
}
else if( p_region->p_style->i_text_align != SUBPICTURE_ALIGN_LEFT )
else if( ( p_region->p_style && p_region->p_style->i_text_align != SUBPICTURE_ALIGN_LEFT ) ||
( !p_region->p_style && (p_region->i_align & 0x3) != SUBPICTURE_ALIGN_LEFT ) )
{
i_align_offset = ( i_width - p_line->i_width ) / 2;
}
......
......@@ -497,7 +497,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
}
/* Load the text rendering module */
if( !p_spu->p_text && p_region )
if( !p_spu->p_text && p_region && p_region->fmt.i_chroma == VLC_FOURCC('T','E','X','T') )
{
char *psz_modulename = NULL;
......@@ -527,7 +527,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
}
if( psz_modulename ) free( psz_modulename );
}
else if( p_region )
if( p_spu->p_text )
{
if( p_subpic->i_original_picture_height > 0 &&
p_subpic->i_original_picture_width > 0 )
......@@ -622,9 +622,8 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
{
if( p_spu->p_text && p_spu->p_text->p_module &&
p_spu->p_text->pf_render_text )
{/*
if( p_region->p_style )
p_region->p_style->i_text_align = p_subpic->i_flags & 0x3; */
{
p_region->i_align = p_subpic->i_flags;
p_spu->p_text->pf_render_text( p_spu->p_text,
p_region, p_region );
}
......
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