mirror of
https://github.com/mpv-player/mpv
synced 2024-12-18 21:06:00 +00:00
Implement setting gain control for video devices (usually webcams)
in v4l2 tv:// driver. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24573 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
04586de1dd
commit
fdb78c2bea
@ -1854,6 +1854,11 @@ These options set parameters of the mixer on the video capture card.
|
|||||||
They will have no effect, if your card does not have one.
|
They will have no effect, if your card does not have one.
|
||||||
For v4l2 50 maps to the default value of the
|
For v4l2 50 maps to the default value of the
|
||||||
control, as reported by the driver.
|
control, as reported by the driver.
|
||||||
|
.IPs "gain=<0\-100> (v4l2)"
|
||||||
|
Set gain control for video devices (usually webcams) to the desired
|
||||||
|
value and switch off automatic control.
|
||||||
|
A value of 0 enables automatic control.
|
||||||
|
If this option is omitted, gain control will not be modified.
|
||||||
.IPs immediatemode=<bool>
|
.IPs immediatemode=<bool>
|
||||||
A value of 0 means capture and buffer audio and video together
|
A value of 0 means capture and buffer audio and video together
|
||||||
(default for MEncoder).
|
(default for MEncoder).
|
||||||
|
@ -436,6 +436,7 @@ m_option_t tvopts_conf[]={
|
|||||||
{"contrast", &stream_tv_defaults.contrast, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
|
{"contrast", &stream_tv_defaults.contrast, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
|
||||||
{"hue", &stream_tv_defaults.hue, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
|
{"hue", &stream_tv_defaults.hue, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
|
||||||
{"saturation", &stream_tv_defaults.saturation, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
|
{"saturation", &stream_tv_defaults.saturation, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL},
|
||||||
|
{"gain", &stream_tv_defaults.gain, CONF_TYPE_INT, CONF_RANGE, -1, 100, NULL},
|
||||||
#if defined(HAVE_TV_V4L) || defined(HAVE_TV_V4L2)
|
#if defined(HAVE_TV_V4L) || defined(HAVE_TV_V4L2)
|
||||||
{"amode", &stream_tv_defaults.amode, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
|
{"amode", &stream_tv_defaults.amode, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
|
||||||
{"volume", &stream_tv_defaults.volume, CONF_TYPE_INT, CONF_RANGE, 0, 65535, NULL},
|
{"volume", &stream_tv_defaults.volume, CONF_TYPE_INT, CONF_RANGE, 0, 65535, NULL},
|
||||||
|
@ -72,6 +72,7 @@ tv_param_t stream_tv_defaults = {
|
|||||||
0, //contrast
|
0, //contrast
|
||||||
0, //hue
|
0, //hue
|
||||||
0, //saturation
|
0, //saturation
|
||||||
|
-1, //gain
|
||||||
NULL, //tdevice
|
NULL, //tdevice
|
||||||
0, //tformat
|
0, //tformat
|
||||||
100, //tpage
|
100, //tpage
|
||||||
|
@ -759,6 +759,10 @@ no_audio:
|
|||||||
tv_set_color_options(tvh, TV_COLOR_SATURATION, tvh->tv_param->saturation);
|
tv_set_color_options(tvh, TV_COLOR_SATURATION, tvh->tv_param->saturation);
|
||||||
tv_set_color_options(tvh, TV_COLOR_CONTRAST, tvh->tv_param->contrast);
|
tv_set_color_options(tvh, TV_COLOR_CONTRAST, tvh->tv_param->contrast);
|
||||||
|
|
||||||
|
if(tvh->tv_param->gain!=-1)
|
||||||
|
if(funcs->control(tvh->priv,TVI_CONTROL_VID_SET_GAIN,&tvh->tv_param->gain)!=TVI_CONTROL_TRUE)
|
||||||
|
mp_msg(MSGT_TV,MSGL_WARN,"Unable to set gain control!\n");
|
||||||
|
|
||||||
funcs->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);
|
funcs->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);
|
||||||
|
|
||||||
return demuxer;
|
return demuxer;
|
||||||
|
@ -47,6 +47,7 @@ typedef struct tv_param_s {
|
|||||||
int contrast;
|
int contrast;
|
||||||
int hue;
|
int hue;
|
||||||
int saturation;
|
int saturation;
|
||||||
|
int gain;
|
||||||
char *tdevice; ///< teletext device
|
char *tdevice; ///< teletext device
|
||||||
int tformat; ///< teletext display format
|
int tformat; ///< teletext display format
|
||||||
int tpage; ///< start teletext page
|
int tpage; ///< start teletext page
|
||||||
@ -151,6 +152,8 @@ typedef struct {
|
|||||||
#define TVI_CONTROL_VID_SET_CONTRAST 0x11c
|
#define TVI_CONTROL_VID_SET_CONTRAST 0x11c
|
||||||
#define TVI_CONTROL_VID_GET_PICTURE 0x11d
|
#define TVI_CONTROL_VID_GET_PICTURE 0x11d
|
||||||
#define TVI_CONTROL_VID_SET_PICTURE 0x11e
|
#define TVI_CONTROL_VID_SET_PICTURE 0x11e
|
||||||
|
#define TVI_CONTROL_VID_SET_GAIN 0x11f
|
||||||
|
#define TVI_CONTROL_VID_GET_GAIN 0x120
|
||||||
|
|
||||||
/* TUNER controls */
|
/* TUNER controls */
|
||||||
#define TVI_CONTROL_TUN_GET_FREQ 0x201
|
#define TVI_CONTROL_TUN_GET_FREQ 0x201
|
||||||
|
@ -478,7 +478,6 @@ static int set_mute(priv_t *priv, int value)
|
|||||||
*/
|
*/
|
||||||
static int set_control(priv_t *priv, struct v4l2_control *control, int val_signed) {
|
static int set_control(priv_t *priv, struct v4l2_control *control, int val_signed) {
|
||||||
struct v4l2_queryctrl qctrl;
|
struct v4l2_queryctrl qctrl;
|
||||||
|
|
||||||
qctrl.id = control->id;
|
qctrl.id = control->id;
|
||||||
if (ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
|
if (ioctl(priv->video_fd, VIDIOC_QUERYCTRL, &qctrl) < 0) {
|
||||||
mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query control failed: %s\n",
|
mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl query control failed: %s\n",
|
||||||
@ -806,6 +805,40 @@ static int control(priv_t *priv, int cmd, void *arg)
|
|||||||
control.id = V4L2_CID_SATURATION;
|
control.id = V4L2_CID_SATURATION;
|
||||||
control.value = *(int *)arg;
|
control.value = *(int *)arg;
|
||||||
return set_control(priv, &control, 1);
|
return set_control(priv, &control, 1);
|
||||||
|
case TVI_CONTROL_VID_GET_GAIN:
|
||||||
|
{
|
||||||
|
|
||||||
|
control.id = V4L2_CID_AUTOGAIN;
|
||||||
|
if(get_control(priv,&control,0)!=TVI_CONTROL_TRUE)
|
||||||
|
return TVI_CONTROL_FALSE;
|
||||||
|
|
||||||
|
if(control.value){ //Auto Gain control is enabled
|
||||||
|
*(int*)arg=0;
|
||||||
|
return TVI_CONTROL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Manual Gain control
|
||||||
|
control.id = V4L2_CID_GAIN;
|
||||||
|
if(get_control(priv,&control,0)!=TVI_CONTROL_TRUE)
|
||||||
|
return TVI_CONTROL_FALSE;
|
||||||
|
|
||||||
|
*(int*)arg=control.value?control.value:1;
|
||||||
|
|
||||||
|
return TVI_CONTROL_TRUE;
|
||||||
|
}
|
||||||
|
case TVI_CONTROL_VID_SET_GAIN:
|
||||||
|
{
|
||||||
|
//value==0 means automatic gain control
|
||||||
|
int value=*(int*)arg;
|
||||||
|
|
||||||
|
if (value < 0 || value>100)
|
||||||
|
return TVI_CONTROL_FALSE;
|
||||||
|
|
||||||
|
control.id=value?V4L2_CID_GAIN:V4L2_CID_AUTOGAIN;
|
||||||
|
control.value=value?value:1;
|
||||||
|
|
||||||
|
return set_control(priv,&control,0);
|
||||||
|
}
|
||||||
case TVI_CONTROL_VID_GET_CONTRAST:
|
case TVI_CONTROL_VID_GET_CONTRAST:
|
||||||
control.id = V4L2_CID_CONTRAST;
|
control.id = V4L2_CID_CONTRAST;
|
||||||
if (get_control(priv, &control, 1) == TVI_CONTROL_TRUE) {
|
if (get_control(priv, &control, 1) == TVI_CONTROL_TRUE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user