Commit 1ac8441a authored by Jean-Paul Saman's avatar Jean-Paul Saman

Merge branch 'dynamicoverlay'

parents 665cd920 569f294d
......@@ -208,6 +208,7 @@ Sebastian Jenny <jenny - sebastian &t gmail - com > - AAC decoding channel order
Sebastien Chaumat <Sebastien.Chaumat at ens-lyon.fr> - YOPY port tests
Sidney Doria <ssdoria qt gmail.com> - Brazilian Portuguese localisation
Simon Damkjær Andersen <simondamkjaer at gmail.com> - playmode icons and the entire Fullscreen Panel design for the OSX GUI (v0.8.6)
Soren Bog <avacore at videolan dot org> - dynamicoverlays
Stefán Freyr Stefánsson <stefan.freyr -at- gmail.com> - Qt4 speed slider
Steve Lhomme <steve dot lhomme at free dot fr> - MSVC fixes and Matroska enhancements
Steve Brown <sbrown at cortland.com> - fix for optional PES size bug
......
......@@ -1200,7 +1200,7 @@ dnl
VLC_ADD_PLUGINS([dummy logger memcpy])
VLC_ADD_PLUGINS([mpgv mpga m4v m4a h264 vc1 demux_cdg cdg ps pva avi asf mp4 rawdv rawvid nsv real aiff mjpeg demuxdump flacsys tta])
VLC_ADD_PLUGINS([cvdsub svcdsub spudec subsdec subsusf t140 dvbsub cc mpeg_audio lpcm a52 dts cinepak flac])
VLC_ADD_PLUGINS([deinterlace invert adjust transform wave ripple psychedelic gradient motionblur rv32 rotate noise grain extract sharpen seamcarving croppadd])
VLC_ADD_PLUGINS([deinterlace invert adjust transform wave ripple psychedelic gradient motionblur rv32 rotate noise grain extract sharpen seamcarving croppadd dynamicoverlay blendbench])
VLC_ADD_PLUGINS([converter_fixed mono])
VLC_ADD_PLUGINS([trivial_resampler ugly_resampler])
VLC_ADD_PLUGINS([trivial_channel_mixer trivial_mixer])
......@@ -6294,6 +6294,7 @@ AC_CONFIG_FILES([
modules/video_chroma/Makefile
modules/video_filter/Makefile
modules/video_filter/atmo/Makefile
modules/video_filter/dynamicoverlay/Makefile
modules/video_output/Makefile
modules/video_output/msw/Makefile
modules/video_output/qte/Makefile
......
......@@ -211,10 +211,11 @@ struct subpicture_region_t
int i_x; /**< position of region */
int i_y; /**< position of region */
int i_align; /**< alignment within a region */
int i_alpha; /**< transparency */
char *psz_text; /**< text string comprising this region */
char *psz_html; /**< HTML version of subtitle (NULL = use psz_text) */
text_style_t *p_style; /* a description of the text style formatting */
text_style_t *p_style; /**< a description of the text style formatting */
subpicture_region_t *p_next; /**< next region in the list */
subpicture_region_t *p_cache; /**< modified version of this region */
......
......@@ -36,4 +36,5 @@ SOURCES_gaussianblur = gaussianblur.c
SOURCES_grain = grain.c
SOURCES_seamcarving = seamcarving.c
SOURCES_croppadd = croppadd.c
SOURCES_blendbench = blendbench.c
noinst_HEADERS = filter_common.h filter_picture.h
/*****************************************************************************
* blendbench.c : blending benchmark plugin for vlc
*****************************************************************************
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Author: Søren Bøg <avacore@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
* (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.
*
* 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.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
#include <vlc_sout.h>
#include <vlc_vout.h>
#include "vlc_filter.h"
#include "vlc_image.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Create( vlc_object_t * );
static void Destroy( vlc_object_t * );
static picture_t *Filter( filter_t *, picture_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define LOOPS_TEXT N_("Number of time to blend")
#define LOOPS_LONGTEXT N_("The number of time the blend will be performed")
#define ALPHA_TEXT N_("Alpha of the blended image")
#define ALPHA_LONGTEXT N_("Alpha with which the blend image is blended")
#define BASE_IMAGE_TEXT N_("Image to be blended onto")
#define BASE_IMAGE_LONGTEXT N_("The image which will be used to blend onto")
#define BASE_CHROMA_TEXT N_("Chroma for the base image")
#define BASE_CHROMA_LONGTEXT N_("Chroma which the base image will be loaded in")
#define BLEND_IMAGE_TEXT N_("Image which will be blended.")
#define BLEND_IMAGE_LONGTEXT N_("The image blended onto the base image")
#define BLEND_CHROMA_TEXT N_("Chroma for the blend image")
#define BLEND_CHROMA_LONGTEXT N_("Chroma which the blend image will be loaded" \
"in")
#define CFG_PREFIX "blendbench-"
vlc_module_begin();
set_description( _("Blending benchmark filter") );
set_shortname( _("blendbench" ));
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_VFILTER );
set_capability( "video filter2", 0 );
set_section( N_("Benchmarking"), NULL );
add_integer( CFG_PREFIX "loops", 1000, NULL, LOOPS_TEXT,
LOOPS_LONGTEXT, VLC_FALSE );
add_integer_with_range( CFG_PREFIX "alpha", 128, 0, 255, NULL, ALPHA_TEXT,
ALPHA_LONGTEXT, VLC_FALSE );
set_section( N_("Base image"), NULL );
add_file( CFG_PREFIX "base-image", NULL, NULL, BASE_IMAGE_TEXT,
BASE_IMAGE_LONGTEXT, VLC_FALSE );
add_string( CFG_PREFIX "base-chroma", "I420", NULL, BASE_CHROMA_TEXT,
BASE_CHROMA_LONGTEXT, VLC_FALSE );
set_section( N_("Blend image"), NULL );
add_file( CFG_PREFIX "blend-image", NULL, NULL, BLEND_IMAGE_TEXT,
BLEND_IMAGE_LONGTEXT, VLC_FALSE );
add_string( CFG_PREFIX "blend-chroma", "YUVA", NULL, BLEND_CHROMA_TEXT,
BLEND_CHROMA_LONGTEXT, VLC_FALSE );
set_callbacks( Create, Destroy );
vlc_module_end();
static const char *ppsz_filter_options[] = {
"loops", "alpha", "base-image", "base-chroma", "blend-image",
"blend-chroma", NULL
};
/*****************************************************************************
* filter_sys_t: filter method descriptor
*****************************************************************************/
struct filter_sys_t
{
vlc_bool_t b_done;
int i_loops, i_alpha;
picture_t *p_base_image;
picture_t *p_blend_image;
vlc_fourcc_t i_base_chroma;
vlc_fourcc_t i_blend_chroma;
};
static int LoadImage( vlc_object_t *p_this, picture_t **pp_pic,
vlc_fourcc_t i_chroma, char *psz_file, const char *psz_name )
{
image_handler_t *p_image;
video_format_t fmt_in, fmt_out;
memset( &fmt_in, 0, sizeof(video_format_t) );
memset( &fmt_out, 0, sizeof(video_format_t) );
fmt_out.i_chroma = i_chroma;
p_image = image_HandlerCreate( p_this );
*pp_pic = image_ReadUrl( p_image, psz_file, &fmt_in, &fmt_out );
image_HandlerDelete( p_image );
if( *pp_pic == NULL ) {
msg_Err( p_this, "Unable to load %s image", psz_name );
return VLC_EGENERIC;
}
msg_Dbg( p_this, "%s image has dim %d x %d (Y plane)", psz_name,
(*pp_pic)->p[Y_PLANE].i_visible_pitch,
(*pp_pic)->p[Y_PLANE].i_visible_lines );
return VLC_SUCCESS;
}
/*****************************************************************************
* Create: allocates video thread output method
*****************************************************************************/
static int Create( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
char *psz_temp;
/* Allocate structure */
p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
if( p_filter->p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
p_sys = p_filter->p_sys;
p_sys->b_done = VLC_FALSE;
p_filter->pf_video_filter = Filter;
/* needed to get options passed in transcode using the
* adjust{name=value} syntax */
config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
p_filter->p_cfg );
p_sys->i_loops = var_CreateGetIntegerCommand( p_filter,
CFG_PREFIX "loops" );
p_sys->i_alpha = var_CreateGetIntegerCommand( p_filter,
CFG_PREFIX "alpha" );
psz_temp = var_CreateGetStringCommand( p_filter, CFG_PREFIX "base-chroma" );
p_sys->i_base_chroma = VLC_FOURCC( psz_temp[0], psz_temp[1],
psz_temp[2], psz_temp[3] );
LoadImage( p_this, &p_sys->p_base_image, p_sys->i_base_chroma,
var_CreateGetStringCommand( p_filter, CFG_PREFIX "base-image" ),
"Base" );
psz_temp = var_CreateGetStringCommand( p_filter,
CFG_PREFIX "blend-chroma" );
p_sys->i_blend_chroma = VLC_FOURCC( psz_temp[0], psz_temp[1],
psz_temp[2], psz_temp[3] );
LoadImage( p_this, &p_sys->p_blend_image, p_sys->i_blend_chroma,
var_CreateGetStringCommand( p_filter, CFG_PREFIX "blend-image" ),
"Blend" );
return VLC_SUCCESS;
}
/*****************************************************************************
* Destroy: destroy video thread output method
*****************************************************************************/
static void Destroy( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
p_sys->p_base_image->pf_release( p_sys->p_base_image );
p_sys->p_blend_image->pf_release( p_sys->p_blend_image );
}
/*****************************************************************************
* Render: displays previously rendered output
*****************************************************************************/
static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{
filter_sys_t *p_sys = p_filter->p_sys;
if( p_sys->b_done )
{
return p_pic;
}
filter_t *p_blend;
p_blend = vlc_object_create( p_filter, VLC_OBJECT_FILTER );
vlc_object_attach( p_blend, p_filter );
p_blend->fmt_out.video = p_sys->p_base_image->format;
p_blend->fmt_in.video = p_sys->p_blend_image->format;
p_blend->p_module = module_Need( p_blend, "video blending", 0, 0 );
mtime_t time = mdate();
for( int i_iter = 0; i_iter < p_sys->i_loops; ++i_iter )
{
p_blend->pf_video_blend( p_blend, p_sys->p_base_image,
p_sys->p_base_image, p_sys->p_blend_image, 0,
0, p_sys->i_alpha );
}
time = mdate() - time;
msg_Info( p_filter, "Blended %d images in %f sec.", p_sys->i_loops,
time / 1000000.0f );
msg_Info( p_filter, "Speed is: %f images/second, %f pixels/second",
(float) p_sys->i_loops / time * 1000000,
(float) p_sys->i_loops / time * 1000000 *
p_sys->p_blend_image->p[Y_PLANE].i_visible_pitch *
p_sys->p_blend_image->p[Y_PLANE].i_visible_lines );
module_Unneed( p_blend, p_blend->p_module );
vlc_object_detach( p_blend );
vlc_object_release( p_blend );
p_sys->b_done = VLC_TRUE;
return p_pic;
}
SOURCES_dynamicoverlay = dynamicoverlay_buffer.c dynamicoverlay_queue.c dynamicoverlay_list.c dynamicoverlay_commands.c dynamicoverlay.c
noinst_HEADERS = dynamicoverlay.h
/*****************************************************************************
* dynamicoverlay.c : dynamic overlay plugin for vlc
*****************************************************************************
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Author: Søren Bøg <avacore@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
* (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.
*
* 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.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
#include <vlc_sout.h>
#include <vlc_vout.h>
#include <vlc_filter.h>
#include <vlc_osd.h>
#include <ctype.h>
#include <fcntl.h>
#include "dynamicoverlay.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Create( vlc_object_t * );
static void Destroy( vlc_object_t * );
static subpicture_t *Filter( filter_t *, mtime_t );
static int AdjustCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval,
void *p_data );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define INPUT_TEXT N_("Input FIFO")
#define INPUT_LONGTEXT N_("FIFO which will be read for commands")
#define OUTPUT_TEXT N_("Output FIFO")
#define OUTPUT_LONGTEXT N_("FIFO which will be written to for responses")
vlc_module_begin();
set_description( _("Dynamic video overlay") );
set_shortname( _("Overlay" ));
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_VFILTER );
set_capability( "sub filter", 0 );
add_file( "overlay-input", NULL, NULL, INPUT_TEXT, INPUT_LONGTEXT,
VLC_FALSE );
add_file( "overlay-output", NULL, NULL, OUTPUT_TEXT, OUTPUT_LONGTEXT,
VLC_FALSE );
add_shortcut( "overlay" );
set_callbacks( Create, Destroy );
vlc_module_end();
static const char *ppsz_filter_options[] = {
"input", "output", NULL
};
/*****************************************************************************
* Create: allocates adjust video thread output method
*****************************************************************************
* This function allocates and initializes a adjust vout method.
*****************************************************************************/
static int Create( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
/* Allocate structure */
p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
if( p_filter->p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
p_sys = p_filter->p_sys;
BufferInit( &p_sys->input );
BufferInit( &p_sys->output );
QueueInit( &p_sys->atomic );
QueueInit( &p_sys->pending );
QueueInit( &p_sys->processed );
ListInit( &p_sys->overlays );
p_sys->i_inputfd = -1;
p_sys->i_outputfd = -1;
p_sys->b_updated = VLC_TRUE;
p_sys->b_atomic = VLC_FALSE;
p_filter->pf_sub_filter = Filter;
config_ChainParse( p_filter, "overlay-", ppsz_filter_options,
p_filter->p_cfg );
p_sys->psz_inputfile = var_CreateGetStringCommand( p_filter,
"overlay-input" );
p_sys->psz_outputfile = var_CreateGetStringCommand( p_filter,
"overlay-output" );
var_AddCallback( p_filter, "overlay-input", AdjustCallback, p_sys );
var_AddCallback( p_filter, "overlay-output", AdjustCallback, p_sys );
RegisterCommand( p_filter );
return VLC_SUCCESS;
}
/*****************************************************************************
* Destroy: destroy adjust video thread output method
*****************************************************************************
* Terminate an output method created by adjustCreateOutputMethod
*****************************************************************************/
static void Destroy( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
BufferDestroy( &p_filter->p_sys->input );
BufferDestroy( &p_filter->p_sys->output );
QueueDestroy( &p_filter->p_sys->atomic );
QueueDestroy( &p_filter->p_sys->pending );
QueueDestroy( &p_filter->p_sys->processed );
ListDestroy( &p_filter->p_sys->overlays );
UnregisterCommand( p_filter );
free( p_filter->p_sys->psz_inputfile );
free( p_filter->p_sys->psz_outputfile );
free( p_filter->p_sys );
}
/*****************************************************************************
* Render: displays previously rendered output
*****************************************************************************
* This function send the currently rendered image to adjust modified image,
* waits until it is displayed and switch the two rendering buffers, preparing
* next frame.
*****************************************************************************/
static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
{
filter_sys_t *p_sys = p_filter->p_sys;
/* We might need to open these at any time. */
if( p_sys->i_inputfd == -1 )
{
p_sys->i_inputfd = open( p_sys->psz_inputfile, O_RDONLY | O_NONBLOCK );
if( p_sys->i_inputfd == -1 )
{
msg_Warn( p_filter, "Failed to grab input file: %s (%s)",
p_sys->psz_inputfile, strerror( errno ) );
}
else
{
msg_Info( p_filter, "Grabbed input file: %s",
p_sys->psz_inputfile );
}
}
if( p_sys->i_outputfd == -1 )
{
p_sys->i_outputfd = open( p_sys->psz_outputfile,
O_WRONLY | O_NONBLOCK );
if( p_sys->i_outputfd == -1 )
{
if( errno != ENXIO )
{
msg_Warn( p_filter, "Failed to grab output file: %s (%s)",
p_sys->psz_outputfile, strerror( errno ) );
}
}
else
{
msg_Info( p_filter, "Grabbed output file: %s",
p_sys->psz_outputfile );
}
}
/* Read any waiting commands */
if( p_sys->i_inputfd != -1 )
{
char p_buffer[1024];
ssize_t i_len = read( p_sys->i_inputfd, p_buffer, 1024 );
if( i_len == -1 )
{
/* We hit an error */
if( errno != EAGAIN )
{
msg_Warn( p_filter, "Error on input file: %s",
strerror( errno ) );
close( p_sys->i_inputfd );
p_sys->i_inputfd = -1;
}
}
else if( i_len == 0 )
{
/* We hit the end-of-file */
}
else
{
BufferAdd( &p_sys->input, p_buffer, i_len );
}
}
/* Parse any complete commands */
char *p_end, *p_cmd;
while( ( p_end = memchr( p_sys->input.p_begin, '\n',
p_sys->input.i_length ) ) )
{
commanddesc_t *p_cur = NULL;
vlc_bool_t b_found = VLC_FALSE;
size_t i_index = 0;
*p_end = '\0';
p_cmd = BufferGetToken( &p_sys->input );
msg_Info( p_filter, "Search command: %s", p_cmd );
for( i_index = 0; i_index < p_sys->i_commands; i_index++ )
{
p_cur = p_sys->pp_commands[i_index];
if( !strncmp( p_cur->psz_command, p_cmd, strlen(p_cur->psz_command) ) )
{
p_cmd[strlen(p_cur->psz_command)] = '\0';
b_found = VLC_TRUE;
break;
}
}
if( !b_found )
{
/* No matching command */
msg_Err( p_filter, "Got invalid command: %s", p_cmd );
BufferPrintf( &p_sys->output, "FAILURE: %d Invalid Command\n", VLC_EGENERIC );
}
else
{
msg_Info( p_filter, "Got valid command: %s", p_cmd );
command_t *p_cmddesc = malloc( sizeof( command_t ) );
if( !p_cmddesc )
return NULL;
p_cmd = p_cmd + strlen(p_cur->psz_command) +1;
p_cmddesc->p_command = p_cur;
p_cmddesc->p_command->pf_parser( p_cmd, p_end,
&p_cmddesc->params );
if( ( p_cmddesc->p_command->b_atomic == VLC_TRUE ) &&
( p_sys->b_atomic == VLC_TRUE ) )
QueueEnqueue( &p_sys->atomic, p_cmddesc );
else
QueueEnqueue( &p_sys->pending, p_cmddesc );
}
BufferDel( &p_sys->input, p_end - p_sys->input.p_begin + 1 );
}
/* Process any pending commands */
command_t *p_command = NULL;
while( (p_command = QueueDequeue( &p_sys->pending )) )
{
p_command->i_status =
p_command->p_command->pf_execute( p_filter, &p_command->params,
&p_command->results );
QueueEnqueue( &p_sys->processed, p_command );
}
/* Output any processed commands */
while( (p_command = QueueDequeue( &p_sys->processed )) )
{
if( p_command->i_status == VLC_SUCCESS )
{
const char *psz_success = "SUCCESS:";
const char *psz_nl = "\n";
BufferAdd( &p_sys->output, psz_success, 8 );
p_command->p_command->pf_unparse( &p_command->results,
&p_sys->output );
BufferAdd( &p_sys->output, psz_nl, 1 );
}
else
{
BufferPrintf( &p_sys->output, "FAILURE: %d\n",
p_command->i_status );
}
}
/* Try emptying the output buffer */
if( p_sys->i_outputfd != -1 )
{
ssize_t i_len = write( p_sys->i_outputfd, p_sys->output.p_begin,
p_sys->output.i_length );
if( i_len == -1 )
{
/* We hit an error */
if( errno != EAGAIN )
{
msg_Warn( p_filter, "Error on output file: %s",
strerror( errno ) );
close( p_sys->i_outputfd );
p_sys->i_outputfd = -1;
}
}
else
{
BufferDel( &p_sys->output, i_len );
}
}