Commit 794eece8 authored by Laurent Aimar's avatar Laurent Aimar

Fixed subtitle blend module loading.

The blend module will be loaded only if needed and reloaded on chroma change.
(As a side effect it should allow displaying TEXT even when no blending module
exist)
parent e7d9e560
...@@ -547,10 +547,10 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, ...@@ -547,10 +547,10 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
p_spu->p_blend->fmt_out.video.i_y_offset = 0; p_spu->p_blend->fmt_out.video.i_y_offset = 0;
p_spu->p_blend->fmt_out.video.i_aspect = p_fmt->i_aspect; p_spu->p_blend->fmt_out.video.i_aspect = p_fmt->i_aspect;
p_spu->p_blend->fmt_out.video.i_chroma = p_fmt->i_chroma; p_spu->p_blend->fmt_out.video.i_chroma = p_fmt->i_chroma;
p_spu->p_blend->fmt_in.video.i_chroma = p_region->fmt.i_chroma;
p_spu->p_blend->p_module = /* The blend module will be loaded when needed with the real input format */
module_Need( p_spu->p_blend, "video blending", 0, 0 ); memset( &p_spu->p_blend->fmt_in, 0, sizeof(p_spu->p_blend->fmt_in) );
p_spu->p_blend->p_module = NULL;
} }
/* Load the text rendering module; it is possible there is a /* Load the text rendering module; it is possible there is a
...@@ -721,7 +721,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, ...@@ -721,7 +721,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
module_Need( p_spu->p_scale, "video filter2", 0, 0 ); module_Need( p_spu->p_scale, "video filter2", 0, 0 );
} }
while( p_region && p_spu->p_blend && p_spu->p_blend->pf_video_blend ) while( p_region )
{ {
video_format_t orig_fmt = p_region->fmt; video_format_t orig_fmt = p_region->fmt;
vlc_bool_t b_rerender_text = VLC_FALSE; vlc_bool_t b_rerender_text = VLC_FALSE;
...@@ -934,7 +934,34 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, ...@@ -934,7 +934,34 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
i_y_offset -= ( p_spu->i_margin * i_inv_scale_y / 1000 + i_diff ); i_y_offset -= ( p_spu->i_margin * i_inv_scale_y / 1000 + i_diff );
} }
if( p_subpic->b_fade )
{
mtime_t i_fade_start = ( p_subpic->i_stop +
p_subpic->i_start ) / 2;
mtime_t i_now = mdate();
if( i_now >= i_fade_start && p_subpic->i_stop > i_fade_start )
{
i_fade_alpha = 255 * ( p_subpic->i_stop - i_now ) /
( p_subpic->i_stop - i_fade_start );
}
}
if( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') )
{
if( p_spu->p_blend->fmt_in.video.i_chroma != p_region->fmt.i_chroma )
{
/* The chroma is not the same, we need to reload the blend module
* XXX to match the old behaviour just test !p_spu->p_blend->fmt_in.video.i_chroma */
if( p_spu->p_blend->p_module )
module_Unneed( p_spu->p_blend, p_spu->p_blend->p_module );
p_spu->p_blend->fmt_in.video = p_region->fmt;
p_spu->p_blend->p_module = module_Need( p_spu->p_blend, "video blending", 0, 0 );
}
else
{
p_spu->p_blend->fmt_in.video = p_region->fmt; p_spu->p_blend->fmt_in.video = p_region->fmt;
}
/* Force cropping if requested */ /* Force cropping if requested */
if( p_spu->b_force_crop ) if( p_spu->b_force_crop )
...@@ -978,23 +1005,10 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, ...@@ -978,23 +1005,10 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
} }
} }
if( p_subpic->b_fade )
{
mtime_t i_fade_start = ( p_subpic->i_stop +
p_subpic->i_start ) / 2;
mtime_t i_now = mdate();
if( i_now >= i_fade_start && p_subpic->i_stop > i_fade_start )
{
i_fade_alpha = 255 * ( p_subpic->i_stop - i_now ) /
( p_subpic->i_stop - i_fade_start );
}
}
i_x_offset = __MAX( i_x_offset, 0 ); i_x_offset = __MAX( i_x_offset, 0 );
i_y_offset = __MAX( i_y_offset, 0 ); i_y_offset = __MAX( i_y_offset, 0 );
if( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') )
{
/* Update the output picture size */ /* Update the output picture size */
p_spu->p_blend->fmt_out.video.i_width = p_spu->p_blend->fmt_out.video.i_width =
p_spu->p_blend->fmt_out.video.i_visible_width = p_spu->p_blend->fmt_out.video.i_visible_width =
...@@ -1003,10 +1017,19 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, ...@@ -1003,10 +1017,19 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
p_spu->p_blend->fmt_out.video.i_visible_height = p_spu->p_blend->fmt_out.video.i_visible_height =
p_fmt->i_height; p_fmt->i_height;
if( p_spu->p_blend->p_module )
{
p_spu->p_blend->pf_video_blend( p_spu->p_blend, p_pic_dst, p_spu->p_blend->pf_video_blend( p_spu->p_blend, p_pic_dst,
p_pic_src, &p_region->picture, i_x_offset, i_y_offset, p_pic_src, &p_region->picture, i_x_offset, i_y_offset,
i_fade_alpha * p_subpic->i_alpha / 255 ); i_fade_alpha * p_subpic->i_alpha / 255 );
} }
else
{
msg_Err( p_spu, "blending %4.4s to %4.4s failed",
(char *)&p_spu->p_blend->fmt_out.video.i_chroma,
(char *)&p_spu->p_blend->fmt_out.video.i_chroma );
}
}
if( b_rerender_text ) if( b_rerender_text )
{ {
......
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