#include <vlc_plugin.h>
#include <vlc_vout.h>
-#include "filter_common.h"
#include "filter_picture.h"
#define TRANSFORM_MODE_HFLIP 1
static void FilterI422( vout_thread_t *, const picture_t *, picture_t * );
static void FilterYUYV( vout_thread_t *, const picture_t *, picture_t * );
-static int SendEvents( vlc_object_t *, char const *,
+static int MouseEvent( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
N_("Rotate by 180 degrees"), N_("Rotate by 270 degrees"),
N_("Flip horizontally"), N_("Flip vertically") };
+#define TRANSFORM_HELP N_("Rotate or flip the video")
#define CFG_PREFIX "transform-"
-vlc_module_begin();
- set_description( N_("Video transformation filter") );
- set_shortname( N_("Transformation"));
- set_capability( "video filter", 0 );
- set_category( CAT_VIDEO );
- set_subcategory( SUBCAT_VIDEO_VFILTER );
+vlc_module_begin ()
+ set_description( N_("Video transformation filter") )
+ set_shortname( N_("Transformation"))
+ set_help(TRANSFORM_HELP)
+ set_capability( "video filter", 0 )
+ set_category( CAT_VIDEO )
+ set_subcategory( SUBCAT_VIDEO_VFILTER )
add_string( CFG_PREFIX "type", "90", NULL,
- TYPE_TEXT, TYPE_LONGTEXT, false);
- change_string_list( type_list, type_list_text, 0);
+ TYPE_TEXT, TYPE_LONGTEXT, false)
+ change_string_list( type_list, type_list_text, 0)
- add_shortcut( "transform" );
- set_callbacks( Create, Destroy );
-vlc_module_end();
+ add_shortcut( "transform" )
+ set_callbacks( Create, Destroy )
+vlc_module_end ()
static const char *const ppsz_filter_options[] = {
"type", NULL
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
- {
- msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM;
- }
p_vout->pf_init = Init;
p_vout->pf_end = End;
p_vout->p_cfg );
/* Look what method was requested */
- psz_method = var_CreateGetNonEmptyString( p_vout, "transform-type" );
+ psz_method = var_CreateGetNonEmptyStringCommand( p_vout, "transform-type" );
switch( p_vout->fmt_in.i_chroma )
{
CASE_PLANAR_YUV_SQUARE
- case VLC_FOURCC('G','R','E','Y'):
+ case VLC_CODEC_GREY:
p_vout->p_sys->pf_filter = FilterPlanar;
break;
- case VLC_FOURCC('I','4','2','2'):
- case VLC_FOURCC('J','4','2','2'):
+ case VLC_CODEC_I422:
+ case VLC_CODEC_J422:
p_vout->p_sys->pf_filter = FilterI422;
break;
*****************************************************************************/
static int Init( vout_thread_t *p_vout )
{
- int i_index;
- picture_t *p_pic;
video_format_t fmt;
I_OUTPUTPICTURES = 0;
fmt.i_visible_height = p_vout->fmt_out.i_visible_width;
fmt.i_y_offset = p_vout->fmt_out.i_x_offset;
- fmt.i_aspect = VOUT_ASPECT_FACTOR *
- (uint64_t)VOUT_ASPECT_FACTOR / fmt.i_aspect;
-
fmt.i_sar_num = p_vout->fmt_out.i_sar_den;
fmt.i_sar_den = p_vout->fmt_out.i_sar_num;
}
return VLC_EGENERIC;
}
- ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
+ vout_filter_AllocateDirectBuffers( p_vout, VOUT_MAX_PICTURES );
- ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-
- ADD_PARENT_CALLBACKS( SendEventsToChild );
+ vout_filter_AddChild( p_vout, p_vout->p_sys->p_vout, MouseEvent );
return VLC_SUCCESS;
}
*****************************************************************************/
static void End( vout_thread_t *p_vout )
{
- int i_index;
+ vout_sys_t *p_sys = p_vout->p_sys;
- /* Free the fake output buffers we allocated */
- for( i_index = I_OUTPUTPICTURES ; i_index ; )
- {
- i_index--;
- free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
- }
+ vout_filter_DelChild( p_vout, p_sys->p_vout, MouseEvent );
+ vout_CloseAndRelease( p_sys->p_vout );
+
+ vout_filter_ReleaseDirectBuffers( p_vout );
}
/*****************************************************************************
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
- 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 );
- }
-
- DEL_PARENT_CALLBACKS( SendEventsToChild );
-
free( p_vout->p_sys );
}
while( ( p_outpic = vout_CreatePicture( p_vout->p_sys->p_vout, 0, 0, 0 ) )
== NULL )
{
- if( p_vout->b_die || p_vout->b_error )
+ if( !vlc_object_alive (p_vout) || p_vout->b_error )
{
return;
}
msleep( VOUT_OUTMEM_SLEEP );
}
- vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, p_pic->date );
+ p_outpic->date = p_pic->date;
vout_LinkPicture( p_vout->p_sys->p_vout, p_outpic );
p_vout->p_sys->pf_filter( p_vout, p_pic, p_outpic );
vout_DisplayPicture( p_vout->p_sys->p_vout, p_outpic );
}
-/*****************************************************************************
- * SendEvents: forward mouse and keyboard events to the parent p_vout
- *****************************************************************************/
-static int SendEvents( vlc_object_t *p_this, char const *psz_var,
- vlc_value_t oldval, vlc_value_t newval, void *_p_vout )
+/**
+ * Forward mouse event with proper conversion.
+ */
+static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t val, void *p_data )
{
+ vout_thread_t *p_vout = p_data;
VLC_UNUSED(p_this); VLC_UNUSED(oldval);
- vout_thread_t *p_vout = (vout_thread_t *)_p_vout;
- vlc_value_t sentval = newval;
- /* Translate the mouse coordinates */
- if( !strcmp( psz_var, "mouse-x" ) )
+ /* Translate the mouse coordinates
+ * FIXME missing lock */
+ if( !strcmp( psz_var, "mouse-button-down" ) )
+ return var_SetChecked( p_vout, psz_var, VLC_VAR_INTEGER, val );
+
+ int x = val.coords.x, y = val.coords.y;
+
+ switch( p_vout->p_sys->i_mode )
{
- switch( p_vout->p_sys->i_mode )
- {
- case TRANSFORM_MODE_270:
- sentval.i_int = p_vout->p_sys->p_vout->output.i_width
- - sentval.i_int;
case TRANSFORM_MODE_90:
- var_Set( p_vout, "mouse-y", sentval );
- return VLC_SUCCESS;
+ x = p_vout->p_sys->p_vout->output.i_height - val.coords.y;
+ y = val.coords.x;
+ break;
case TRANSFORM_MODE_180:
- case TRANSFORM_MODE_HFLIP:
- sentval.i_int = p_vout->p_sys->p_vout->output.i_width
- - sentval.i_int;
+ x = p_vout->p_sys->p_vout->output.i_width - val.coords.x;
+ y = p_vout->p_sys->p_vout->output.i_height - val.coords.y;
break;
- case TRANSFORM_MODE_VFLIP:
- default:
- break;
- }
- }
- else if( !strcmp( psz_var, "mouse-y" ) )
- {
- switch( p_vout->p_sys->i_mode )
- {
- case TRANSFORM_MODE_90:
- sentval.i_int = p_vout->p_sys->p_vout->output.i_height
- - sentval.i_int;
case TRANSFORM_MODE_270:
- var_Set( p_vout, "mouse-x", sentval );
- return VLC_SUCCESS;
+ x = val.coords.y;
+ y = p_vout->p_sys->p_vout->output.i_width - val.coords.x;
+ break;
+
+ case TRANSFORM_MODE_HFLIP:
+ x = p_vout->p_sys->p_vout->output.i_width - val.coords.x;
+ break;
- case TRANSFORM_MODE_180:
case TRANSFORM_MODE_VFLIP:
- sentval.i_int = p_vout->p_sys->p_vout->output.i_height
- - sentval.i_int;
+ y = p_vout->p_sys->p_vout->output.i_height - val.coords.y;
break;
- case TRANSFORM_MODE_HFLIP:
default:
break;
- }
}
-
- var_Set( p_vout, psz_var, sentval );
-
- 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 )
-{
- VLC_UNUSED(p_data); VLC_UNUSED(oldval);
- vout_thread_t *p_vout = (vout_thread_t *)p_this;
- var_Set( p_vout->p_sys->p_vout, psz_var, newval );
- return VLC_SUCCESS;
+ return var_SetCoords( p_vout, psz_var, x, y );
}
static void FilterPlanar( vout_thread_t *p_vout,
}
break;
- case TRANSFORM_MODE_HFLIP:
+ case TRANSFORM_MODE_VFLIP:
for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
{
uint8_t *p_in = p_pic->p[i_index].p_pixels;
p_in_end -= p_pic->p[i_index].i_pitch;
vlc_memcpy( p_out, p_in_end,
p_pic->p[i_index].i_visible_pitch );
- p_out += p_pic->p[i_index].i_pitch;
+ p_out += p_outpic->p[i_index].i_pitch;
}
}
break;
- case TRANSFORM_MODE_VFLIP:
+ case TRANSFORM_MODE_HFLIP:
for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
{
uint8_t *p_in = p_pic->p[i_index].p_pixels;
}
p_in += p_pic->p[i_index].i_pitch;
+ p_out += p_outpic->p[i_index].i_pitch
+ - p_outpic->p[i_index].i_visible_pitch;
}
}
break;
switch( p_vout->p_sys->i_mode )
{
- case TRANSFORM_MODE_HFLIP:
+ case TRANSFORM_MODE_VFLIP:
/* Fall back on the default implementation */
FilterPlanar( p_vout, p_pic, p_outpic );
return;
}
break;
- case TRANSFORM_MODE_VFLIP:
+ case TRANSFORM_MODE_HFLIP:
for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
{
uint8_t *p_in = p_pic->p[i_index].p_pixels;
}
p_in += p_pic->p[i_index].i_pitch;
+ p_out += p_outpic->p[i_index].i_pitch
+ - p_outpic->p[i_index].i_visible_pitch;
}
}
break;