changeset 18173:1acdeb017c9c

Implement getting colors. The mapping between MPlayer's gamma range (-100/100) and v4l's range (0-65535) had to be changed a bit to avoid rounding errors.
author albeu
date Fri, 21 Apr 2006 12:47:37 +0000
parents 90b62d7c0fca
children 0f897ffb95bc
files libmpdemux/tvi_v4l.c
diffstat 1 files changed, 24 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/tvi_v4l.c	Fri Apr 21 12:45:18 2006 +0000
+++ b/libmpdemux/tvi_v4l.c	Fri Apr 21 12:47:37 2006 +0000
@@ -964,11 +964,6 @@
     return(1);
 }
 
-// 2nd order polynomial with p(-100)=0, p(100)=65535, p(0)=y0
-static int poly(int x, int y0)
-{
-    return ((65535-2*y0)*x*x+6553500*x+20000*y0)/20000;
-}
 
 static int control(priv_t *priv, int cmd, void *arg)
 {
@@ -1083,21 +1078,33 @@
 	    }
 	    return(TVI_CONTROL_TRUE);
 	case TVI_CONTROL_VID_SET_BRIGHTNESS:
-	    priv->picture.brightness = 65535*(*(int *)arg+100)/200;
-	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
-	    return(TVI_CONTROL_TRUE);
+	    priv->picture.brightness = (327*(*(int *)arg+100)) + 68;
+	    return control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
 	case TVI_CONTROL_VID_SET_HUE:
-	    priv->picture.hue = 65535*(*(int *)arg+100)/200;
-	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
-	    return(TVI_CONTROL_TRUE);
+	    priv->picture.hue = (327*(*(int *)arg+100)) + 68;
+	    return control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
 	case TVI_CONTROL_VID_SET_SATURATION:
-	    priv->picture.colour = 65535*(*(int *)arg+100)/200;
-	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
-	    return(TVI_CONTROL_TRUE);
+	    priv->picture.colour = (327*(*(int *)arg+100)) + 68;
+	    return control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
 	case TVI_CONTROL_VID_SET_CONTRAST:
-	    priv->picture.contrast = poly(*(int *)arg, 24576);
-	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
-	    return(TVI_CONTROL_TRUE);
+	    priv->picture.contrast = (327*(*(int *)arg+100)) + 68;
+	    return control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
+	case TVI_CONTROL_VID_GET_BRIGHTNESS:
+	    if(!control(priv, TVI_CONTROL_VID_GET_PICTURE, 0)) return 0;
+	    *(int*)arg = ((int)priv->picture.brightness-68)/327-100;
+	    return 1;
+	case TVI_CONTROL_VID_GET_HUE:
+	    if(!control(priv, TVI_CONTROL_VID_GET_PICTURE, 0)) return 0;
+	    *(int*)arg = ((int)priv->picture.hue-68)/327-100;
+	    return 1;
+	case TVI_CONTROL_VID_GET_SATURATION:
+	    if(!control(priv, TVI_CONTROL_VID_GET_PICTURE, 0)) return 0;
+	    *(int*)arg = ((int)priv->picture.colour-68)/327-100;
+	    return 1;
+	case TVI_CONTROL_VID_GET_CONTRAST:
+	    if(!control(priv, TVI_CONTROL_VID_GET_PICTURE, 0)) return 0;
+	    *(int*)arg = ((int)priv->picture.contrast-68)/327-100;
+	    return 1;
 	case TVI_CONTROL_VID_GET_FPS:
 	    *(float *)arg=priv->fps;
 	    return(TVI_CONTROL_TRUE);