# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include <vlc_vout.h>
#include <vlc_block.h>
#include <vlc_filter.h>
static int SubFilterCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
+static int sub_filter_allocation_init( filter_t *, void * );
+static void sub_filter_allocation_clear( filter_t * );
struct filter_owner_sys_t
{
spu_t *p_spu;
SCALE_TEXT,
SCALE_SIZE
};
+
/**
* Creates the subpicture unit
*
p_spu->p_blend = NULL;
p_spu->p_text = NULL;
p_spu->p_scale = NULL;
- p_spu->i_filter = 0;
p_spu->pf_control = spu_vaControlDefault;
/* Register the default subpicture channel */
p_spu->i_channel = 2;
- vlc_mutex_init( p_this, &p_spu->subpicture_lock );
+ vlc_mutex_init( &p_spu->subpicture_lock );
vlc_object_attach( p_spu, p_this );
+ p_spu->p_chain = filter_chain_New( p_spu, "sub filter", false,
+ sub_filter_allocation_init,
+ sub_filter_allocation_clear,
+ p_spu );
return p_spu;
}
int spu_ParseChain( spu_t *p_spu )
{
- char *psz_parser;
- vlc_value_t val;
- var_Get( p_spu, "sub-filter", &val );
- psz_parser = val.psz_string;
-
- while( psz_parser && *psz_parser )
+ char *psz_parser = var_GetString( p_spu, "sub-filter" );
+ if( filter_chain_AppendFromString( p_spu->p_chain, psz_parser ) < 0 )
{
- config_chain_t *p_cfg;
- char *psz_name;
-
- 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_name, VLC_TRUE );
- if( p_spu->pp_filter[p_spu->i_filter]->p_module )
- {
- filter_owner_sys_t *p_sys = malloc( sizeof(filter_owner_sys_t) );
- if( p_sys )
- {
- p_spu->pp_filter[p_spu->i_filter]->p_owner = p_sys;
- spu_Control( p_spu, SPU_CHANNEL_REGISTER, &p_sys->i_channel );
- p_sys->p_spu = p_spu;
- p_spu->i_filter++;
- }
- }
- else
- {
- msg_Dbg( p_spu, "no sub filter found" );
- config_ChainDestroy( p_spu->pp_filter[p_spu->i_filter]->p_cfg );
- vlc_object_detach( p_spu->pp_filter[p_spu->i_filter] );
- vlc_object_release( p_spu->pp_filter[p_spu->i_filter] );
- }
-
- if( p_spu->i_filter >= 10 )
- {
- msg_Dbg( p_spu, "can't add anymore filters" );
- }
-
- free( psz_name );
+ free( psz_parser );
+ return VLC_EGENERIC;
}
- free( val.psz_string );
+ free( psz_parser );
return VLC_SUCCESS;
}
static void spu_DeleteChain( spu_t *p_spu )
{
- if( p_spu->i_filter )
- while( p_spu->i_filter )
- {
- p_spu->i_filter--;
- module_Unneed( p_spu->pp_filter[p_spu->i_filter],
- p_spu->pp_filter[p_spu->i_filter]->p_module );
- free( p_spu->pp_filter[p_spu->i_filter]->p_owner );
- config_ChainDestroy( p_spu->pp_filter[p_spu->i_filter]->p_cfg );
- vlc_object_detach( p_spu->pp_filter[p_spu->i_filter] );
- vlc_object_release( p_spu->pp_filter[p_spu->i_filter] );
- }
+ filter_chain_Delete( p_spu->p_chain );
}
/**
* \param p_this the object in which to destroy the subpicture unit
* \param b_attach to select attach or detach
*/
-void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, vlc_bool_t b_attach )
+void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
{
vlc_object_t *p_input;
if( !p_region ) return NULL;
memset( p_region, 0, sizeof(subpicture_region_t) );
- p_region->i_alpha = 0xff
+ p_region->i_alpha = 0xff;
p_region->p_next = NULL;
p_region->p_cache = NULL;
p_region->fmt = *p_fmt;
/* Copy subpicture information, set some default values */
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->b_absolute = true;
+ p_subpic->b_pausable = false;
+ p_subpic->b_fade = false;
p_subpic->i_alpha = 0xFF;
p_subpic->p_region = NULL;
p_subpic->pf_render = NULL;
{
p_spu->p_text->p_module =
module_Need( p_spu->p_text, "text renderer",
- psz_modulename, VLC_TRUE );
+ psz_modulename, true );
}
if( !p_spu->p_text->p_module )
{
while( p_region )
{
video_format_t orig_fmt = p_region->fmt;
- vlc_bool_t b_rerender_text = VLC_FALSE;
+ bool b_rerender_text = false;
int i_fade_alpha = 255;
int i_x_offset;
int i_y_offset;
var_Set( p_spu->p_text, "spu-elapsed", val );
var_Create( p_spu->p_text, "text-rerender", VLC_VAR_BOOL );
- var_SetBool( p_spu->p_text, "text-rerender", VLC_FALSE );
+ var_SetBool( p_spu->p_text, "text-rerender", false );
var_Create( p_spu->p_text, "scale", VLC_VAR_INTEGER );
var_SetInteger( p_spu->p_text, "scale",
i_y_offset = __MAX( i_y_offset, 0 );
if( ( p_spu->i_margin != 0 ) &&
- ( p_spu->b_force_crop == VLC_FALSE ) )
+ ( p_spu->b_force_crop == false ) )
{
int i_diff = 0;
int i_low = (i_y_offset - p_spu->i_margin) * i_inv_scale_y / 1000;
* 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,
- vlc_bool_t b_paused )
+ bool b_paused )
{
int i_index, i_channel;
subpicture_t *p_subpic = NULL;
mtime_t ephemer_date;
/* Run subpicture filters */
- for( i_index = 0; i_index < p_spu->i_filter; i_index++ )
- {
- subpicture_t *p_subpic_filter;
- p_subpic_filter = p_spu->pp_filter[i_index]->
- pf_sub_filter( p_spu->pp_filter[i_index], display_date );
- if( p_subpic_filter )
- {
- spu_DisplaySubpicture( p_spu, p_subpic_filter );
- }
- }
+ filter_chain_SubFilter( p_spu->p_chain, display_date );
/* We get an easily parsable chained list of subpictures which
* ends with NULL since p_subpic was initialized to NULL. */
{
vlc_value_t val;
- p_spu->b_force_palette = VLC_FALSE;
- p_spu->b_force_crop = VLC_FALSE;
+ p_spu->b_force_palette = false;
+ p_spu->b_force_crop = false;
if( var_Get( p_object, "highlight", &val ) || !val.b_bool ) return;
- p_spu->b_force_crop = VLC_TRUE;
+ p_spu->b_force_crop = true;
var_Get( p_object, "x-start", &val );
p_spu->i_crop_x = val.i_int;
var_Get( p_object, "y-start", &val );
if( var_Get( p_object, "menu-palette", &val ) == VLC_SUCCESS )
{
memcpy( p_spu->palette, val.p_address, 16 );
- p_spu->b_force_palette = VLC_TRUE;
+ p_spu->b_force_palette = true;
}
msg_Dbg( p_object, "crop: %i,%i,%i,%i, palette forced: %i",
subpicture_t *p_subpic = (subpicture_t *)malloc(sizeof(subpicture_t));
if( !p_subpic ) return NULL;
memset( p_subpic, 0, sizeof(subpicture_t) );
- p_subpic->b_absolute = VLC_TRUE;
+ p_subpic->b_absolute = true;
p_subpic->pf_create_region = __spu_CreateRegion;
p_subpic->pf_make_region = __spu_MakeRegion;
vlc_mutex_unlock( &p_spu->subpicture_lock );
return VLC_SUCCESS;
}
+
+static int sub_filter_allocation_init( filter_t *p_filter, void *p_data )
+{
+ spu_t *p_spu = (spu_t *)p_data;
+
+ p_filter->pf_sub_buffer_new = sub_new_buffer;
+ p_filter->pf_sub_buffer_del = sub_del_buffer;
+
+ filter_owner_sys_t *p_sys = malloc( sizeof(filter_owner_sys_t) );
+ if( !p_sys ) return VLC_EGENERIC;
+
+ p_filter->p_owner = p_sys;
+ spu_Control( p_spu, SPU_CHANNEL_REGISTER, &p_sys->i_channel );
+ p_sys->p_spu = p_spu;
+
+ return VLC_SUCCESS;
+}
+
+static void sub_filter_allocation_clear( filter_t *p_filter )
+{
+ free( p_filter->p_owner );
+}