summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-01-12 16:30:41 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-01-12 16:30:41 +0000
commita84db25ae46c3c90ec9801fcd7d26ea6d94d28b9 (patch)
treeff715c1f6633b46344b219d91be1ffbfa496958d /libvo
parent7172339ff9086f1f86937d06c89a4b348fdf2ed3 (diff)
downloadmpv-a84db25ae46c3c90ec9801fcd7d26ea6d94d28b9.tar.bz2
mpv-a84db25ae46c3c90ec9801fcd7d26ea6d94d28b9.tar.xz
Use a transform_color function to reduce code duplication
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25702 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/x11_common.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 66b7782371..bf92a37032 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -1959,6 +1959,17 @@ static int vo_gamma = 0;
static int vo_brightness = 0;
static int vo_contrast = 0;
+static int transform_color(float val,
+ float brightness, float contrast, float gamma) {
+ float s = pow(val, gamma);
+ s = (s - 0.5) * contrast + 0.5;
+ s += brightness;
+ if (s < 0)
+ s = 0;
+ if (s > 1)
+ s = 1;
+ return (unsigned short) (s * 65535);
+}
uint32_t vo_x11_set_equalizer(char *name, int value)
{
@@ -2001,34 +2012,9 @@ uint32_t vo_x11_set_equalizer(char *name, int value)
/* now recalculate the colormap using the newly set value */
for (k = 0; k < cm_size; k++)
{
- float s;
-
- s = pow(rf * k, gamma);
- s = (s - 0.5) * contrast + 0.5;
- s += brightness;
- if (s < 0)
- s = 0;
- if (s > 1)
- s = 1;
- cols[k].red = (unsigned short) (s * 65535);
-
- s = pow(gf * k, gamma);
- s = (s - 0.5) * contrast + 0.5;
- s += brightness;
- if (s < 0)
- s = 0;
- if (s > 1)
- s = 1;
- cols[k].green = (unsigned short) (s * 65535);
-
- s = pow(bf * k, gamma);
- s = (s - 0.5) * contrast + 0.5;
- s += brightness;
- if (s < 0)
- s = 0;
- if (s > 1)
- s = 1;
- cols[k].blue = (unsigned short) (s * 65535);
+ cols[k].red = transform_color(rf * k, brightness, contrast, gamma);
+ cols[k].green = transform_color(gf * k, brightness, contrast, gamma);
+ cols[k].blue = transform_color(bf * k, brightness, contrast, gamma);
}
XStoreColors(mDisplay, cmap, cols, cm_size);