Commit 8c75d5ed authored by Laurent Aimar's avatar Laurent Aimar

More clean up on subtitle.

parent fa1117e6
......@@ -595,9 +595,9 @@ static void SpuRenderRegion( spu_t *p_spu,
int i_fade_alpha = 255;
int i_x_offset;
int i_y_offset;
int i_scale_idx = SCALE_DEFAULT;
int i_inv_scale_x = 1000;
int i_inv_scale_y = 1000;
int i_scale_idx;
int i_inv_scale_x;
int i_inv_scale_y;
if( p_region->fmt.i_chroma == VLC_FOURCC('T','E','X','T') )
{
......@@ -626,12 +626,10 @@ static void SpuRenderRegion( spu_t *p_spu,
*/
var_Create( p_spu->p_text, "spu-duration", VLC_VAR_TIME );
val.i_time = p_subpic->i_stop - p_subpic->i_start;
var_Set( p_spu->p_text, "spu-duration", val );
var_SetTime( p_spu->p_text, "spu-duration", p_subpic->i_stop - p_subpic->i_start );
var_Create( p_spu->p_text, "spu-elapsed", VLC_VAR_TIME );
val.i_time = mdate() - p_subpic->i_start;
var_Set( p_spu->p_text, "spu-elapsed", val );
var_SetTime( p_spu->p_text, "spu-elapsed", mdate() - p_subpic->i_start );
var_Create( p_spu->p_text, "text-rerender", VLC_VAR_BOOL );
var_SetBool( p_spu->p_text, "text-rerender", false );
......@@ -660,12 +658,23 @@ static void SpuRenderRegion( spu_t *p_spu,
p_region->i_align |= SUBPICTURE_RENDERED;
}
/* From now on, we can only process non text data */
if( p_region->fmt.i_chroma == VLC_FOURCC('T','E','X','T') )
goto exit;
if( p_region->i_align & SUBPICTURE_RENDERED )
{
/* We are using a region which come from rendered text */
i_scale_idx = SCALE_TEXT;
i_inv_scale_x = i_scale_width_orig;
i_inv_scale_y = i_scale_height_orig;
}
else
{
i_scale_idx = SCALE_DEFAULT;
i_inv_scale_x = 1000;
i_inv_scale_y = 1000;
}
i_x_offset = (p_region->i_x + pi_subpic_x[ i_scale_idx ]) * i_inv_scale_x / 1000;
i_y_offset = (p_region->i_y + p_subpic->i_y) * i_inv_scale_y / 1000;
......@@ -674,13 +683,15 @@ static void SpuRenderRegion( spu_t *p_spu,
if( p_spu->b_force_palette &&
( VLC_FOURCC('Y','U','V','P') == p_region->fmt.i_chroma ) )
{
memcpy( p_region->fmt.p_palette->palette,
p_spu->palette, 16 );
/* It look so wrong I won't comment
* p_palette->palette is [256][4] with a int i_entries
* p_spu->palette is [4][4]
* */
memcpy( p_region->fmt.p_palette->palette, p_spu->palette, 16 );
}
/* Scale SPU if necessary */
if( p_region->p_cache &&
( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
if( p_region->p_cache )
{
if( pi_scale_width[ i_scale_idx ] * p_region->fmt.i_width / 1000 !=
p_region->p_cache->fmt.i_width ||
......@@ -697,8 +708,7 @@ static void SpuRenderRegion( spu_t *p_spu,
( pi_scale_height[ i_scale_idx ] != 1000 ) ) &&
( ( pi_scale_width[ i_scale_idx ] > 0 ) ||
( pi_scale_height[ i_scale_idx ] > 0 ) ) &&
p_spu->p_scale && !p_region->p_cache &&
( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
p_spu->p_scale && !p_region->p_cache )
{
picture_t *p_pic;
......@@ -745,8 +755,7 @@ static void SpuRenderRegion( spu_t *p_spu,
( pi_scale_height[ i_scale_idx ] != 1000 ) ) &&
( ( pi_scale_width[ i_scale_idx ] > 0 ) ||
( pi_scale_height[ i_scale_idx ] > 0 ) ) &&
p_spu->p_scale && p_region->p_cache &&
( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
p_spu->p_scale && p_region->p_cache )
{
p_region = p_region->p_cache;
}
......@@ -814,8 +823,6 @@ static void SpuRenderRegion( spu_t *p_spu,
}
}
if( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') )
{
/* */
SpuRenderUpdateBlend( p_spu, &p_region->fmt );
......@@ -884,8 +891,8 @@ static void SpuRenderRegion( spu_t *p_spu,
(char *)&p_spu->p_blend->fmt_out.video.i_chroma,
(char *)&p_spu->p_blend->fmt_out.video.i_chroma );
}
}
exit:
if( b_rerender_text )
{
/* Some forms of subtitles need to be re-rendered more than
......@@ -923,9 +930,9 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
}
if( i_scale_width_orig <= 0 )
i_scale_width_orig = 1;
i_scale_width_orig = 1000;
if( i_scale_height_orig <= 0 )
i_scale_height_orig = 1;
i_scale_height_orig = 1000;
i_source_video_width = p_fmt->i_width * 1000 / i_scale_width_orig;
i_source_video_height = p_fmt->i_height * 1000 / i_scale_height_orig;
......
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