summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-20 16:11:07 +0200
committerwm4 <wm4@nowhere>2013-08-22 21:19:08 +0200
commitab3bafc7504d4dad50ccaa5ee2393f5ead4c9801 (patch)
tree2449563b883892cea99776c9cd88710defb6e7d9
parentd3f7248ca973547c2a367dec5f2488e55a9003e4 (diff)
downloadmpv-ab3bafc7504d4dad50ccaa5ee2393f5ead4c9801.tar.bz2
mpv-ab3bafc7504d4dad50ccaa5ee2393f5ead4c9801.tar.xz
vf_eq: fix behavior when changing parameters
Using -vf eq and changing brightness, contrast, etc. using key bindings with e.g. "add brightness 1" didn't work well: with step width 1, the property gets easily "stuck". This is a rounding problem: e.g. setting gamma to 3 would actually make it report that gamma is set to 2, so the "add" command will obviously never reach 3 with a step width of 1. Fix this by storing the parameters as integers. This was broken in cac7702. This commit effectively changed these properties to use the value as reported by vf_eq, instead of the previously set value for the "add" command. This was more robust, but not very correct either, so we keep the new behavior and make vf_eq report its parameters more accurately.
-rw-r--r--video/filter/vf_eq.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/video/filter/vf_eq.c b/video/filter/vf_eq.c
index 802b2f7048..9002d7504e 100644
--- a/video/filter/vf_eq.c
+++ b/video/filter/vf_eq.c
@@ -72,6 +72,8 @@ typedef struct vf_priv_s {
unsigned buf_w[3];
unsigned buf_h[3];
unsigned char *buf[3];
+
+ int gamma_i, contrast_i, brightness_i, saturation_i;
} vf_eq2_t;
@@ -381,18 +383,22 @@ int control (vf_instance_t *vf, int request, void *data)
if (strcmp (eq->item, "gamma") == 0) {
set_gamma (vf->priv, exp (log (8.0) * eq->value / 100.0));
+ vf->priv->gamma_i = eq->value;
return CONTROL_TRUE;
}
else if (strcmp (eq->item, "contrast") == 0) {
set_contrast (vf->priv, (1.0 / 100.0) * (eq->value + 100));
+ vf->priv->contrast_i = eq->value;
return CONTROL_TRUE;
}
else if (strcmp (eq->item, "brightness") == 0) {
set_brightness (vf->priv, (1.0 / 100.0) * eq->value);
+ vf->priv->brightness_i = eq->value;
return CONTROL_TRUE;
}
else if (strcmp (eq->item, "saturation") == 0) {
set_saturation (vf->priv, (double) (eq->value + 100) / 100.0);
+ vf->priv->saturation_i = eq->value;
return CONTROL_TRUE;
}
break;
@@ -400,19 +406,19 @@ int control (vf_instance_t *vf, int request, void *data)
case VFCTRL_GET_EQUALIZER:
eq = (vf_equalizer_t *) data;
if (strcmp (eq->item, "gamma") == 0) {
- eq->value = (int) (100.0 * log (vf->priv->gamma) / log (8.0));
+ eq->value = vf->priv->gamma_i;
return CONTROL_TRUE;
}
else if (strcmp (eq->item, "contrast") == 0) {
- eq->value = (int) (100.0 * vf->priv->contrast) - 100;
+ eq->value = vf->priv->contrast_i;
return CONTROL_TRUE;
}
else if (strcmp (eq->item, "brightness") == 0) {
- eq->value = (int) (100.0 * vf->priv->brightness);
+ eq->value = vf->priv->brightness_i;
return CONTROL_TRUE;
}
else if (strcmp (eq->item, "saturation") == 0) {
- eq->value = (int) (100.0 * vf->priv->saturation) - 100;
+ eq->value = vf->priv->saturation_i;
return CONTROL_TRUE;
}
break;
@@ -503,9 +509,13 @@ int vf_open(vf_instance_t *vf, char *args)
eq2->gamma_weight = par[7];
set_gamma (eq2, par[0]);
+ eq2->gamma_i = (int) (100.0 * log (vf->priv->gamma) / log (8.0));
set_contrast (eq2, par[1]);
+ eq2->contrast_i = (int) (100.0 * vf->priv->contrast) - 100;
set_brightness (eq2, par[2]);
+ eq2->brightness_i = (int) (100.0 * vf->priv->brightness);
set_saturation (eq2, par[3]);
+ eq2->saturation_i = (int) (100.0 * vf->priv->saturation) - 100;
}
return 1;