/*****************************************************************************
* logo.c : logo video plugin for vlc
*****************************************************************************
- * Copyright (C) 2003-2006 the VideoLAN team
+ * Copyright (C) 2003-2006 VLC authors and VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
* Simon Latapie <garf@videolan.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_SUBPIC )
set_help(LOGO_HELP)
- set_capability( "sub filter", 0 )
+ set_capability( "sub source", 0 )
set_callbacks( OpenSub, Close )
- set_description( N_("Logo sub filter") )
+ set_description( N_("Logo sub source") )
set_shortname( N_("Logo overlay") )
add_shortcut( "logo" )
/* default to 1000 ms per image, continuously cycle through them */
add_integer( CFG_PREFIX "delay", 1000, DELAY_TEXT, DELAY_LONGTEXT, true )
add_integer( CFG_PREFIX "repeat", -1, REPEAT_TEXT, REPEAT_LONGTEXT, true )
- add_integer_with_range( CFG_PREFIX "opacity", 255, 0, 255, NULL,
+ add_integer_with_range( CFG_PREFIX "opacity", 255, 0, 255,
OPACITY_TEXT, OPACITY_LONGTEXT, false )
add_integer( CFG_PREFIX "position", -1, POS_TEXT, POS_LONGTEXT, false )
change_integer_list( pi_pos_values, ppsz_pos_descriptions )
static logo_t *LogoListCurrent( logo_list_t *p_list );
/**
- * Open the sub filter
+ * Open the sub source
*/
static int OpenSub( vlc_object_t *p_this )
{
msg_Warn( p_this, "no logo file specified" );
p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, "logo-opacity");
- p_list->i_alpha = __MAX( __MIN( p_list->i_alpha, 255 ), 0 );
+ p_list->i_alpha = VLC_CLIP( p_list->i_alpha, 0, 255 );
p_list->i_delay = var_CreateGetIntegerCommand( p_filter, "logo-delay" );
p_list->i_repeat = var_CreateGetIntegerCommand( p_filter, "logo-repeat" );
/* Misc init */
if( b_sub )
{
- p_filter->pf_sub_filter = FilterSub;
+ p_filter->pf_sub_source = FilterSub;
}
else
{
}
/**
- * Sub filter
+ * Sub source
*/
static subpicture_t *FilterSub( filter_t *p_filter, mtime_t date )
{
if( p_list->i_repeat != -1 && p_list->i_counter == 0 )
{
p_list->i_repeat--;
- if( p_list->i_repeat == 0 )
+ if( p_list->i_repeat < 0 )
goto exit;
}
if( !p_pic || !p_logo->i_alpha ||
}
}
+ if( p_sys->i_pos_x < 0 || p_sys->i_pos_y < 0 )
+ {
+ msg_Warn( p_filter,
+ "logo(%ix%i) doesn't fit into video(%ix%i)",
+ p_fmt->i_visible_width, p_fmt->i_visible_height,
+ i_dst_w,i_dst_h );
+ p_sys->i_pos_x = (p_sys->i_pos_x > 0) ? p_sys->i_pos_x : 0;
+ p_sys->i_pos_y = (p_sys->i_pos_y > 0) ? p_sys->i_pos_y : 0;
+ }
+
/* */
const int i_alpha = p_logo->i_alpha != -1 ? p_logo->i_alpha : p_list->i_alpha;
if( filter_ConfigureBlend( p_sys->p_blend, i_dst_w, i_dst_h, p_fmt ) ||
{
int i_dx, i_dy;
vlc_mouse_GetMotion( &i_dx, &i_dy, p_old, p_new );
- p_sys->i_pos_x = __MIN( __MAX( p_sys->i_pos_x + i_dx, 0 ),
+ p_sys->i_pos_x = VLC_CLIP( p_sys->i_pos_x + i_dx, 0,
p_filter->fmt_in.video.i_width - i_logo_w );
- p_sys->i_pos_y = __MIN( __MAX( p_sys->i_pos_y + i_dy, 0 ),
+ p_sys->i_pos_y = VLC_CLIP( p_sys->i_pos_y + i_dy, 0,
p_filter->fmt_in.video.i_height - i_logo_h );
/* object under mouse has moved */
}
else if ( !strcmp( psz_var, "logo-opacity" ) )
{
- p_list->i_alpha = __MAX( __MIN( newval.i_int, 255 ), 0 );
+ p_list->i_alpha = VLC_CLIP( newval.i_int, 0, 255 );
}
else if ( !strcmp( psz_var, "logo-repeat" ) )
{
if( !p_image )
return NULL;
- char *psz_url = make_URI( psz_filename, NULL );
+ char *psz_url = vlc_path2uri( psz_filename, NULL );
picture_t *p_pic = image_ReadUrl( p_image, psz_url, &fmt_in, &fmt_out );
free( psz_url );
image_HandlerDelete( p_image );