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.
This commit is contained in:
David Schleef 2008-07-29 01:58:05 +00:00
parent f9749dea39
commit e98057986b
2 changed files with 20 additions and 12 deletions

View file

@ -1,3 +1,11 @@
2008-07-28 David Schleef <ds@schleef.org>
* 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.
2008-07-28 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* ext/ogg/gstoggdemux.c: (gst_ogg_demux_chain_peer),

View file

@ -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;