mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
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
This commit is contained in:
parent
42d8b96f2d
commit
a65fd146f8
1 changed files with 25 additions and 23 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue