diff options
author | David Schleef <ds@schleef.org> | 2008-07-29 01:58:05 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2008-07-29 01:58:05 +0000 |
commit | e98057986b7a55bc04346dd294c219c624982260 (patch) | |
tree | 7ebb09642231ff74f7f1fc3652804d7acc186e54 /sys | |
parent | f9749dea394c0ed5e1ef054641d4358cb6f376b0 (diff) |
sys/xvimage/xvimagesink.c: Fix rounding errors when converting colorbalance values between hardware and object proper...
Original commit message from CVS:
* sys/xvimage/xvimagesink.c:
Fix rounding errors when converting colorbalance values
between hardware and object property ranges. Partial
fix for #537889, however, there still seems to be a small
drift problem that could be totem's fault.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/xvimage/xvimagesink.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index df5c48b5..96c70edf 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -1049,16 +1049,13 @@ gst_xvimagesink_update_colorbalance (GstXvImageSink * xvimagesink) convert_coef = (channel->max_value - channel->min_value) / 2000.0; if (g_ascii_strcasecmp (channel->label, "XV_HUE") == 0) { - value = (xvimagesink->hue + 1000) * convert_coef + channel->min_value; + value = xvimagesink->hue; } else if (g_ascii_strcasecmp (channel->label, "XV_SATURATION") == 0) { - value = (xvimagesink->saturation + 1000) * convert_coef + - channel->min_value; + value = xvimagesink->saturation; } else if (g_ascii_strcasecmp (channel->label, "XV_CONTRAST") == 0) { - value = (xvimagesink->contrast + 1000) * convert_coef + - channel->min_value; + value = xvimagesink->contrast; } else if (g_ascii_strcasecmp (channel->label, "XV_BRIGHTNESS") == 0) { - value = (xvimagesink->brightness + 1000) * convert_coef + - channel->min_value; + value = xvimagesink->brightness; } else { g_warning ("got an unknown channel %s", channel->label); g_object_unref (channel); @@ -1070,8 +1067,11 @@ gst_xvimagesink_update_colorbalance (GstXvImageSink * xvimagesink) prop_atom = XInternAtom (xvimagesink->xcontext->disp, channel->label, True); if (prop_atom != None) { + int xv_value; + xv_value = + floor (0.5 + (value + 1000) * convert_coef + channel->min_value); XvSetPortAttribute (xvimagesink->xcontext->disp, - xvimagesink->xcontext->xv_port_id, prop_atom, value); + xvimagesink->xcontext->xv_port_id, prop_atom, xv_value); } g_mutex_unlock (xvimagesink->x_lock); @@ -1765,8 +1765,8 @@ gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink) XvGetPortAttribute (xcontext->disp, xcontext->xv_port_id, prop_atom, &val); /* Normalize val to [-1000, 1000] */ - val = -1000 + 2000 * (val - channel->min_value) / - (channel->max_value - channel->min_value); + val = floor (0.5 + -1000 + 2000 * (val - channel->min_value) / + (double) (channel->max_value - channel->min_value)); if (!g_ascii_strcasecmp (channels[i], "XV_HUE")) xvimagesink->hue = val; @@ -2659,8 +2659,8 @@ gst_xvimagesink_colorbalance_set_value (GstColorBalance * balance, xvimagesink->cb_changed = TRUE; /* Normalize val to [-1000, 1000] */ - value = -1000 + 2000 * (value - channel->min_value) / - (channel->max_value - channel->min_value); + value = floor (0.5 + -1000 + 2000 * (value - channel->min_value) / + (double) (channel->max_value - channel->min_value)); if (g_ascii_strcasecmp (channel->label, "XV_HUE") == 0) { xvimagesink->hue = value; |