changeset 9663:596ad944a65e

color equalizer for tv input
author henry
date Sun, 23 Mar 2003 15:05:14 +0000
parents 2ac95540dc55
children eb9660b1f782
files cfg-common.h libmpdemux/tv.c libmpdemux/tv.h libmpdemux/tvi_v4l.c
diffstat 4 files changed, 28 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-common.h	Sun Mar 23 12:59:09 2003 +0000
+++ b/cfg-common.h	Sun Mar 23 15:05:14 2003 +0000
@@ -277,6 +277,10 @@
 	{"outfmt", &tv_param_outfmt, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	{"fps", &tv_param_fps, CONF_TYPE_FLOAT, 0, 0, 100.0, NULL},
 	{"channels", &tv_param_channels, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
+	{"brightness", &tv_param_brightness, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
+	{"contrast", &tv_param_contrast, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
+	{"hue", &tv_param_hue, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
+	{"saturation", &tv_param_saturation, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
 #ifdef HAVE_TV_V4L
 	{"amode", &tv_param_amode, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
 	{"volume", &tv_param_volume, CONF_TYPE_INT, CONF_RANGE, 0, 65535, NULL},
--- a/libmpdemux/tv.c	Sun Mar 23 12:59:09 2003 +0000
+++ b/libmpdemux/tv.c	Sun Mar 23 15:05:14 2003 +0000
@@ -71,6 +71,10 @@
 #endif
 char* tv_param_adevice = NULL;
 #endif
+int tv_param_brightness = 0;
+int tv_param_contrast = 0;
+int tv_param_hue = 0;
+int tv_param_saturation = 0;
 
 /* ================== DEMUX_TV ===================== */
 /*
@@ -443,6 +447,12 @@
     /* set height */
     funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
 
+    /* set color eq */
+    tv_set_color_options(tvh, TV_COLOR_BRIGHTNESS, tv_param_brightness);
+    tv_set_color_options(tvh, TV_COLOR_HUE, tv_param_hue);
+    tv_set_color_options(tvh, TV_COLOR_SATURATION, tv_param_saturation);
+    tv_set_color_options(tvh, TV_COLOR_CONTRAST, tv_param_contrast);
+
     demuxer->video->sh = sh_video;
     sh_video->ds = demuxer->video;
     demuxer->video->id = 0;
--- a/libmpdemux/tv.h	Sun Mar 23 12:59:09 2003 +0000
+++ b/libmpdemux/tv.h	Sun Mar 23 15:05:14 2003 +0000
@@ -42,6 +42,10 @@
 #endif
 extern char* tv_param_adevice;
 #endif
+extern int tv_param_brightness;
+extern int tv_param_contrast;
+extern int tv_param_hue;
+extern int tv_param_saturation;
 
 typedef struct tvi_info_s
 {
--- a/libmpdemux/tvi_v4l.c	Sun Mar 23 12:59:09 2003 +0000
+++ b/libmpdemux/tvi_v4l.c	Sun Mar 23 15:05:14 2003 +0000
@@ -929,6 +929,12 @@
     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)
 {
     mp_msg(MSGT_TV, MSGL_DBG2, "\ndebug: control(priv=%p, cmd=%d, arg=%p)\n",
@@ -1042,19 +1048,19 @@
 	    }
 	    return(TVI_CONTROL_TRUE);
 	case TVI_CONTROL_VID_SET_BRIGHTNESS:
-	    priv->picture.brightness = (int)*(void **)arg;
+	    priv->picture.brightness = 65535*((int)*(void **)arg+100)/200;
 	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
 	    return(TVI_CONTROL_TRUE);
 	case TVI_CONTROL_VID_SET_HUE:
-	    priv->picture.hue = (int)*(void **)arg;
+	    priv->picture.hue = 65535*((int)*(void **)arg+100)/200;
 	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
 	    return(TVI_CONTROL_TRUE);
 	case TVI_CONTROL_VID_SET_SATURATION:
-	    priv->picture.colour = (int)*(void **)arg;
+	    priv->picture.colour = 65535*((int)*(void **)arg+100)/200;
 	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
 	    return(TVI_CONTROL_TRUE);
 	case TVI_CONTROL_VID_SET_CONTRAST:
-	    priv->picture.contrast = (int)*(void **)arg;
+	    priv->picture.contrast = poly((int)*(void **)arg, 24576);
 	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
 	    return(TVI_CONTROL_TRUE);
 	case TVI_CONTROL_VID_GET_FPS: