/*****************************************************************************
* logo.c : logo video plugin for vlc
*****************************************************************************
- * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
- * $Id: logo.c,v 1.3 2003/09/18 21:42:54 garf Exp $
+ * Copyright (C) 2003-2004 VideoLAN
+ * $Id$
*
* Authors: Simon Latapie <garf@videolan.org>
*
* Module descriptor
*****************************************************************************/
-#define FILE_TEXT N_("Logo File")
-#define FILE_LONGTEXT N_("It must be a PNG in RGBA 8bits (for now)")
-#define POSX_TEXT N_("x postion of the logo")
-#define POSX_LONGTEXT N_("You can move the logo by left-clicking on it" )
-#define POSY_TEXT N_("y position of the logo")
-#define POSY_LONGTEXT N_("You can move the logo by left-clicking on it" )
-#define TRANS_TEXT N_("transparency of the logo")
-#define TRANS_LONGTEXT N_("You can change it by middle-clicking and moving mouse left or right")
+#define FILE_TEXT N_("Logo filename")
+#define FILE_LONGTEXT N_("The file must be in PNG RGBA 8bits format (for now).")
+#define POSX_TEXT N_("X coordinate of the logo")
+#define POSX_LONGTEXT N_("You can move the logo by left-clicking on it." )
+#define POSY_TEXT N_("Y coordinate of the logo")
+#define POSY_LONGTEXT N_("You can move the logo by left-clicking on it." )
+#define TRANS_TEXT N_("Transparency of the logo (255-0)")
+#define TRANS_LONGTEXT N_("You can change it by middle-clicking and moving mouse left or right.")
vlc_module_begin();
- add_category_hint( N_("logo"), NULL, VLC_FALSE );
- add_file( "logo_file", NULL, NULL, FILE_TEXT, FILE_LONGTEXT, VLC_FALSE );
- add_integer( "logo_x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_FALSE );
- add_integer( "logo_y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_FALSE );
- add_float( "logo_transparency", 1, NULL, TRANS_TEXT, TRANS_LONGTEXT, VLC_FALSE );
- set_description( _("logo video filter") );
+ set_description( _("Logo video filter") );
set_capability( "video filter", 0 );
+
+ add_file( "logo-file", NULL, NULL, FILE_TEXT, FILE_LONGTEXT, VLC_FALSE );
+ add_integer( "logo-x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_FALSE );
+ add_integer( "logo-y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_FALSE );
+ add_integer_with_range( "logo-transparency", 255, 0, 255, NULL,
+ TRANS_TEXT, TRANS_LONGTEXT, VLC_FALSE );
+
add_shortcut( "logo" );
set_callbacks( Create, Destroy );
vlc_module_end();
int trans;
};
+/*****************************************************************************
+ * Control: control facility for the vout (forwards to child vout)
+ *****************************************************************************/
+static int Control( vout_thread_t *p_vout, int i_query, va_list args )
+{
+ return vout_vaControl( p_vout->p_sys->p_vout, i_query, args );
+}
+
/*****************************************************************************
* Create: allocates logo video thread output method
*****************************************************************************
p_vout->pf_manage = NULL;
p_vout->pf_render = Render;
p_vout->pf_display = NULL;
+ p_vout->pf_control = Control;
return VLC_SUCCESS;
}
int i_parity_height;
/* read png file */
- filename = config_GetPsz( p_vout, "logo_file" );
+ filename = config_GetPsz( p_vout, "logo-file" );
fp = fopen( filename , "rb");
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL , NULL , NULL);
info_ptr = png_create_info_struct(png_ptr);
-
+
if (fp == NULL)
{
p_vout->p_sys->error=1;
/* initialize yuv plans of the image */
i_parity_width = p_vout->p_sys->width % 2;
i_parity_height = p_vout->p_sys->height % 2;
-
+
p_vout->p_sys->height = p_vout->p_sys->height
+ (p_vout->p_sys->height % 2);
p_vout->p_sys->width = p_vout->p_sys->width
uint8_t (*p)[4];
int idx;
int idxc;
-
+
/* FIXME FIXME */
p = (void*)row_pointers[y];
idx = x + y * p_vout->p_sys->width;
if( ( x % 2 == 0 ) && ( y % 2 == 0 ) )
{
-
+
temp = (p[x][2] * 439
- p[x][0] * 148
- p[x][1] * 291)/1000 + 128;
p_vout->p_sys->png_image_a[1][idxc] = p_vout->p_sys->png_image_a[0][idx];
}
-
+
} else
{
p_vout->p_sys->png_image_a[0][idx]= 0;
/* now we can free row_pointers*/
free(row_pointers);
}
-
+
I_OUTPUTPICTURES = 0;
/* Initialize the output structure */
ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-
- p_vout->p_sys->posx = config_GetInt( p_vout, "logo_x" );
- p_vout->p_sys->posy = config_GetInt( p_vout, "logo_y" );
- p_vout->p_sys->trans = (int)(config_GetFloat( p_vout, "logo_transparency" ) * 255);
+
+ ADD_PARENT_CALLBACKS( SendEventsToChild );
+
+ p_vout->p_sys->posx = config_GetInt( p_vout, "logo-x" );
+ p_vout->p_sys->posy = config_GetInt( p_vout, "logo-y" );
+ p_vout->p_sys->trans = config_GetInt( p_vout, "logo-transparency");
return VLC_SUCCESS;
}
var_DelCallback( p_vout->p_sys->p_vout, "mouse-x", MouseEvent, p_vout);
var_DelCallback( p_vout->p_sys->p_vout, "mouse-y", MouseEvent, p_vout);
- DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
- vlc_object_detach( p_vout->p_sys->p_vout );
- vout_Destroy( p_vout->p_sys->p_vout );
+ if( p_vout->p_sys->p_vout )
+ {
+ DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+ vlc_object_detach( p_vout->p_sys->p_vout );
+ vout_Destroy( p_vout->p_sys->p_vout );
+ }
- config_PutInt( p_vout, "logo_x", p_vout->p_sys->posx );
- config_PutInt( p_vout, "logo_y", p_vout->p_sys->posy );
- config_PutFloat( p_vout, "logo_transparency", (float)(p_vout->p_sys->trans) / 255.0 );
+ config_PutInt( p_vout, "logo-x", p_vout->p_sys->posx );
+ config_PutInt( p_vout, "logo-y", p_vout->p_sys->posy );
if (p_vout->p_sys->error == 0)
{
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
+ DEL_PARENT_CALLBACKS( SendEventsToChild );
+
free( p_vout->p_sys );
}
vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, p_pic->date );
vout_LinkPicture( p_vout->p_sys->p_vout, p_outpic );
-
+
tr = p_vout->p_sys->trans;
-
+
for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
{
memcpy( p_outpic->p[i_index].p_pixels,
- p_pic->p[i_index].p_pixels,
+ p_pic->p[i_index].p_pixels,
p_pic->p[i_index].i_lines * p_pic->p[i_index].i_pitch);
} else
{
p_out = p_outpic->p[i_index].p_pixels +
- (p_vout->p_sys->posy/2)* p_outpic->p[i_index].i_pitch +
+ p_vout->p_sys->posy / 2 * p_outpic->p[i_index].i_pitch +
p_vout->p_sys->posx / 2;
i_max = p_vout->p_sys->height / 2;
j_max = p_vout->p_sys->width / 2;
}
i_delta = p_outpic->p[i_index].i_pitch - j_max;
-
+
p_in_a = p_vout->p_sys->png_image_a[i_index];
p_in = p_vout->p_sys->png_image[i_index];
-
+
for( i = 0; i < i_max ; i++ )
{
for( j = 0 ; j < j_max ; j++)
{
- *p_out = ( *p_out * ( 65025 - *p_in_a * tr) + *p_in * *p_in_a * tr) >> 16;
+ *p_out = ( *p_out * ( 65025 - *p_in_a * tr) + *p_in * *p_in_a * tr ) >> 16;
p_out++;
p_in++;
p_in_a++;
#define width p_vout->p_sys->width
#define height p_vout->p_sys->height
#define trans p_vout->p_sys->trans
-
+
var_Get( p_vout->p_sys->p_vout, "mouse-button-down", &valb );
i_delta = newval.i_int - oldval.i_int;
{
posx = __MIN( __MAX( posx + i_delta , 0 ) , p_vout->output.i_width - width );
}
-
+
}
else if( psz_var[6] == 'y' )
{
return VLC_SUCCESS;
}
+
+/*****************************************************************************
+ * SendEventsToChild: forward events to the child/children vout
+ *****************************************************************************/
+static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ vout_thread_t *p_vout = (vout_thread_t *)p_this;
+ var_Set( p_vout->p_sys->p_vout, psz_var, newval );
+ return VLC_SUCCESS;
+}