viewpoint: add vlc_viewpoint_clip
authorThomas Guillem <thomas@gllm.fr>
Mon, 24 Jul 2017 14:30:12 +0000 (16:30 +0200)
committerThomas Guillem <thomas@gllm.fr>
Tue, 25 Jul 2017 14:40:51 +0000 (16:40 +0200)
include/vlc_viewpoint.h
src/input/input.c

index 8c1b739..cf01913 100644 (file)
@@ -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_ */
index b6bde6f..dc9213e 100644 (file)
@@ -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;