From f7756121ee35cb54b217218f9a5b07310b69625c Mon Sep 17 00:00:00 2001 From: henry Date: Sun, 23 Mar 2003 15:05:14 +0000 Subject: color equalizer for tv input git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9664 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/tv.c | 10 ++++++++++ libmpdemux/tv.h | 4 ++++ libmpdemux/tvi_v4l.c | 14 ++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) (limited to 'libmpdemux') diff --git a/libmpdemux/tv.c b/libmpdemux/tv.c index 2f4681f205..5a173d29f4 100644 --- a/libmpdemux/tv.c +++ b/libmpdemux/tv.c @@ -71,6 +71,10 @@ int tv_param_alsa = 0; #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 @@ int demux_open_tv(demuxer_t *demuxer) /* 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; diff --git a/libmpdemux/tv.h b/libmpdemux/tv.h index 0ad4680833..18ef4c52e6 100644 --- a/libmpdemux/tv.h +++ b/libmpdemux/tv.h @@ -42,6 +42,10 @@ extern int tv_param_alsa; #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 { diff --git a/libmpdemux/tvi_v4l.c b/libmpdemux/tvi_v4l.c index 96e786c0f8..e68b638c8f 100644 --- a/libmpdemux/tvi_v4l.c +++ b/libmpdemux/tvi_v4l.c @@ -929,6 +929,12 @@ 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) { mp_msg(MSGT_TV, MSGL_DBG2, "\ndebug: control(priv=%p, cmd=%d, arg=%p)\n", @@ -1042,19 +1048,19 @@ static int control(priv_t *priv, int cmd, void *arg) } 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: -- cgit v1.2.3