summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authoralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-04-21 12:47:37 +0000
committeralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-04-21 12:47:37 +0000
commit4d418c336f34b17a3b3e52a0ce32ee10e5bc8f3f (patch)
treefe0316e53f18ba4044e0b2b381677eaea7e508ea /libmpdemux
parentf865d5a17e6e5a53a121df0fe1cd1e2ddf9e9633 (diff)
downloadmpv-4d418c336f34b17a3b3e52a0ce32ee10e5bc8f3f.tar.bz2
mpv-4d418c336f34b17a3b3e52a0ce32ee10e5bc8f3f.tar.xz
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. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18174 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/tvi_v4l.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/libmpdemux/tvi_v4l.c b/libmpdemux/tvi_v4l.c
index 7678e69532..56a789fcb8 100644
--- a/libmpdemux/tvi_v4l.c
+++ b/libmpdemux/tvi_v4l.c
@@ -964,11 +964,6 @@ static int start(priv_t *priv)
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 @@ static int control(priv_t *priv, int cmd, void *arg)
}
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);