summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2013-02-21 15:01:15 -0500
committerTim-Philipp Müller <tim@centricular.net>2013-02-22 00:04:51 +0000
commita65fd146f8c42f7edb86d63d68a3e1a979d05c7e (patch)
tree45713bc39a6027ec3fc47b6e6cf3e54da65a591b
parent42d8b96f2d2824cf8126526e4966f2144e82e537 (diff)
alpha: Do not override the method with custom r/g/b values
Depending on the order g_object_set() calls aare made, the target r/g/b settings will override the method if set to green/blue. Change that so we do not use the target-r/g/b values unless the method is set to custom. https://bugzilla.gnome.org/show_bug.cgi?id=694374
-rw-r--r--gst/alpha/gstalpha.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/gst/alpha/gstalpha.c b/gst/alpha/gstalpha.c
index 473844e02..9e6617424 100644
--- a/gst/alpha/gstalpha.c
+++ b/gst/alpha/gstalpha.c
@@ -327,20 +327,6 @@ gst_alpha_set_property (GObject * object, guint prop_id,
&& (alpha->prefer_passthrough);
alpha->method = method;
- switch (alpha->method) {
- case ALPHA_METHOD_GREEN:
- alpha->target_r = 0;
- alpha->target_g = 255;
- alpha->target_b = 0;
- break;
- case ALPHA_METHOD_BLUE:
- alpha->target_r = 0;
- alpha->target_g = 0;
- alpha->target_b = 255;
- break;
- default:
- break;
- }
gst_alpha_set_process_function (alpha);
gst_alpha_init_params (alpha);
break;
@@ -2300,8 +2286,26 @@ gst_alpha_init_params_full (GstAlpha * alpha,
gfloat tmp;
gfloat tmp1, tmp2;
gfloat y;
+ guint target_r = alpha->target_r;
+ guint target_g = alpha->target_g;
+ guint target_b = alpha->target_b;
const gint *matrix;
+ switch (alpha->method) {
+ case ALPHA_METHOD_GREEN:
+ target_r = 0;
+ target_g = 255;
+ target_b = 0;
+ break;
+ case ALPHA_METHOD_BLUE:
+ target_r = 0;
+ target_g = 0;
+ target_b = 255;
+ break;
+ default:
+ break;
+ }
+
/* RGB->RGB: convert to SDTV YUV, chroma keying, convert back
* YUV->RGB: chroma keying, convert to RGB
* RGB->YUV: convert to YUV, chroma keying
@@ -2325,20 +2329,18 @@ gst_alpha_init_params_full (GstAlpha * alpha,
(alpha->out_sdtv) ? cog_rgb_to_ycbcr_matrix_8bit_sdtv :
cog_rgb_to_ycbcr_matrix_8bit_hdtv;
- y = (matrix[0] * ((gint) alpha->target_r) +
- matrix[1] * ((gint) alpha->target_g) +
- matrix[2] * ((gint) alpha->target_b) + matrix[3]) >> 8;
+ y = (matrix[0] * ((gint) target_r) +
+ matrix[1] * ((gint) target_g) +
+ matrix[2] * ((gint) target_b) + matrix[3]) >> 8;
/* Cb,Cr without offset here because the chroma keying
* works with them being in range [-128,127]
*/
tmp1 =
- (matrix[4] * ((gint) alpha->target_r) +
- matrix[5] * ((gint) alpha->target_g) +
- matrix[6] * ((gint) alpha->target_b)) >> 8;
+ (matrix[4] * ((gint) target_r) +
+ matrix[5] * ((gint) target_g) + matrix[6] * ((gint) target_b)) >> 8;
tmp2 =
- (matrix[8] * ((gint) alpha->target_r) +
- matrix[9] * ((gint) alpha->target_g) +
- matrix[10] * ((gint) alpha->target_b)) >> 8;
+ (matrix[8] * ((gint) target_r) +
+ matrix[9] * ((gint) target_g) + matrix[10] * ((gint) target_b)) >> 8;
kgl = sqrt (tmp1 * tmp1 + tmp2 * tmp2);
alpha->cb = 127 * (tmp1 / kgl);