changeset 2937:4307478ad922

added support for setting color values
author alex
date Fri, 16 Nov 2001 22:59:07 +0000
parents 53d168c38d29
children 757c3ab1a45a
files libmpdemux/tv.c libmpdemux/tv.h libmpdemux/tvi_v4l.c
diffstat 3 files changed, 128 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/tv.c	Fri Nov 16 22:54:36 2001 +0000
+++ b/libmpdemux/tv.c	Fri Nov 16 22:59:07 2001 +0000
@@ -284,4 +284,86 @@
 {
     return(tvh->functions->uninit(tvh->priv));
 }
+
+/* utilities for mplayer (not mencoder!!) */
+int tv_set_color_options(tvi_handle_t *tvh, int opt, int value)
+{
+    tvi_functions_t *funcs = tvh->functions;
+
+    switch(opt)
+    {
+	case TV_COLOR_BRIGHTNESS:
+	    if (value == 50)
+		value = 32768;
+	    if (value > 50)
+	    {
+		value *= 100;
+		value += 32768;
+	    }
+	    if (value < 50)
+	    {
+		int i;
+		value *= 100;
+		i = value;
+		value = 32768 - i;
+	    }
+	    funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value);
+	    break;
+	case TV_COLOR_HUE:
+	    if (value == 50)
+		value = 32768;
+	    if (value > 50)
+	    {
+		value *= 100;
+		value += 32768;
+	    }
+	    if (value < 50)
+	    {
+		int i;
+		value *= 100;
+		i = value;
+		value = 32768 - i;
+	    }
+	    funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value);
+	    break;
+	case TV_COLOR_SATURATION:
+	    if (value == 50)
+		value = 32512;
+	    if (value > 50)
+	    {
+		value *= 100;
+		value += 32512;
+	    }
+	    if (value < 50)
+	    {
+		int i;
+		value *= 100;
+		i = value;
+		value = 32512 - i;
+	    }
+	    funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value);
+	    break;
+	case TV_COLOR_CONTRAST:
+	    if (value == 50)
+		value = 27648;
+	    if (value > 50)
+	    {
+		value *= 100;
+		value += 27648;
+	    }
+	    if (value < 50)
+	    {
+		int i;
+		value *= 100;
+		i = value;
+		value = 27648 - i;
+	    }
+	    funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value);
+	    break;
+	default:
+	    mp_msg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt);
+    }
+    
+    return(1);
+}
 #endif /* USE_TV */
--- a/libmpdemux/tv.h	Fri Nov 16 22:54:36 2001 +0000
+++ b/libmpdemux/tv.h	Fri Nov 16 22:59:07 2001 +0000
@@ -78,6 +78,16 @@
 #define TVI_CONTROL_VID_GET_HEIGHT	0x112
 #define TVI_CONTROL_VID_CHK_HEIGHT	0x113
 #define TVI_CONTROL_VID_SET_HEIGHT	0x114
+#define TVI_CONTROL_VID_GET_BRIGHTNESS	0x115
+#define TVI_CONTROL_VID_SET_BRIGHTNESS	0x116
+#define TVI_CONTROL_VID_GET_HUE		0x117
+#define TVI_CONTROL_VID_SET_HUE		0x118
+#define TVI_CONTROL_VID_GET_SATURATION	0x119
+#define TVI_CONTROL_VID_SET_SATURATION	0x11a
+#define TVI_CONTROL_VID_GET_CONTRAST	0x11b
+#define TVI_CONTROL_VID_SET_CONTRAST	0x11c
+#define TVI_CONTROL_VID_GET_PICTURE	0x11d
+#define TVI_CONTROL_VID_SET_PICTURE	0x11e
 
 /* TUNER controls */
 #define TVI_CONTROL_TUN_GET_FREQ	0x201
@@ -101,4 +111,10 @@
 extern int tv_init(tvi_handle_t *tvh);
 extern int tv_uninit(tvi_handle_t *tvh);
 
+
+#define TV_COLOR_BRIGHTNESS	1
+#define TV_COLOR_HUE		2
+#define TV_COLOR_SATURATION	3
+#define TV_COLOR_CONTRAST	4
+
 #endif /* USE_TV */
--- a/libmpdemux/tvi_v4l.c	Fri Nov 16 22:54:36 2001 +0000
+++ b/libmpdemux/tvi_v4l.c	Fri Nov 16 22:59:07 2001 +0000
@@ -552,6 +552,36 @@
 	case TVI_CONTROL_VID_SET_HEIGHT:
 	    priv->height = (int)*(void **)arg;
 	    return(TVI_CONTROL_TRUE);
+	case TVI_CONTROL_VID_GET_PICTURE:
+	    if (ioctl(priv->fd, VIDIOCGPICT, &priv->picture) == -1)
+	    {
+		mp_msg(MSGT_TV, MSGL_ERR, "ioctl get picture failed: %s\n", strerror(errno));
+		return(TVI_CONTROL_FALSE);
+	    }
+	    return(TVI_CONTROL_TRUE);
+	case TVI_CONTROL_VID_SET_PICTURE:
+	    if (ioctl(priv->fd, VIDIOCSPICT, &priv->picture) == -1)
+	    {
+		mp_msg(MSGT_TV, MSGL_ERR, "ioctl get picture failed: %s\n", strerror(errno));
+		return(TVI_CONTROL_FALSE);
+	    }
+	    return(TVI_CONTROL_TRUE);
+	case TVI_CONTROL_VID_SET_BRIGHTNESS:
+	    priv->picture.brightness = (int)*(void **)arg;
+	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
+	    return(TVI_CONTROL_TRUE);
+	case TVI_CONTROL_VID_SET_HUE:
+	    priv->picture.hue = (int)*(void **)arg;
+	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
+	    return(TVI_CONTROL_TRUE);
+	case TVI_CONTROL_VID_SET_SATURATION:
+	    priv->picture.colour = (int)*(void **)arg;
+	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
+	    return(TVI_CONTROL_TRUE);
+	case TVI_CONTROL_VID_SET_CONTRAST:
+	    priv->picture.contrast = (int)*(void **)arg;
+	    control(priv, TVI_CONTROL_VID_SET_PICTURE, 0);
+	    return(TVI_CONTROL_TRUE);
 
 	/* ========== TUNER controls =========== */
 	case TVI_CONTROL_TUN_GET_FREQ: