[vlc-commits] viewpoint: add vlc_viewpoint_clip

Thomas Guillem git at videolan.org
Tue Jul 25 16:42:21 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jul 24 16:30:12 2017 +0200| [26f09915529066a179446ed76a07bb6f630cd2ac] | committer: Thomas Guillem

viewpoint: add vlc_viewpoint_clip

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=26f09915529066a179446ed76a07bb6f630cd2ac
---

 include/vlc_viewpoint.h | 11 +++++++++++
 src/input/input.c       |  8 +-------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/vlc_viewpoint.h b/include/vlc_viewpoint.h
index 8c1b739e1f..cf0191334a 100644
--- a/include/vlc_viewpoint.h
+++ b/include/vlc_viewpoint.h
@@ -23,6 +23,8 @@
 
 #include <vlc_common.h>
 
+#include <math.h>
+
 /**
  * \defgroup output Output
  * \ingroup output
@@ -52,6 +54,15 @@ static inline void vlc_viewpoint_init( vlc_viewpoint_t *p_vp )
     p_vp->fov = FIELD_OF_VIEW_DEGREES_DEFAULT;
 }
 
+static inline void vlc_viewpoint_clip( vlc_viewpoint_t *p_vp )
+{
+    p_vp->yaw = fmodf( p_vp->yaw, 360.f );
+    p_vp->pitch = fmodf( p_vp->pitch, 360.f );
+    p_vp->roll = fmodf( p_vp->roll, 360.f );
+    p_vp->fov = VLC_CLIP( p_vp->fov, FIELD_OF_VIEW_DEGREES_MIN,
+                          FIELD_OF_VIEW_DEGREES_MAX );
+}
+
 /**@}*/
 
 #endif /* VLC_VIEWPOINT_H_ */
diff --git a/src/input/input.c b/src/input/input.c
index b6bde6f942..dc9213eb03 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -33,7 +33,6 @@
 
 #include <limits.h>
 #include <assert.h>
-#include <math.h>
 #include <sys/stat.h>
 
 #include "input_internal.h"
@@ -1960,12 +1959,7 @@ static bool Control( input_thread_t *p_input,
                 priv->viewpoint.fov   += p_vp->fov;
             }
 
-            priv->viewpoint.yaw = fmodf( priv->viewpoint.yaw, 360.f );
-            priv->viewpoint.pitch = fmodf( priv->viewpoint.pitch, 360.f );
-            priv->viewpoint.roll = fmodf( priv->viewpoint.roll, 360.f );
-            priv->viewpoint.fov = VLC_CLIP( priv->viewpoint.fov,
-                                            FIELD_OF_VIEW_DEGREES_MIN,
-                                            FIELD_OF_VIEW_DEGREES_MAX );
+            vlc_viewpoint_clip( &priv->viewpoint );
 
             vout_thread_t **pp_vout;
             size_t i_vout;



More information about the vlc-commits mailing list