[vlc-devel] [PATCH] core: parametric default Field Of View

Rémi Denis-Courmont remi at remlab.net
Tue Dec 6 12:45:18 CET 2016


Le mardi 6 décembre 2016, 12:18:25 Steve Lhomme a écrit :
> That's especially useful with libvlc devices that may have a wider/narrower
> display for VR.
> ---
>  include/vlc_vout.h  | 4 ++--
>  lib/media_player.c  | 2 +-
>  src/input/input.c   | 3 ++-
>  src/libvlc-module.c | 8 ++++++++
>  4 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/include/vlc_vout.h b/include/vlc_vout.h
> index d236d51..031f6b0 100644
> --- a/include/vlc_vout.h
> +++ b/include/vlc_vout.h
> @@ -92,10 +92,10 @@ struct vlc_viewpoint_t {
>      float fov;   /* field of view in degrees */
>  };
> 
> -static inline void vlc_viewpoint_init( vlc_viewpoint_t *p_vp )
> +static inline void vlc_viewpoint_init( vlc_viewpoint_t *p_vp, float fov )
>  {
>      p_vp->yaw = p_vp->pitch = p_vp->roll = 0.0f;
> -    p_vp->fov = FIELD_OF_VIEW_DEGREES_DEFAULT;
> +    p_vp->fov = fov;
>  }
> 
>  /**************************************************************************
> *** diff --git a/lib/media_player.c b/lib/media_player.c
> index ba7554c..152172d 100644
> --- a/lib/media_player.c
> +++ b/lib/media_player.c
> @@ -719,7 +719,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
>      if( aout != NULL )
>          input_resource_PutAout(mp->input.p_resource, aout);
> 
> -    vlc_viewpoint_init(&mp->viewpoint);
> +    vlc_viewpoint_init( &mp->viewpoint, var_InheritFloat( mp,
> "field-of-view" ) );

There does not seem to be any way for the application to actually change this, 
so then just pass the default value.

> 
>      var_Create (mp, "viewpoint", VLC_VAR_ADDRESS);
>      var_SetAddress( mp, "viewpoint", &mp->viewpoint );

Either this, or the code to modify the viewpoint in video.c is wrong. They are 
incompatible.

> diff --git a/src/input/input.c b/src/input/input.c
> index 118612c..d7d11df 100644
> --- a/src/input/input.c
> +++ b/src/input/input.c
> @@ -322,7 +322,8 @@ static input_thread_t *Create( vlc_object_t *p_parent,
> input_item_t *p_item, if (likely(p_viewpoint != NULL))
>          priv->viewpoint = *p_viewpoint;
>      else
> -        vlc_viewpoint_init( &priv->viewpoint );
> +        vlc_viewpoint_init( &priv->viewpoint,
> +                            var_InheritFloat( p_input, "field-of-view" ) );
> 
>      vlc_gc_incref( p_item ); /* Released in Destructor() */
>      priv->p_item = p_item;
> diff --git a/src/libvlc-module.c b/src/libvlc-module.c
> index 50ae1e0..b36693c 100644
> --- a/src/libvlc-module.c
> +++ b/src/libvlc-module.c
> @@ -433,6 +433,11 @@ static const char *const ppsz_pos_descriptions[] =
>      "aspect, or a float value (1.25, 1.3333, etc.) expressing pixel " \
>      "squareness.")
> 
> +#define VIEWPOINT_FOV_TEXT N_("Viewpoint Field Of View")
> +#define VIEWPOINT_FOV_LONGTEXT N_( \
> +    "This forces the default field of view for the displayed video, in "\
> +    "degrees." )
> +
>  #define AUTOSCALE_TEXT N_("Video Auto Scaling")
>  #define AUTOSCALE_LONGTEXT N_( \
>      "Let the video scale to fit a given window or fullscreen.")
> @@ -1595,6 +1600,9 @@ vlc_module_begin ()
>      add_string( "aspect-ratio", NULL,
>                  ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, false )
>          change_safe ()
> +    add_float( "field-of-view", FIELD_OF_VIEW_DEGREES_DEFAULT,
> +                VIEWPOINT_FOV_TEXT, VIEWPOINT_FOV_LONGTEXT, true )
> +        change_safe ()
>      add_bool( "autoscale", true, AUTOSCALE_TEXT, AUTOSCALE_LONGTEXT, false
> ) change_safe ()
>      add_obsolete_float( "scale" ) /* since 3.0.0 */

-- 
Rémi Denis-Courmont
http://www.remlab.net/


More information about the vlc-devel mailing list