[vlc-devel] [PATCH] modules/video_filter/rotate.c: add pf_video_mouse input filter

Alexandre Janniaux ajanni at videolabs.io
Wed Nov 25 10:27:06 CET 2020


Hi,

We usually write patch targetting 4.0, and only then eventually
backport to 3.0 branch, except if it only concerns 3.0 branch. ;)

Thanks for your work, this looks great though I haven't review yet!

Regards,
--
Alexandre Janniaux
Videolabs

On Wed, Nov 25, 2020 at 09:08:59AM +0000, Yuri Sevatz wrote:
> Please disregard thread -- I was trying to get both a VLC-master and a VLC-3.0 review going in parallel.
>
> (See follow-up thread.  Still learning!)
> ________________________________
> From: Yuri Sevatz <yuri_sevatz at hotmail.com>
> Sent: Wednesday, November 25, 2020 3:42 AM
> To: vlc-devel at videolan.org <vlc-devel at videolan.org>
> Cc: Yuri Sevatz <yuri_sevatz at hotmail.com>
> Subject: [PATCH] modules/video_filter/rotate.c: add pf_video_mouse input filter
>
> Add input rotation for mouse events in the rotate video filter.
>
> Previously the rotate video filter would not rotate mouse events,
> which would cause confusion if another video filter taking mouse
> input was chained before rotate (e.g. zoom, puzzle, etc), and
> clicks headed for those in-filter actions would have to go to
> their pre-rotated positions in order for VLC to accept them.
>
> Signed-off-by: Yuri Sevatz <yuri_sevatz at hotmail.com>
> ---
>  modules/video_filter/rotate.c | 40 +++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
>
> diff --git a/modules/video_filter/rotate.c b/modules/video_filter/rotate.c
> index 84e66b0249..83844cbfc5 100644
> --- a/modules/video_filter/rotate.c
> +++ b/modules/video_filter/rotate.c
> @@ -36,6 +36,7 @@
>  #include <vlc_plugin.h>
>  #include <vlc_atomic.h>
>  #include <vlc_filter.h>
> +#include <vlc_mouse.h>
>  #include <vlc_picture.h>
>  #include "filter_picture.h"
>  #include "../control/motionlib.h"
> @@ -46,6 +47,8 @@
>  static int  Create    ( vlc_object_t * );
>  static void Destroy   ( vlc_object_t * );
>
> +static int Mouse( filter_t *p_filter, vlc_mouse_t *p_mouse,
> +                  const vlc_mouse_t *p_old, const vlc_mouse_t *p_new );
>  static picture_t *Filter( filter_t *, picture_t * );
>  static picture_t *FilterPacked( filter_t *, picture_t * );
>
> @@ -149,6 +152,9 @@ static int Create( vlc_object_t *p_this )
>              return VLC_EGENERIC;
>      }
>
> +    /* Add mouse filter */
> +    p_filter->pf_video_mouse = Mouse;
> +
>      /* Allocate structure */
>      p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
>      if( p_filter->p_sys == NULL )
> @@ -198,6 +204,40 @@ static void Destroy( vlc_object_t *p_this )
>      free( p_sys );
>  }
>
> +/*****************************************************************************
> + *
> + *****************************************************************************/
> +static int Mouse( filter_t *p_filter, vlc_mouse_t *p_mouse,
> +                  const vlc_mouse_t *p_old, const vlc_mouse_t *p_new )
> +{
> +    VLC_UNUSED( p_old );
> +
> +    const video_format_t *p_fmt = &p_filter->fmt_out.video;
> +    filter_sys_t *p_sys = p_filter->p_sys;
> +
> +    *p_mouse = *p_new;
> +
> +    if( p_sys->p_motion != NULL )
> +    {
> +        int i_angle = motion_get_angle( p_sys->p_motion );
> +        store_trigo( p_sys, i_angle / 20.f );
> +    }
> +
> +    int i_sin, i_cos;
> +    fetch_trigo( p_sys, &i_sin, &i_cos );
> +
> +    p_mouse->i_x = ( p_fmt->i_visible_width >> 1 );
> +    p_mouse->i_y = ( p_fmt->i_visible_height >> 1 );
> +
> +    const int i_rx = ( p_new->i_x - p_mouse->i_x );
> +    const int i_ry = ( p_new->i_y - p_mouse->i_y );
> +
> +    p_mouse->i_x += ( ( i_rx * i_cos - i_ry * i_sin )>> 12 );
> +    p_mouse->i_y += ( ( i_rx * i_sin + i_ry * i_cos )>> 12 );
> +
> +    return VLC_SUCCESS;
> +}
> +
>  /*****************************************************************************
>   *
>   *****************************************************************************/
> --
> 2.29.2
>

> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list