diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-10-06 16:54:16 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-10-06 16:54:16 +0200 |
commit | 59720fd42a1bcaf6b31076b7c302be006d9b7bad (patch) | |
tree | 38145d2ff15224c63b41286dbcf09fd2c451489b /gst/coloreffects | |
parent | 10e0187df1aa78c7259e8758dcea39d3886c1321 (diff) | |
download | gstreamer-plugins-bad-59720fd42a1bcaf6b31076b7c302be006d9b7bad.tar.gz |
chromahold: Fix hue calculation for red colors
Also make the calculation much more accurate...
Diffstat (limited to 'gst/coloreffects')
-rw-r--r-- | gst/coloreffects/gstchromahold.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/gst/coloreffects/gstchromahold.c b/gst/coloreffects/gstchromahold.c index d2770e855..3e8c1fa8f 100644 --- a/gst/coloreffects/gstchromahold.c +++ b/gst/coloreffects/gstchromahold.c @@ -52,7 +52,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_chroma_hold_debug); #define DEFAULT_TARGET_R 255 #define DEFAULT_TARGET_G 0 #define DEFAULT_TARGET_B 0 -#define DEFAULT_TOLERANCE 2 +#define DEFAULT_TOLERANCE 30 enum { @@ -301,23 +301,24 @@ gst_chroma_hold_set_caps (GstBaseTransform * btrans, static inline gint rgb_to_hue (gint r, gint g, gint b) { - gint m, M, C, h; + gint m, M, C, C2, h; m = MIN (MIN (r, g), b); M = MAX (MAX (r, g), b); C = M - m; + C2 = C >> 1; if (C == 0) { return G_MAXUINT; } else if (M == r) { - h = ((g - b) / C) % 6; + h = ((256 * 60 * (g - b) + C2) / C); } else if (M == g) { - h = ((b - r) / C) + 2; - } else { /* if (M == b) */ - - h = ((r - g) / C) + 4; + h = ((256 * 60 * (b - r) + C2) / C) + 120 * 256; + } else { + /* if (M == b) */ + h = ((256 * 60 * (r - g) + C2) / C) + 240 * 256; } - h = 60 * h; + h >>= 8; if (h >= 360) h -= 360; |