[vlc-commits] vdpau: switch hue to float

Rémi Denis-Courmont git at videolan.org
Tue Aug 19 21:17:02 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Aug 19 21:56:01 2014 +0300| [eebb0e8313fb581498e34421ebbd212e332eae81] | committer: Rémi Denis-Courmont

vdpau: switch hue to float

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

 modules/hw/vdpau/adjust.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/modules/hw/vdpau/adjust.c b/modules/hw/vdpau/adjust.c
index d150579..0db8ee6 100644
--- a/modules/hw/vdpau/adjust.c
+++ b/modules/hw/vdpau/adjust.c
@@ -84,19 +84,22 @@ static int SaturationCallback(vlc_object_t *obj, const char *varname,
     return VLC_SUCCESS;
 }
 
-static float vlc_to_vdp_hue(int hue)
+static float vlc_to_vdp_hue(float hue)
 {
-    hue %= 360;
-    if (hue > 180)
-        hue -= 360;
-    return (float)hue * (float)(M_PI / 180.);
+    float dummy;
+
+    hue /= 360.f;
+    hue = modff(hue, &dummy);
+    if (hue > .5f)
+        hue -= 1.f;
+    return hue * (float)(2. * M_PI);
 }
 
 static int HueCallback(vlc_object_t *obj, const char *varname,
                               vlc_value_t prev, vlc_value_t cur, void *data)
 {
 
-    vlc_atomic_store_float(data, vlc_to_vdp_hue(cur.i_int));
+    vlc_atomic_store_float(data, vlc_to_vdp_hue(cur.f_float));
     (void) obj; (void) varname; (void) prev;
     return VLC_SUCCESS;
 }
@@ -158,7 +161,7 @@ static int Open(vlc_object_t *obj)
                     &sys->saturation);
     vlc_atomic_init_float(&sys->saturation, vlc_to_vdp_saturation(f));
 
-    i = var_CreateGetIntegerCommand(filter, "hue");
+    i = var_CreateGetFloatCommand(filter, "hue");
     var_AddCallback(filter, "hue", HueCallback, &sys->hue);
     vlc_atomic_init_float(&sys->hue, vlc_to_vdp_hue(i));
 



More information about the vlc-commits mailing list