Commit f6832bdc authored by Antoine Cellerier's avatar Antoine Cellerier

* mosaic alignment (works like --marq-position) and callback

parent bff1fb1c
......@@ -383,6 +383,8 @@ static void Run( intf_thread_t *p_intf )
var_AddCallback( p_intf, "mosaic-xoffset", Other, NULL );
var_Create( p_intf, "mosaic-yoffset", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "mosaic-yoffset", Other, NULL );
var_Create( p_intf, "mosaic-align", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "mosaic-align", Other, NULL );
var_Create( p_intf, "mosaic-vborder", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "mosaic-vborder", Other, NULL );
var_Create( p_intf, "mosaic-hborder", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
......@@ -726,6 +728,7 @@ static void Run( intf_thread_t *p_intf )
msg_rc(_("| mosaic-width # . . . . . . . . . . . . . . width\n"));
msg_rc(_("| mosaic-xoffset # . . . .top left corner position\n"));
msg_rc(_("| mosaic-yoffset # . . . .top left corner position\n"));
msg_rc(_("| mosaic-align 0..2,4..6,8..10. . .mosaic alignment\n"));
msg_rc(_("| mosaic-vborder # . . . . . . . . vertical border\n"));
msg_rc(_("| mosaic-hborder # . . . . . . . horizontal border\n"));
msg_rc(_("| mosaic-position {0=auto,1=fixed} . . . .position\n"));
......@@ -1100,7 +1103,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "mosaic-alpha" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-alpha", val );
......@@ -1108,7 +1111,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "mosaic-height" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-height", val );
......@@ -1116,7 +1119,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "mosaic-width" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-width", val );
......@@ -1124,7 +1127,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "mosaic-xoffset" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-xoffset", val );
......@@ -1132,15 +1135,23 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "mosaic-yoffset" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-yoffset", val );
}
}
else if( !strcmp( psz_cmd, "mosaic-align" ) )
{
if( strlen( newval.psz_string ) > 0 )
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-align", val );
}
}
else if( !strcmp( psz_cmd, "mosaic-vborder" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-vborder", val );
......@@ -1148,7 +1159,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "mosaic-hborder" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-hborder", val );
......@@ -1156,7 +1167,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "mosaic-position" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-position", val );
......@@ -1164,7 +1175,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "mosaic-rows" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-rows", val );
......@@ -1172,7 +1183,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "mosaic-cols" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-cols", val );
......@@ -1180,7 +1191,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
}
else if( !strcmp( psz_cmd, "mosaic-keep-aspect-ratio" ) )
{
if( strlen( newval.psz_string) > 0)
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "mosaic-keep-aspect-ratio", val );
......
......@@ -70,6 +70,7 @@ struct filter_sys_t
vlc_bool_t b_keep; /* do we keep the original picture format ? */
int i_width, i_height; /* mosaic height and width */
int i_cols, i_rows; /* mosaic rows and cols */
int i_align; /* mosaic alignment in background video */
int i_xoffset, i_yoffset; /* top left corner offset */
int i_vborder, i_hborder; /* border width/height between miniatures */
int i_alpha; /* subfilter alpha blending */
......@@ -92,6 +93,7 @@ struct filter_sys_t
#define YOFFSET_TEXT N_("Top left corner y coordinate")
#define VBORDER_TEXT N_("Vertical border width in pixels")
#define HBORDER_TEXT N_("Horizontal border width in pixels")
#define ALIGN_TEXT N_("Mosaic alignment")
#define POS_TEXT N_("Positioning method")
#define POS_LONGTEXT N_("Positioning method. auto : automatically choose " \
......@@ -113,6 +115,11 @@ static int pi_pos_values[] = { 0, 1 };
static char * ppsz_pos_descriptions[] =
{ N_("auto"), N_("fixed") };
static int pi_align_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
static char *ppsz_align_descriptions[] =
{ N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
vlc_module_begin();
set_description( N_("Mosaic video sub filter") );
......@@ -123,6 +130,8 @@ vlc_module_begin();
add_integer( "mosaic-alpha", 255, NULL, ALPHA_TEXT, ALPHA_LONGTEXT, VLC_FALSE );
add_integer( "mosaic-height", 100, NULL, HEIGHT_TEXT, HEIGHT_TEXT, VLC_FALSE );
add_integer( "mosaic-width", 100, NULL, WIDTH_TEXT, WIDTH_TEXT, VLC_FALSE );
add_integer( "mosaic-align", 5, NULL, ALIGN_TEXT, ALIGN_TEXT, VLC_TRUE);
change_integer_list( pi_align_values, ppsz_align_descriptions, 0 );
add_integer( "mosaic-xoffset", 0, NULL, XOFFSET_TEXT, XOFFSET_TEXT, VLC_TRUE );
add_integer( "mosaic-yoffset", 0, NULL, YOFFSET_TEXT, YOFFSET_TEXT, VLC_TRUE );
add_integer( "mosaic-vborder", 0, NULL, VBORDER_TEXT, VBORDER_TEXT, VLC_TRUE );
......@@ -178,6 +187,15 @@ static int CreateFilter( vlc_object_t *p_this )
GET_VAR( height, 0, INT_MAX );
GET_VAR( xoffset, 0, INT_MAX );
GET_VAR( yoffset, 0, INT_MAX );
p_sys->i_align = __MIN( 10, __MAX( 0, var_CreateGetInteger( p_filter, "mosaic-align" ) ) );
if( p_sys->i_align == 3 || p_sys->i_align == 7 )
p_sys->i_align = 5;
var_Destroy( p_filter, "mosaic-align" );
var_Create( p_libvlc, "mosaic-align", VLC_VAR_INTEGER );
var_SetInteger( p_libvlc, "mosaic-align", p_sys->i_align );
var_AddCallback( p_libvlc, "mosaic-align", MosaicCallback, p_sys );
GET_VAR( vborder, 0, INT_MAX );
GET_VAR( hborder, 0, INT_MAX );
GET_VAR( rows, 1, INT_MAX );
......@@ -262,6 +280,7 @@ static void DestroyFilter( vlc_object_t *p_this )
var_Destroy( p_libvlc, "mosaic-alpha" );
var_Destroy( p_libvlc, "mosaic-height" );
var_Destroy( p_libvlc, "mosaic-align" );
var_Destroy( p_libvlc, "mosaic-width" );
var_Destroy( p_libvlc, "mosaic-xoffset" );
var_Destroy( p_libvlc, "mosaic-yoffset" );
......@@ -337,6 +356,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
p_spu->i_stop = 0;
p_spu->b_ephemer = VLC_TRUE;
p_spu->i_alpha = p_sys->i_alpha;
p_spu->i_flags = p_sys->i_align;
p_spu->b_absolute = VLC_FALSE;
vlc_mutex_lock( &p_sys->lock );
......@@ -611,6 +632,21 @@ static int MosaicCallback( vlc_object_t *p_this, char const *psz_var,
p_sys->i_yoffset = __MAX( newval.i_int, 0 );
vlc_mutex_unlock( &p_sys->lock );
}
else if( !strcmp( psz_var, "mosaic-align" ) )
{
int i_old = 0, i_new = 0;
vlc_mutex_lock( &p_sys->lock );
newval.i_int = __MIN( __MAX( newval.i_int, 0 ), 10 );
if( newval.i_int == 3 || newval.i_int == 7 )
newval.i_int = 5;
while( pi_align_values[i_old] != p_sys->i_align ) i_old++;
while( pi_align_values[i_new] != newval.i_int ) i_new++;
msg_Dbg( p_this, "Changing alignment from %d (%s) to %d (%s)",
p_sys->i_align, ppsz_align_descriptions[i_old],
newval.i_int, ppsz_align_descriptions[i_new] );
p_sys->i_align = newval.i_int;
vlc_mutex_unlock( &p_sys->lock );
}
else if( !strcmp( psz_var, "mosaic-vborder" ) )
{
vlc_mutex_lock( &p_sys->lock );
......
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