*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
*/
int spu_Init( spu_t *p_spu )
{
- char *psz_filter, *psz_filter_orig;
+ char *psz_parser;
vlc_value_t val;
/* If the user requested a sub margin, we force the position. */
var_Create( p_spu, "sub-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_spu, "sub-filter", &val );
- psz_filter = psz_filter_orig = val.psz_string;
- while( psz_filter && *psz_filter )
+
+ psz_parser = val.psz_string;
+
+ while( psz_parser && *psz_parser )
{
- char *psz_parser = strchr( psz_filter, ':' );
+ config_chain_t *p_cfg; /* Do we ever need to free this ? */
+ char *psz_name;
- if( psz_parser ) *psz_parser++ = 0;
+ psz_parser = config_ChainCreate( &psz_name, &p_cfg, psz_parser );
+
+ msg_Dbg( p_spu, "adding sub-filter: %s", psz_name );
p_spu->pp_filter[p_spu->i_filter] =
vlc_object_create( p_spu, VLC_OBJECT_FILTER );
vlc_object_attach( p_spu->pp_filter[p_spu->i_filter], p_spu );
p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_new = sub_new_buffer;
p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_del = sub_del_buffer;
+ p_spu->pp_filter[p_spu->i_filter]->p_cfg = p_cfg;;
p_spu->pp_filter[p_spu->i_filter]->p_module =
module_Need( p_spu->pp_filter[p_spu->i_filter],
- "sub filter", psz_filter, 0 );
+ "sub filter", psz_name, 0 );
if( p_spu->pp_filter[p_spu->i_filter]->p_module )
{
filter_owner_sys_t *p_sys = malloc( sizeof(filter_owner_sys_t) );
msg_Dbg( p_spu, "can't add anymore filters" );
}
- psz_filter = psz_parser;
+ free( psz_name );
}
- if( psz_filter_orig ) free( psz_filter_orig );
+ if( val.psz_string ) free( val.psz_string );
return VLC_EGENERIC;
}
p_region->p_cache = 0;
p_region->fmt = *p_fmt;
p_region->psz_text = 0;
- p_region->i_text_color = 0xFFFFFF;
+ p_region->p_style = NULL;
if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
p_fmt->p_palette = p_region->fmt.p_palette =
malloc( sizeof(video_palette_t) );
else p_fmt->p_palette = p_region->fmt.p_palette = NULL;
- p_region->picture.p_data_orig = 0;
+ p_region->picture.p_data_orig = NULL;
if( p_fmt->i_chroma == VLC_FOURCC('T','E','X','T') ) return p_region;
p_region->p_cache = 0;
p_region->fmt = *p_fmt;
p_region->psz_text = 0;
- p_region->i_text_color = 0xFFFFFF;
+ p_region->p_style = NULL;
if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
p_fmt->p_palette = p_region->fmt.p_palette =
if( p_region->picture.pf_release )
p_region->picture.pf_release( &p_region->picture );
if( p_region->fmt.p_palette ) free( p_region->fmt.p_palette );
- if( p_region->psz_text ) free( p_region->psz_text );
if( p_region->p_cache ) __spu_DestroyRegion( p_this, p_region->p_cache );
free( p_region );
}
memset( p_subpic, 0, sizeof(subpicture_t) );
p_subpic->i_status = RESERVED_SUBPICTURE;
p_subpic->b_absolute = VLC_TRUE;
+ p_subpic->b_pausable = VLC_FALSE;
p_subpic->b_fade = VLC_FALSE;
p_subpic->i_alpha = 0xFF;
p_subpic->p_region = 0;
p_subpic->pf_create_region = __spu_CreateRegion;
p_subpic->pf_make_region = __spu_MakeRegion;
p_subpic->pf_destroy_region = __spu_DestroyRegion;
-
+
return p_subpic;
}
}
/* 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;
+
p_spu->p_text = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
vlc_object_attach( p_spu->p_text, p_spu );
p_spu->p_text->fmt_out.video.i_width =
p_spu->p_text->fmt_out.video.i_visible_width =
- p_fmt->i_width;
+ p_fmt->i_width;
p_spu->p_text->fmt_out.video.i_height =
p_spu->p_text->fmt_out.video.i_visible_height =
- p_fmt->i_height;
+ p_fmt->i_height;
p_spu->p_text->pf_sub_buffer_new = spu_new_buffer;
p_spu->p_text->pf_sub_buffer_del = spu_del_buffer;
- p_spu->p_text->p_module =
- module_Need( p_spu->p_text, "text renderer", 0, 0 );
+
+ psz_modulename = var_CreateGetString( p_spu, "text-renderer" );
+ if( psz_modulename && *psz_modulename )
+ {
+ p_spu->p_text->p_module =
+ module_Need( p_spu->p_text, "text renderer", psz_modulename, VLC_TRUE );
+ }
+ if( !p_spu->p_text->p_module )
+ {
+ p_spu->p_text->p_module =
+ module_Need( p_spu->p_text, "text renderer", 0, 0 );
+ }
+ if( psz_modulename ) free( psz_modulename );
}
- else if( p_region )
+ if( p_spu->p_text )
{
- p_spu->p_text->fmt_out.video.i_width =
- p_spu->p_text->fmt_out.video.i_visible_width =
+ if( p_subpic->i_original_picture_height > 0 &&
+ p_subpic->i_original_picture_width > 0 )
+ {
+ p_spu->p_text->fmt_out.video.i_width =
+ p_spu->p_text->fmt_out.video.i_visible_width =
+ p_subpic->i_original_picture_width;
+ p_spu->p_text->fmt_out.video.i_height =
+ p_spu->p_text->fmt_out.video.i_visible_height =
+ p_subpic->i_original_picture_height;
+ }
+ else
+ {
+ p_spu->p_text->fmt_out.video.i_width =
+ p_spu->p_text->fmt_out.video.i_visible_width =
p_fmt->i_width;
- p_spu->p_text->fmt_out.video.i_height =
- p_spu->p_text->fmt_out.video.i_visible_height =
+ p_spu->p_text->fmt_out.video.i_height =
+ p_spu->p_text->fmt_out.video.i_visible_height =
p_fmt->i_height;
+ }
}
i_scale_width = i_scale_width_orig;
i_scale_height = i_scale_height_orig;
- if( p_subpic->i_original_picture_width &&
- p_subpic->i_original_picture_height )
+ if( p_subpic->i_original_picture_height > 0 &&
+ p_subpic->i_original_picture_width > 0 )
{
i_scale_width = i_scale_width * p_fmt->i_width /
p_subpic->i_original_picture_width;
i_scale_height = i_scale_height * p_fmt->i_height /
p_subpic->i_original_picture_height;
}
+ else if( p_subpic->i_original_picture_height > 0 )
+ {
+ i_scale_height = i_scale_height * p_fmt->i_height /
+ p_subpic->i_original_picture_height;
+ i_scale_width = i_scale_height * i_scale_height / p_fmt->i_height;
+ }
/* Set default subpicture aspect ratio */
if( p_region && p_region->fmt.i_aspect &&
if( p_spu->p_text && p_spu->p_text->p_module &&
p_spu->p_text->pf_render_text )
{
- p_region->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 );
}
i_y_offset = p_region->i_y +
p_subpic->i_y * i_scale_height / 1000;
- if( p_spu->i_margin >= 0 )
- {
- if( p_subpic->i_height + (unsigned int)p_spu->i_margin <=
- p_fmt->i_height )
- {
- i_y_offset = p_fmt->i_height -
- p_spu->i_margin - p_subpic->i_height;
- }
- }
+ }
+
+ if( p_spu->i_margin != 0 && p_spu->b_force_crop == VLC_FALSE )
+ {
+ int i_diff = 0;
+ int i_low = i_y_offset - p_spu->i_margin;
+ int i_high = i_y_offset + p_region->fmt.i_height - p_spu->i_margin;
+
+ /* crop extra margin to keep within bounds */
+ if( i_low < 0 ) i_diff = i_low;
+ if( i_high > (int)p_fmt->i_height ) i_diff = i_high - p_fmt->i_height;
+ i_y_offset -= ( p_spu->i_margin + i_diff );
}
p_spu->p_blend->fmt_in.video = p_region->fmt;
* to be removed if a newer one is available), which makes it a lot
* more difficult to guess if a subpicture has to be rendered or not.
*****************************************************************************/
-subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date )
+subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date,
+ vlc_bool_t b_paused )
{
int i_index, i_channel;
subpicture_t *p_subpic = NULL;
if( display_date > p_spu->p_subpicture[i_index].i_stop &&
( !p_spu->p_subpicture[i_index].b_ephemer ||
p_spu->p_subpicture[i_index].i_stop >
- p_spu->p_subpicture[i_index].i_start ) )
+ p_spu->p_subpicture[i_index].i_start ) &&
+ !( p_spu->p_subpicture[i_index].b_pausable &&
+ b_paused ) )
{
/* Too late, destroy the subpic */
spu_DestroySubpicture( p_spu, &p_spu->p_subpicture[i_index] );
case SPU_CHANNEL_REGISTER:
pi = (int *)va_arg( args, int * );
if( pi ) *pi = p_spu->i_channel++;
- msg_Dbg( p_spu, "Registering subpicture channel, ID: %i",
- p_spu->i_channel - 1 );
break;
case SPU_CHANNEL_CLEAR: