Commit 7a5a63a7 authored by Antoine Cellerier's avatar Antoine Cellerier

Motion control interface can now be used with the rotate video filter. (Should...

Motion control interface can now be used with the rotate video filter. (Should be usefull when watching videos on a boat i guess ... :) ) Command line: vlc --control motion --motion-use-rotate --video-filter rotate <the video>

parent 4963328e
...@@ -42,8 +42,9 @@ struct intf_sys_t ...@@ -42,8 +42,9 @@ struct intf_sys_t
{ {
enum { NO_SENSOR, HDAPS_SENSOR, AMS_SENSOR } sensor; enum { NO_SENSOR, HDAPS_SENSOR, AMS_SENSOR } sensor;
int i_last_x, i_calibrate; int i_calibrate;
int i_threshold;
vlc_bool_t b_use_rotate;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -55,6 +56,8 @@ static void Close ( vlc_object_t * ); ...@@ -55,6 +56,8 @@ static void Close ( vlc_object_t * );
static void RunIntf( intf_thread_t *p_intf ); static void RunIntf( intf_thread_t *p_intf );
static int GetOrientation( intf_thread_t *p_intf ); static int GetOrientation( intf_thread_t *p_intf );
#define USE_ROTATE_TEXT N_("Use the rotate video filter instead of transform")
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
...@@ -63,6 +66,9 @@ vlc_module_begin(); ...@@ -63,6 +66,9 @@ vlc_module_begin();
set_category( CAT_INTERFACE ); set_category( CAT_INTERFACE );
set_description( _("motion control interface") ); set_description( _("motion control interface") );
add_bool( "motion-use-rotate", 0, NULL,
USE_ROTATE_TEXT, USE_ROTATE_TEXT, VLC_FALSE );
set_capability( "interface", 0 ); set_capability( "interface", 0 );
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
...@@ -112,6 +118,13 @@ int Open ( vlc_object_t *p_this ) ...@@ -112,6 +118,13 @@ int Open ( vlc_object_t *p_this )
p_intf->pf_run = RunIntf; p_intf->pf_run = RunIntf;
p_intf->p_sys->b_use_rotate = config_GetInt( p_intf, "motion-use-rotate" );
if( p_intf->p_sys->b_use_rotate )
{
var_Create( p_intf->p_libvlc, "rotate_angle", VLC_VAR_INTEGER );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -145,6 +158,17 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -145,6 +158,17 @@ static void RunIntf( intf_thread_t *p_intf )
i_x = GetOrientation( p_intf ); i_x = GetOrientation( p_intf );
if( p_intf->p_sys->b_use_rotate )
{
if( i_oldx != i_x )
{
var_SetInteger( p_intf->p_libvlc, "rotate_angle",
((360+i_x/2)%360) );
i_oldx = i_x;
}
continue;
}
if( i_x < -HIGH_THRESHOLD && i_oldx > -LOW_THRESHOLD ) if( i_x < -HIGH_THRESHOLD && i_oldx > -LOW_THRESHOLD )
{ {
b_change = VLC_TRUE; b_change = VLC_TRUE;
......
...@@ -42,6 +42,10 @@ static void Destroy ( vlc_object_t * ); ...@@ -42,6 +42,10 @@ static void Destroy ( vlc_object_t * );
static picture_t *Filter( filter_t *, picture_t * ); static picture_t *Filter( filter_t *, picture_t * );
static int RotateCallback( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval,
void *p_data );
#define ANGLE_TEXT N_("Angle in degrees") #define ANGLE_TEXT N_("Angle in degrees")
#define ANGLE_LONGTEXT N_("Angle in degrees (0 to 359)") #define ANGLE_LONGTEXT N_("Angle in degrees (0 to 359)")
...@@ -108,6 +112,12 @@ static int Create( vlc_object_t *p_this ) ...@@ -108,6 +112,12 @@ static int Create( vlc_object_t *p_this )
FILTER_PREFIX "angle" ); FILTER_PREFIX "angle" );
p_filter->p_sys->last_date = 0; p_filter->p_sys->last_date = 0;
var_Create( p_filter->p_libvlc, "rotate_angle", VLC_VAR_INTEGER );
var_SetInteger( p_filter->p_libvlc, "rotate_angle",
p_filter->p_sys->i_angle );
var_AddCallback( p_filter->p_libvlc,
"rotate_angle", RotateCallback, p_filter->p_sys );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -119,6 +129,9 @@ static int Create( vlc_object_t *p_this ) ...@@ -119,6 +129,9 @@ static int Create( vlc_object_t *p_this )
static void Destroy( vlc_object_t *p_this ) static void Destroy( vlc_object_t *p_this )
{ {
filter_t *p_filter = (filter_t *)p_this; filter_t *p_filter = (filter_t *)p_this;
var_DelCallback( p_filter->p_libvlc,
"rotate_angle", RotateCallback, p_filter->p_sys );
free( p_filter->p_sys ); free( p_filter->p_sys );
} }
...@@ -176,10 +189,12 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -176,10 +189,12 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{ {
int i_line_orig, i_col_orig; int i_line_orig, i_col_orig;
i_line_orig = (int)( f_cos * (double)(i_line-i_line_center) i_line_orig = (int)( f_cos * (double)(i_line-i_line_center)
+ f_sin * (double)(i_col-i_col_center) ) + f_sin * (double)(i_col-i_col_center)
+ 0.5 )
+ i_line_center; + i_line_center;
i_col_orig = (int)(-f_sin * (double)(i_line-i_line_center) i_col_orig = (int)(-f_sin * (double)(i_line-i_line_center)
+ f_cos * (double)(i_col-i_col_center) ) + f_cos * (double)(i_col-i_col_center)
+ 0.5 )
+ i_col_center; + i_col_center;
if( 0 <= i_line_orig && i_line_orig < i_num_lines if( 0 <= i_line_orig && i_line_orig < i_num_lines
...@@ -208,3 +223,16 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -208,3 +223,16 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
return p_outpic; return p_outpic;
} }
static int RotateCallback( 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( !strcmp( psz_var, "rotate_angle" ) )
{
p_sys->i_angle = newval.i_int;
}
return VLC_SUCCESS;
}
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