Commit e1381cf7 authored by Mark Moriarty's avatar Mark Moriarty

freetype and rc extensions. i_font_color and i_font_opacity added to...

freetype and rc extensions.  i_font_color and i_font_opacity added to subpictures, allowing per-object control (defaulting to freetype).  marq and time updated to allow font color and opacity control.  rc update to allow OTF control of all marq and time options.
parent ff146815
......@@ -3,7 +3,7 @@
* This header is required by all modules which have to handle pictures. It
* includes all common video types and constants.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* Copyright (C) 1999 - 2005 VideoLAN
* $Id$
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
......@@ -208,7 +208,7 @@ struct subpicture_region_t
int i_x; /**< position of region */
int i_y; /**< position of region */
int i_font_color, i_font_opacity; /**< controls for text subpictures */
subpicture_region_t *p_next; /**< next region in the list */
subpicture_region_t *p_cache; /**< modified version of this region */
/**@}*/
......
/*****************************************************************************
* rc.c : remote control stdin/stdout module for vlc
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* Copyright (C) 2004 - 2005 VideoLAN
* $Id$
*
* Author: Peter Surda <shurdeek@panorama.sth.ac.at>
......@@ -358,15 +358,37 @@ static void Run( intf_thread_t *p_intf )
var_Create( p_intf, "goto", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "goto", Playlist, NULL );
/* marquee on the fly items */
var_Create( p_intf, "marq-marquee", VLC_VAR_VOID | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "marq-marquee", Other, NULL );
var_Create( p_intf, "marq-x", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "marq-x", Other, NULL );
var_Create( p_intf, "marq-y", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "marq-y", Other, NULL );
var_Create( p_intf, "marq-position", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "marq-position", Other, NULL );
var_Create( p_intf, "marq-color", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "marq-color", Other, NULL );
var_Create( p_intf, "marq-opacity", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "marq-opacity", Other, NULL );
var_Create( p_intf, "marq-timeout", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "marq-timeout", Other, NULL );
/* time on the fly items */
var_Create( p_intf, "time-format", VLC_VAR_VOID | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "time-format", Other, NULL );
var_Create( p_intf, "time-x", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "time-x", Other, NULL );
var_Create( p_intf, "time-y", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "time-y", Other, NULL );
var_Create( p_intf, "time-position", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "time-position", Other, NULL );
var_Create( p_intf, "time-color", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "time-color", Other, NULL );
var_Create( p_intf, "time-opacity", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "time-opacity", Other, NULL );
var_Create( p_intf, "pause", VLC_VAR_VOID | VLC_VAR_ISCOMMAND );
var_AddCallback( p_intf, "pause", Input, NULL );
var_Create( p_intf, "seek", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
......@@ -660,8 +682,18 @@ static void Run( intf_thread_t *p_intf )
msg_rc(_("| marq-marquee STRING . . overlay STRING in video\n"));
msg_rc(_("| marq-x X . . . . . offset of marquee, from left\n"));
msg_rc(_("| marq-y Y . . . . . . offset of marquee, from top\n"));
msg_rc(_("| marq-position #. . . .relative position control\n"));
msg_rc(_("| marq-color # . . . . font color of marquee, RGB\n"));
msg_rc(_("| marq-opacity # . . . . . . . .opacity of marquee\n"));
msg_rc(_("| marq-timeout T. . . . timeout of marquee, in ms\n"));
msg_rc( "| \n");
msg_rc(_("| time-format STRING . . . overlay STRING in video\n"));
msg_rc(_("| time-x X . . . . .offset of timestamp, from left\n"));
msg_rc(_("| time-y Y . . . . . offset of timestamp, from top\n"));
msg_rc(_("| time-position #. . . .relative position control\n"));
msg_rc(_("| time-color # . . . font color of timestamp, RGB\n"));
msg_rc(_("| time-opacity # . . . . . . .opacity of timestamp\n"));
msg_rc( "| \n");
}
msg_rc(_("| help . . . . . . . . . . . . . this help message\n"));
msg_rc(_("| logout . . . . . exit (if in socket connection)\n"));
......@@ -964,6 +996,30 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
var_Set( p_inp->p_libvlc, "marq-y", val );
}
}
else if( !strcmp( psz_cmd, "marq-position" ) )
{
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "marq-position", val );
}
}
else if( !strcmp( psz_cmd, "marq-color" ) )
{
if( strlen( newval.psz_string ) > 0)
{
val.i_int = strtol( newval.psz_string, NULL, 0 );
var_Set( p_inp->p_libvlc, "marq-color", val );
}
}
else if( !strcmp( psz_cmd, "marq-opacity" ) )
{
if( strlen( newval.psz_string ) > 0)
{
val.i_int = strtol( newval.psz_string, NULL, 0 );
var_Set( p_inp->p_libvlc, "marq-opacity", val );
}
}
else if( !strcmp( psz_cmd, "marq-timeout" ) )
{
if( strlen( newval.psz_string ) > 0)
......@@ -972,6 +1028,59 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
var_Set( p_inp, "marq-timeout", val );
}
}
else if( !strcmp( psz_cmd, "time-format" ) )
{
if( strlen( newval.psz_string ) > 0 )
{
val.psz_string = newval.psz_string;
var_Set( p_inp->p_libvlc, "time-format", val );
}
else
{
val.psz_string = "";
var_Set( p_inp->p_libvlc, "time-format", val);
}
}
else if( !strcmp( psz_cmd, "time-x" ) )
{
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "time-x", val );
}
}
else if( !strcmp( psz_cmd, "time-y" ) )
{
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "time-y", val );
}
}
else if( !strcmp( psz_cmd, "time-position" ) )
{
if( strlen( newval.psz_string ) > 0)
{
val.i_int = atoi( newval.psz_string );
var_Set( p_inp->p_libvlc, "time-position", val );
}
}
else if( !strcmp( psz_cmd, "time-color" ) )
{
if( strlen( newval.psz_string ) > 0)
{
val.i_int = strtol( newval.psz_string, NULL, 0 );
var_Set( p_inp->p_libvlc, "time-color", val );
}
}
else if( !strcmp( psz_cmd, "time-opacity" ) )
{
if( strlen( newval.psz_string ) > 0)
{
val.i_int = strtol( newval.psz_string, NULL, 0 );
var_Set( p_inp->p_libvlc, "time-opacity", val );
}
}
/*
* sanity check
......
......@@ -70,12 +70,9 @@ typedef struct line_desc_t line_desc_t;
static int Create ( vlc_object_t * );
static void Destroy( vlc_object_t * );
static subpicture_t *RenderText( filter_t *, block_t * );
/* The RenderText call maps to pf_render_string, defined in vlc_filter.h */
static subpicture_t *RenderText( filter_t *, block_t *, int, int );
static line_desc_t *NewLine( byte_t * );
static int FreetypeCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval,
void *p_data );
/*****************************************************************************
* Module descriptor
......@@ -115,9 +112,11 @@ vlc_module_begin();
VLC_FALSE );
add_integer( "freetype-fontsize", 0, NULL, FONTSIZE_TEXT,
FONTSIZE_LONGTEXT, VLC_TRUE );
/* opacity valid on 0..255, with default 255 = fully opaque */
add_integer_with_range( "freetype-opacity", 255, 0, 255, NULL,
OPACITY_TEXT, OPACITY_LONGTEXT, VLC_FALSE );
add_integer( "freetype-color", 0xFFFFFF, NULL, COLOR_TEXT, COLOR_LONGTEXT, VLC_TRUE );
/* hook to the color values list, with default 0x00ffffff = white */
add_integer( "freetype-color", 0x00FFFFFF, NULL, COLOR_TEXT, COLOR_LONGTEXT, VLC_TRUE );
change_integer_list( pi_color_values, ppsz_color_descriptions, 0 );
add_integer( "freetype-rel-fontsize", 16, NULL, FONTSIZER_TEXT,
......@@ -169,15 +168,11 @@ struct filter_sys_t
FT_Library p_library; /* handle to library */
FT_Face p_face; /* handle to face object */
vlc_bool_t i_use_kerning;
uint8_t i_opacity;
uint8_t i_defaultopacity; /* freetype-opacity */
uint8_t i_tempopacity; /* font-opacity dynamic changes */
int i_tempcolor; /* font-color dynamic changes */
int i_defaultcolor; /* freetype-color */
int i_red, i_green, i_blue; /* color components */
uint8_t i_font_opacity; /* freetype-opacity */
int i_font_color; /* freetype-color */
int i_red, i_blue, i_green; /* function vars to render */
uint8_t i_opacity; /* function var to render */
uint8_t pi_gamma[256];
vlc_bool_t b_need_color; /* flag for font color changes */
vlc_bool_t b_need_opacity; /* flag for font opacity changes */
};
/*****************************************************************************
......@@ -193,7 +188,6 @@ static int Create( vlc_object_t *p_this )
int i, i_error;
int i_fontsize = 0;
vlc_value_t val;
vlc_object_t *p_input;
/* Allocate structure */
p_sys = malloc( sizeof( filter_sys_t ) );
......@@ -205,32 +199,6 @@ static int Create( vlc_object_t *p_this )
p_sys->p_face = 0;
p_sys->p_library = 0;
/* Hook used for callback variables */
p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( !p_input )
{
return VLC_ENOOBJ;
}
/* accessible variables, to allow individual text subfilters to set their own values */
p_sys->i_tempcolor = var_CreateGetInteger( p_input->p_libvlc , "font-color" );
p_sys->i_tempopacity = var_CreateGetInteger( p_input->p_libvlc , "font-opacity" );
var_AddCallback( p_input->p_libvlc, "font-color", FreetypeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "font-opacity", FreetypeCallback, p_sys );
vlc_object_release( p_input ); /* free the hook */
/* default to opaque letters, white (all colors set to 255): */
p_sys->i_opacity = 255;
p_sys->i_defaultopacity = 255;
p_sys->i_red = 255;
p_sys->i_green = 255;
p_sys->i_blue = 255;
p_sys->i_defaultcolor = 0x00FFFFFF;
/* miscellaneous initialization */
p_sys->b_need_color = VLC_FALSE; /* inversion of true/false */
p_sys->b_need_opacity = VLC_FALSE;
for( i = 0; i < 256; i++ )
{
p_sys->pi_gamma[i] = (uint8_t)( pow( (double)i * 255.0f, 0.5f ) );
......@@ -244,16 +212,12 @@ static int Create( vlc_object_t *p_this )
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_filter, "freetype-opacity", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Get( p_filter, "freetype-opacity", &val );
p_sys->i_opacity = __MAX( __MIN( val.i_int, 255 ), 0 );
p_sys->i_defaultopacity = p_sys->i_opacity;
p_sys->i_font_opacity = __MAX( __MIN( val.i_int, 255 ), 0 );
var_Create( p_filter, "freetype-color", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_filter, "freetype-color", &val );
if ( ( val.i_int > -1 ) && ( val.i_int < 0x00FFFFFF ) ) /* valid range */
{
p_sys->i_defaultcolor = val.i_int;
p_sys->i_blue = val.i_int & 0x000000FF;
p_sys->i_green = (val.i_int & 0x0000FF00)/256;
p_sys->i_red = (val.i_int & 0x00FF0000)/(256*256);
p_sys->i_font_color = val.i_int;
}
else msg_Warn(p_filter, "Invalid freetype color specified, using white [0xFFFFFF]");
......@@ -349,20 +313,9 @@ static int Create( vlc_object_t *p_this )
*****************************************************************************/
static void Destroy( vlc_object_t *p_this )
{
vlc_object_t *p_input;
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( !p_input )
{
return;
}
var_Destroy( p_input->p_libvlc , "font-color" );
var_Destroy( p_input->p_libvlc , "font-opacity" );
vlc_object_release( p_input );
FT_Done_Face( p_sys->p_face );
FT_Done_FreeType( p_sys->p_library );
free( p_sys );
......@@ -468,8 +421,7 @@ static void Render( filter_t *p_filter, subpicture_t *p_spu,
{
for( x = 0; x < p_glyph->bitmap.width; x++, i_bitmap_offset++ )
{
p_y[i_offset + x] = i_y*pi_gamma[p_glyph->bitmap.buffer[i_bitmap_offset]] *
opacity / ( 256 * 256 );
p_y[i_offset + x] = i_y*opacity*pi_gamma[p_glyph->bitmap.buffer[i_bitmap_offset]]/(256*256);
p_u[i_offset + x] = i_u;
p_v[i_offset + x] = i_v;
}
......@@ -487,7 +439,8 @@ static void Render( filter_t *p_filter, subpicture_t *p_spu,
* needed glyphs into memory. It is used as pf_add_string callback in
* the vout method by this module
*/
static subpicture_t *RenderText( filter_t *p_filter, block_t *p_block )
static subpicture_t *RenderText( filter_t *p_filter, block_t *p_block,
int font_color, int font_opacity )
{
filter_sys_t *p_sys = p_filter->p_sys;
subpicture_t *p_subpic = 0;
......@@ -733,29 +686,26 @@ static subpicture_t *RenderText( filter_t *p_filter, block_t *p_block )
#undef face
#undef glyph
/* check to see whether to use the default color/opacity, or another one: */
if( !p_sys->b_need_color )
if( font_color < 0 )
{
p_sys->i_blue = p_sys->i_tempcolor & 0x000000FF;
p_sys->i_green = (p_sys->i_tempcolor & 0x0000FF00)/256;
p_sys->i_red = (p_sys->i_tempcolor & 0x00FF0000)/(256*256);
p_sys->i_blue = p_sys->i_font_color & 0x000000FF;
p_sys->i_green = (p_sys->i_font_color & 0x0000FF00)/256;
p_sys->i_red = (p_sys->i_font_color & 0x00FF0000)/(256*256);
}
else
{
p_sys->i_blue = p_sys->i_defaultcolor & 0x000000FF;
p_sys->i_green = (p_sys->i_defaultcolor & 0x0000FF00)/256;
p_sys->i_red = (p_sys->i_defaultcolor & 0x00FF0000)/(256*256);
p_sys->b_need_color = VLC_FALSE;
p_sys->i_blue = font_color & 0x000000FF;
p_sys->i_green = (font_color & 0x0000FF00)/256;
p_sys->i_red = (font_color & 0x00FF0000)/(256*256);
}
if( !p_sys->b_need_opacity )
if( font_opacity < 0 )
{
p_sys->i_opacity = p_sys->i_tempopacity;
p_sys->i_opacity = p_sys->i_font_opacity;
}
else
{
p_sys->i_opacity = p_sys->i_defaultopacity;
p_sys->b_need_opacity = VLC_FALSE;
p_sys->i_opacity = (uint8_t) ( font_opacity & 0x000000FF );
}
Render( p_filter, p_subpic, p_string, p_sys->i_opacity,
......@@ -837,24 +787,3 @@ static line_desc_t *NewLine( byte_t *psz_string )
return p_line;
}
/**********************************************************************
* Callback to update params on the fly
**********************************************************************/
static int FreetypeCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
filter_sys_t *p_sys = (filter_sys_t *) p_data;
if ( !strncmp( psz_var, "font-color", 8 ) )
{
p_sys->i_tempcolor = newval.i_int;
p_sys->b_need_color = VLC_TRUE;
}
else if ( !strncmp( psz_var, "font-opacity", 8 ) )
{
p_sys->i_tempopacity = newval.i_int;
p_sys->b_need_opacity = VLC_TRUE;
}
return VLC_SUCCESS;
}
/*****************************************************************************
* marq.c : marquee display video plugin for vlc
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
* Copyright (C) 2003-2005 VideoLAN
* $Id: time.c 8751 2004-09-20 21:51:41Z gbazin $
*
* Authors: Mark Moriarty
......@@ -45,6 +45,15 @@ static subpicture_t *Filter( filter_t *, mtime_t );
static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval,
void *p_data );
static int pi_color_values[] = { 0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0,
0x00FFFFFF, 0x00800000, 0x00FF0000, 0x00FF00FF, 0x00FFFF00,
0x00808000, 0x00008000, 0x00008080, 0x0000FF00, 0x00800080,
0x00000080, 0x000000FF, 0x0000FFFF};
static char *ppsz_color_descriptions[] = { N_("Default"), N_("Black"),
N_("Gray"), N_("Silver"), N_("White"), N_("Maroon"), N_("Red"),
N_("Fuchsia"), N_("Yellow"), N_("Olive"), N_("Green"),
N_("Teal"), N_("Lime"), N_("Purple"), N_("Navy"), N_("Blue"),
N_("Aqua") };
/*****************************************************************************
* filter_sys_t: marquee filter descriptor
......@@ -57,6 +66,8 @@ struct filter_sys_t
char *psz_marquee; /* marquee string */
int i_font_color, i_font_opacity; /* font color control */
time_t last_time;
vlc_bool_t b_absolute; /* position control, relative vs. absolute */
......@@ -73,6 +84,14 @@ struct filter_sys_t
#define TIMEOUT_LONGTEXT N_("Defines the time the marquee must remain " \
"displayed, in milliseconds. Default value is " \
"0 (remain forever).")
#define OPACITY_TEXT N_("Opacity, -1..255")
#define OPACITY_LONGTEXT N_("The opacity (inverse of transparency) of overlay text. " \
"-1 = use freetype-opacity, 0 = transparent, 255 = totally opaque. " )
#define COLOR_TEXT N_("Text Default Color")
#define COLOR_LONGTEXT N_("The color of overlay text. 1 byte for each color, hexadecimal." \
"-1 = use freetype-color, #000000 = all colors off, " \
"0xFF0000 = just Red, 0xFFFFFF = all color on [White]" )
#define POS_TEXT N_("Marquee position")
#define POS_LONGTEXT N_( \
"You can enforce the marquee position on the video " \
......@@ -81,7 +100,7 @@ struct filter_sys_t
static int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
static char *ppsz_pos_descriptions[] =
{ N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
{ N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
/*****************************************************************************
......@@ -95,12 +114,17 @@ vlc_module_begin();
set_subcategory( SUBCAT_VIDEO_SUBPIC );
add_string( "marq-marquee", "Marquee", NULL, MSG_TEXT, MSG_LONGTEXT, VLC_FALSE );
add_integer( "marq-x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_FALSE );
add_integer( "marq-y", -1, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_FALSE );
add_integer( "marq-y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_FALSE );
add_integer( "marq-timeout", 0, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT,
VLC_FALSE );
add_integer( "marq-position", 5, NULL, POS_TEXT, POS_LONGTEXT, VLC_TRUE );
/* 5 sets the default to top [1] left [4] */
change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 );
add_integer_with_range( "marq-opacity", -1, -1, 255, NULL,
OPACITY_TEXT, OPACITY_LONGTEXT, VLC_FALSE );
add_integer( "marq-color", -1, NULL, COLOR_TEXT, COLOR_LONGTEXT, VLC_TRUE );
change_integer_list( pi_color_values, ppsz_color_descriptions, 0 );
set_description( _("Marquee display sub filter") );
add_shortcut( "marq" );
vlc_module_end();
......@@ -113,6 +137,7 @@ static int CreateFilter( vlc_object_t *p_this )
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
vlc_object_t *p_input;
vlc_value_t val;
/* Allocate structure */
p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
......@@ -134,21 +159,20 @@ static int CreateFilter( vlc_object_t *p_this )
p_sys->i_timeout = var_CreateGetInteger( p_input->p_libvlc , "marq-timeout" );
p_sys->i_pos = var_CreateGetInteger( p_input->p_libvlc , "marq-position" );
p_sys->psz_marquee = var_CreateGetString( p_input->p_libvlc, "marq-marquee" );
var_Create( p_input->p_libvlc, "marq-opacity", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
p_sys->i_font_opacity = var_CreateGetInteger( p_input->p_libvlc , "marq-opacity" );
p_sys->i_font_color = var_CreateGetInteger( p_input->p_libvlc , "marq-color" );
var_AddCallback( p_input->p_libvlc, "marq-x", MarqueeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "marq-y", MarqueeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "marq-marquee", MarqueeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "marq-timeout", MarqueeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "marq-position", MarqueeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "marq-color", MarqueeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "marq-opacity", MarqueeCallback, p_sys );
vlc_object_release( p_input );
p_sys->b_absolute = VLC_TRUE;
if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )
{
p_sys->b_absolute = VLC_FALSE;
p_sys->i_xoff = 0; p_sys->i_yoff = 0;
}
/* Misc init */
p_filter->pf_sub_filter = Filter;
......@@ -169,7 +193,7 @@ static void DestroyFilter( vlc_object_t *p_this )
if( p_sys->psz_marquee ) free( p_sys->psz_marquee );
free( p_sys );
/* Delete the marquee variables from playlist */
/* Delete the marquee variables */
p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( !p_input )
{
......@@ -180,6 +204,8 @@ static void DestroyFilter( vlc_object_t *p_this )
var_Destroy( p_input->p_libvlc , "marq-y" );
var_Destroy( p_input->p_libvlc , "marq-timeout" );
var_Destroy( p_input->p_libvlc , "marq-position" );
var_Destroy( p_input->p_libvlc , "marq-color");
var_Destroy( p_input->p_libvlc , "marq-opacity");
vlc_object_release( p_input );
}
......@@ -205,6 +231,12 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
return NULL;
}
p_sys->b_absolute = VLC_TRUE;
if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )
{
p_sys->b_absolute = VLC_FALSE;
}
p_spu = p_filter->pf_sub_buffer_new( p_filter );
if( !p_spu ) return NULL;
......@@ -215,7 +247,6 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
fmt.i_width = fmt.i_height = 0;
fmt.i_x_offset = 0;
fmt.i_y_offset = 0;
p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt );
if( !p_spu->p_region )
{
......@@ -231,6 +262,8 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
p_spu->b_ephemer = VLC_TRUE;
p_spu->i_x = p_sys->i_xoff;
p_spu->i_y = p_sys->i_yoff;
p_spu->p_region->i_font_color = p_sys->i_font_color;
p_spu->p_region->i_font_opacity = p_sys->i_font_opacity;;
p_spu->i_flags = p_sys->i_pos;
......@@ -260,6 +293,14 @@ static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var,
{
p_sys->i_yoff = newval.i_int;
}
else if ( !strncmp( psz_var, "marq-color", 8 ) ) /* "marq-col" */
{
p_sys->i_font_color = newval.i_int;
}
else if ( !strncmp( psz_var, "marq-opacity", 8 ) ) /* "marq-opa" */
{
p_sys->i_font_opacity = newval.i_int;
}
else if ( !strncmp( psz_var, "marq-timeout", 12 ) )
{
p_sys->i_timeout = newval.i_int;
......@@ -268,6 +309,7 @@ static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var,
/* willing to accept a match against marq-pos */
{
p_sys->i_pos = newval.i_int;
p_sys->i_xoff = -1; /* force to relative positioning */
}
p_sys->b_need_update = VLC_TRUE;
return VLC_SUCCESS;
......
/*****************************************************************************
* time.c : time display video plugin for vlc
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
* Copyright (C) 2003-2005 VideoLAN
* $Id$
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
......@@ -40,6 +40,18 @@
static int CreateFilter ( vlc_object_t * );
static void DestroyFilter( vlc_object_t * );
static subpicture_t *Filter( filter_t *, mtime_t );
static int TimeCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval,
void *p_data );
static int pi_color_values[] = { 0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0,
0x00FFFFFF, 0x00800000, 0x00FF0000, 0x00FF00FF, 0x00FFFF00,
0x00808000, 0x00008000, 0x00008080, 0x0000FF00, 0x00800080,
0x00000080, 0x000000FF, 0x0000FFFF};
static char *ppsz_color_descriptions[] = { N_("Default"), N_("Black"),
N_("Gray"), N_("Silver"), N_("White"), N_("Maroon"), N_("Red"),
N_("Fuchsia"), N_("Yellow"), N_("Olive"), N_("Green"),
N_("Teal"), N_("Lime"), N_("Purple"), N_("Navy"), N_("Blue"),
N_("Aqua") };
/*****************************************************************************
* filter_sys_t: time filter descriptor
......@@ -48,6 +60,9 @@ struct filter_sys_t
{
int i_xoff, i_yoff; /* offsets for the display string in the video window */
char *psz_format; /* time format string */
int i_pos; /* permit relative positioning (top, bottom, left, right, center) */
int i_font_color, i_font_opacity; /* font color control */
vlc_bool_t b_absolute; /* position control, relative vs. absolute */
time_t last_time;
};
......@@ -58,6 +73,23 @@ struct filter_sys_t
#define POSX_LONGTEXT N_("X offset, from the left screen edge" )
#define POSY_TEXT N_("Y offset, from the top")
#define POSY_LONGTEXT N_("Y offset, down from the top" )
#define OPACITY_TEXT N_("Opacity, -1..255")
#define OPACITY_LONGTEXT N_("The opacity (inverse of transparency) of overlay text. " \
"-1 = use freetype-opacity, 0 = transparent, 255 = totally opaque. " )
#define COLOR_TEXT N_("Text Default Color")
#define COLOR_LONGTEXT N_("The color of overlay text. 1 byte for each color, hexadecimal." \
"-1 = use freetype-color, #000000 = all colors off, " \
"0xFF0000 = just Red, 0xFFFFFF = all color on [White]" )
#define POS_TEXT N_("Time position")
#define POS_LONGTEXT N_( \
"You can enforce the time position on the video " \
"(0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \
"also use combinations of these values by adding them).")
static int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
static char *ppsz_pos_descriptions[] =
{ N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
/*****************************************************************************
* Module descriptor
......@@ -69,19 +101,27 @@ vlc_module_begin();
set_subcategory( SUBCAT_VIDEO_SUBPIC );
set_callbacks( CreateFilter, DestroyFilter );
add_string( "time-format", "%Y-%m-%d %H:%M:%S", NULL, MSG_TEXT, MSG_LONGTEXT, VLC_FALSE );
add_integer( "time-x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_FALSE );
add_integer( "time-x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_FALSE );
add_integer( "time-y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_FALSE );
add_integer( "time-position", 9, NULL, POS_TEXT, POS_LONGTEXT, VLC_TRUE );
/* 9 sets the default to bottom-left, minimizing jitter */
change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 );
add_integer_with_range( "time-opacity", -1, -1, 255, NULL,
OPACITY_TEXT, OPACITY_LONGTEXT, VLC_FALSE );
add_integer( "time-color", -1, NULL, COLOR_TEXT, COLOR_LONGTEXT, VLC_TRUE );
change_integer_list( pi_color_values, ppsz_color_descriptions, 0 );
set_description( _("Time display sub filter") );
add_shortcut( "time" );
vlc_module_end();
/*****************************************************************************
* CreateFilter: allocates logo video filter
* CreateFilter: allocates time video filter
*****************************************************************************/
static int CreateFilter( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
vlc_object_t *p_input;
vlc_value_t val;
/* Allocate structure */
......@@ -91,14 +131,29 @@ static int CreateFilter( vlc_object_t *p_this )
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
/* Hook used for callback variables */
p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( !p_input )
{
return VLC_ENOOBJ;
}
p_sys->i_xoff = var_CreateGetInteger( p_input->p_libvlc , "time-x" );
p_sys->i_yoff = var_CreateGetInteger( p_input->p_libvlc , "time-y" );
p_sys->psz_format = var_CreateGetString( p_input->p_libvlc, "time-format" );
p_sys->i_pos = var_CreateGetInteger( p_input->p_libvlc , "time-position" );
var_Create( p_input->p_libvlc, "time-opacity", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
p_sys->i_font_opacity = var_CreateGetInteger( p_input->p_libvlc , "time-opacity" );
p_sys->i_font_color = var_CreateGetInteger( p_input->p_libvlc , "time-color" );
var_Create( p_this, "time-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_filter, "time-x", &val );
p_sys->i_xoff = val.i_int;
var_Create( p_this, "time-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_filter, "time-y", &val );
p_sys->i_yoff = val.i_int;
p_sys->psz_format = var_CreateGetString( p_this, "time-format" );
var_AddCallback( p_input->p_libvlc, "time-x", TimeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "time-y", TimeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "time-format", TimeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "time-position", TimeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "time-color", TimeCallback, p_sys );
var_AddCallback( p_input->p_libvlc, "time-opacity", TimeCallback, p_sys );
vlc_object_release( p_input );
/* Misc init */
p_filter->pf_sub_filter = Filter;
......@@ -113,12 +168,25 @@ static void DestroyFilter( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
vlc_object_t *p_input;
if( p_sys->psz_format ) free( p_sys->psz_format );
free( p_sys );
/* Delete the time variables */
p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE );
if( !p_input )
{
return;
}
var_Destroy( p_input->p_libvlc , "time-format" );
var_Destroy( p_input->p_libvlc , "time-x" );
var_Destroy( p_input->p_libvlc , "time-y" );
var_Destroy( p_input->p_libvlc , "time-position" );
var_Destroy( p_input->p_libvlc , "time-color");
var_Destroy( p_input->p_libvlc , "time-opacity");
vlc_object_release( p_input );
}
static char *FormatTime(char *tformat )
{
char buffer[255];
......@@ -156,16 +224,22 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
if( p_sys->last_time == time( NULL ) ) return NULL;
p_sys->b_absolute = VLC_TRUE;
if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )
{
p_sys->b_absolute = VLC_FALSE;
}
p_spu = p_filter->pf_sub_buffer_new( p_filter );
if( !p_spu ) return NULL;
p_spu->b_absolute = p_sys->b_absolute;
memset( &fmt, 0, sizeof(video_format_t) );
fmt.i_chroma = VLC_FOURCC('T','E','X','T');
fmt.i_aspect = 0;
fmt.i_width = fmt.i_height = 0;
fmt.i_x_offset = 0;
fmt.i_y_offset = 0;
p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt );
if( !p_spu->p_region )
{
......@@ -182,7 +256,48 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
p_spu->b_absolute = VLC_FALSE;
p_spu->i_x = p_sys->i_xoff;
p_spu->i_y = p_sys->i_yoff;
p_spu->p_region->i_font_color = p_sys->i_font_color;
p_spu->p_region->i_font_opacity = p_sys->i_font_opacity;;
p_spu->i_flags = p_sys->i_pos;
p_spu->i_flags = OSD_ALIGN_LEFT|OSD_ALIGN_TOP ;
return p_spu;
}
/**********************************************************************
* Callback to update params on the fly
**********************************************************************/
static int TimeCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
{
filter_sys_t *p_sys = (filter_sys_t *) p_data;
if( !strncmp( psz_var, "time-format", 11 ) )
{
if( p_sys->psz_format ) free( p_sys->psz_format );
p_sys->psz_format = strdup( newval.psz_string );
}
else if ( !strncmp( psz_var, "time-x", 6 ) )
{
p_sys->i_xoff = newval.i_int;
}
else if ( !strncmp( psz_var, "time-y", 6 ) )
{
p_sys->i_yoff = newval.i_int;
}
else if ( !strncmp( psz_var, "time-color", 8 ) ) /* "time-col" */
{
p_sys->i_font_color = newval.i_int;
}
else if ( !strncmp( psz_var, "time-opacity", 8 ) ) /* "time-opa" */
{
p_sys->i_font_opacity = newval.i_int;
}
else if ( !strncmp( psz_var, "time-position", 8 ) )
/* willing to accept a match against time-pos */
{
p_sys->i_pos = newval.i_int;
p_sys->i_xoff = -1; /* force to relative positioning */
}
return VLC_SUCCESS;
}
/*****************************************************************************
* vout_subpictures.c : subpicture management functions
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
* Copyright (C) 2000-2005 VideoLAN
* $Id$
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
......@@ -257,6 +257,8 @@ subpicture_region_t *__spu_CreateRegion( vlc_object_t *p_this,
p_region->p_cache = 0;
p_region->fmt = *p_fmt;
p_region->psz_text = 0;
p_region->i_font_color = -1; /* default to using freetype-color -opacity */
p_region->i_font_opacity = -1;
if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
p_fmt->p_palette = p_region->fmt.p_palette =
......@@ -378,7 +380,6 @@ subpicture_t *spu_CreateSubpicture( spu_t *p_spu )
p_subpic->pf_render = 0;
p_subpic->pf_destroy = 0;
p_subpic->p_sys = 0;
vlc_mutex_unlock( &p_spu->subpicture_lock );
p_subpic->pf_create_region = __spu_CreateRegion;
......@@ -442,6 +443,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
subpicture_t *p_subpic,
int i_scale_width_orig, int i_scale_height_orig )
{
/* Get lock */
vlc_mutex_lock( &p_spu->subpicture_lock );
......@@ -460,7 +462,6 @@ 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_aspect = p_fmt->i_aspect;
p_spu->p_blend->fmt_out.video.i_chroma = p_fmt->i_chroma;
p_spu->p_blend->fmt_in.video.i_chroma = VLC_FOURCC('Y','U','V','P');
p_spu->p_blend->p_module =
......@@ -482,7 +483,6 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
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 );
}
......@@ -556,7 +556,6 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
subpicture_region_t tmp_region;
block_t *p_new_block =
block_New( p_spu, strlen(p_region->psz_text) + 1 );
if( p_new_block )
{
memcpy( p_new_block->p_buffer, p_region->psz_text,
......@@ -565,8 +564,10 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
p_subpic->i_start;
p_new_block->i_length =
p_subpic->i_start - p_subpic->i_stop;
/* the actual call to RenderText in freetype.c: */
p_subpic_tmp = p_spu->p_text->pf_render_string(
p_spu->p_text, p_new_block );
p_spu->p_text, p_new_block,
p_region->i_font_color, p_region->i_font_opacity);
if( p_subpic_tmp )
{
......@@ -808,7 +809,6 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date )
{
continue;
}
if( display_date &&
display_date < p_spu->p_subpicture[i_index].i_start )
{
......
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