/*****************************************************************************
* logo.c : logo video plugin for vlc
*****************************************************************************
- * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
- * $Id: logo.c,v 1.2 2003/07/04 19:00:43 titer 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 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 position of the logo")
+#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")
+#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;
}
png_bytep * row_pointers;
png_infop info_ptr;
unsigned int i;
- unsigned int j;
+// unsigned int j;
+ unsigned int x;
+ unsigned int y;
int temp;
int i_size;
+ int i_parity_width;
+ 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;
msg_Err( p_vout , "file not found %s", filename );
free( filename );
- } else
+ }
+ else
{
free( filename );
p_vout->p_sys->error=0;
fclose(fp);
/* finish to read the image in the file. Now We have to convert it YUV */
/* 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
+ + (p_vout->p_sys->width % 2);
i_size = p_vout->p_sys->height * p_vout->p_sys->width;
p_vout->p_sys->png_image[0] = malloc( i_size );
p_vout->p_sys->png_image_a[1] = malloc( i_size / 4 );
p_vout->p_sys->png_image_a[2] = p_vout->p_sys->png_image_a[1];
- /* conversion */
- j = 0;
- for( i= 0; i < p_vout->p_sys->height * p_vout->p_sys->width ; i++)
+ for( y = 0; y < p_vout->p_sys->height ; y++)
{
- uint8_t (*p)[4];
- int x;
- int y;
-
- x = i % p_vout->p_sys->width;
- y = i / p_vout->p_sys->width;
-
- /* FIXME FIXME */
- p = (void*)row_pointers[y];
-
- p_vout->p_sys->png_image_a[0][i]= p[x][3];
- p_vout->p_sys->png_image[0][i]= (p[x][0] * 257
- + p[x][1] * 504
- + p[x][2] * 98)/1000 + 16;
-
- if( ( x % 2 == 0 ) && ( y % 2 == 0 ) )
+ for( x = 0; x < p_vout->p_sys->width ; x++)
{
- temp = (p[x][2] * 439
- - p[x][0] * 148
- - p[x][1] * 291)/1000 + 128;
+ uint8_t (*p)[4];
+ int idx;
+ int idxc;
- temp = (uint8_t)( temp < 0 ? 0 : temp );
- p_vout->p_sys->png_image[1][j] = temp;
+ /* FIXME FIXME */
+ p = (void*)row_pointers[y];
+ idx = x + y * p_vout->p_sys->width;
+ idxc= x/2 + (y/2) * (p_vout->p_sys->width/2);
- temp = ( p[x][0] * 439
- - p[x][1] * 368
- - p[x][2] * 71)/1000 + 128;
- temp = __MAX( __MIN( temp, 255 ), 0 );
+ if( ((i_parity_width == 0) || (x != (p_vout->p_sys->width - 1))) &&
+ ((i_parity_height == 0) || (y != (p_vout->p_sys->height - 1))))
+ {
+ p_vout->p_sys->png_image_a[0][idx]= p[x][3];
+ p_vout->p_sys->png_image[0][idx]= (p[x][0] * 257
+ + p[x][1] * 504
+ + p[x][2] * 98)/1000 + 16;
- p_vout->p_sys->png_image[2][j] = (uint8_t)( temp < 0 ? 0 : temp );
- p_vout->p_sys->png_image_a[1][j] = p_vout->p_sys->png_image_a[0][i];
- j++;
- }
+ if( ( x % 2 == 0 ) && ( y % 2 == 0 ) )
+ {
+
+ temp = (p[x][2] * 439
+ - p[x][0] * 148
+ - p[x][1] * 291)/1000 + 128;
+
+ temp = __MAX( __MIN( temp, 255 ), 0 );
+ p_vout->p_sys->png_image[1][idxc] = temp;
+
+ temp = ( p[x][0] * 439
+ - p[x][1] * 368
+ - p[x][2] * 71)/1000 + 128;
+ temp = __MAX( __MIN( temp, 255 ), 0 );
+ p_vout->p_sys->png_image[2][idxc] = temp;
+ 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;
}
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 );
}
{
picture_t *p_outpic;
int i_index;
- int i_pic_width;
int tr;
/* This is a new frame. Get a structure from the video_output. */
vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, p_pic->date );
vout_LinkPicture( p_vout->p_sys->p_vout, p_outpic );
- i_pic_width=p_vout->output.i_width;
-
+
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);
+
if (p_vout->p_sys->error == 0)
{
unsigned int i;
if (i_index == 0)
{
- p_out = p_outpic->p[i_index].p_pixels + p_vout->p_sys->posy * i_pic_width + p_vout->p_sys->posx;
- i_delta = i_pic_width - p_vout->p_sys->width;
+ p_out = p_outpic->p[i_index].p_pixels +
+ p_vout->p_sys->posy * p_outpic->p[i_index].i_pitch +
+ p_vout->p_sys->posx;
i_max = p_vout->p_sys->height;
j_max = p_vout->p_sys->width;
} else
{
- p_out = p_outpic->p[i_index].p_pixels + (p_vout->p_sys->posy / 2)* (i_pic_width / 2) + p_vout->p_sys->posx / 2;
- i_delta = (i_pic_width - p_vout->p_sys->width) / 2;
+ 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->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++;
p_out += i_delta;
}
}
-
}
vout_UnlinkPicture( p_vout->p_sys->p_vout, p_outpic );
#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;
+}