summaryrefslogtreecommitdiff
path: root/src/lib/util.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-10-08 15:37:04 +0100
committerCarl Hetherington <cth@carlh.net>2012-10-08 15:37:04 +0100
commit5f02ea34590cd6b796a6eaa55211abf5b36fd329 (patch)
tree2bf00f93ab0a73895f7aab6182df8f95d3373a4d /src/lib/util.h
parenta78f48e77516d64f568cd6ea7c35b7095264b78c (diff)
Hacks.
Diffstat (limited to 'src/lib/util.h')
-rw-r--r--src/lib/util.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/util.h b/src/lib/util.h
index 3eac06e97..ed13cd43c 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -165,4 +165,20 @@ private:
int _buffer_data;
};
+#define SCALEBITS 10
+#define ONE_HALF (1 << (SCALEBITS - 1))
+#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
+
+#define RGB_TO_Y_CCIR(r, g, b) \
+((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
+ FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
+
+#define RGB_TO_U_CCIR(r1, g1, b1, shift)\
+(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \
+ FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
+
+#define RGB_TO_V_CCIR(r1, g1, b1, shift)\
+(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
+ FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
+
#endif