alpha: Remove some unneeded calculations and instance struct fields

And document the instance struct fields a bit better
This commit is contained in:
Sebastian Dröge 2010-03-19 18:18:08 +01:00
parent 6b0c535e8d
commit 46025bbd8f
2 changed files with 14 additions and 14 deletions

View file

@ -737,17 +737,17 @@ gst_alpha_chroma_key_i420 (const guint8 * src, guint8 * dest, gint width,
static void static void
gst_alpha_init_params (GstAlpha * alpha) gst_alpha_init_params (GstAlpha * alpha)
{ {
float kgl; gfloat kgl;
float tmp; gfloat tmp;
float tmp1, tmp2; gfloat tmp1, tmp2;
gfloat y;
const gint *matrix; const gint *matrix;
matrix = matrix =
(alpha->out_sdtv) ? cog_rgb_to_ycbcr_matrix_8bit_sdtv : (alpha->out_sdtv) ? cog_rgb_to_ycbcr_matrix_8bit_sdtv :
cog_rgb_to_ycbcr_matrix_8bit_hdtv; cog_rgb_to_ycbcr_matrix_8bit_hdtv;
alpha->y = y = (matrix[0] * ((gint) alpha->target_r) +
(matrix[0] * ((gint) alpha->target_r) +
matrix[1] * ((gint) alpha->target_g) + matrix[1] * ((gint) alpha->target_g) +
matrix[2] * ((gint) alpha->target_b) + matrix[3]) >> 8; matrix[2] * ((gint) alpha->target_b) + matrix[3]) >> 8;
/* Cb,Cr without offset here because the chroma keying /* Cb,Cr without offset here because the chroma keying
@ -766,8 +766,6 @@ gst_alpha_init_params (GstAlpha * alpha)
alpha->cb = 127 * (tmp1 / kgl); alpha->cb = 127 * (tmp1 / kgl);
alpha->cr = 127 * (tmp2 / kgl); alpha->cr = 127 * (tmp2 / kgl);
alpha->accept_angle_cos = cos (M_PI * alpha->angle / 180);
alpha->accept_angle_sin = sin (M_PI * alpha->angle / 180);
tmp = 15 * tan (M_PI * alpha->angle / 180); tmp = 15 * tan (M_PI * alpha->angle / 180);
tmp = MIN (tmp, 255); tmp = MIN (tmp, 255);
alpha->accept_angle_tg = tmp; alpha->accept_angle_tg = tmp;
@ -776,7 +774,7 @@ gst_alpha_init_params (GstAlpha * alpha)
alpha->accept_angle_ctg = tmp; alpha->accept_angle_ctg = tmp;
tmp = 1 / (kgl); tmp = 1 / (kgl);
alpha->one_over_kc = 255 * 2 * tmp - 255; alpha->one_over_kc = 255 * 2 * tmp - 255;
tmp = 15 * (float) (alpha->y) / kgl; tmp = 15 * y / kgl;
tmp = MIN (tmp, 255); tmp = MIN (tmp, 255);
alpha->kfgy_scale = tmp; alpha->kfgy_scale = tmp;
alpha->kg = MIN (kgl, 127); alpha->kg = MIN (kgl, 127);

View file

@ -60,11 +60,14 @@ struct _GstAlpha
{ {
GstVideoFilter parent; GstVideoFilter parent;
/* <private> */
/* caps */ /* caps */
GstVideoFormat in_format, out_format; GstVideoFormat in_format, out_format;
gint width, height; gint width, height;
gboolean in_sdtv, out_sdtv; gboolean in_sdtv, out_sdtv;
/* properties */
gdouble alpha; gdouble alpha;
guint target_r; guint target_r;
@ -75,21 +78,20 @@ struct _GstAlpha
gfloat angle; gfloat angle;
gfloat noise_level; gfloat noise_level;
guint noise_level2;
guint black_sensitivity; guint black_sensitivity;
guint white_sensitivity; guint white_sensitivity;
gfloat y; /* chroma color */ /* processing function */
void (*process) (const guint8 *src, guint8 *dest, gint width, gint height, GstAlpha *alpha);
/* precalculated values for chroma keying */
gint8 cb, cr; gint8 cb, cr;
gint8 kg; gint8 kg;
gfloat accept_angle_cos;
gfloat accept_angle_sin;
guint8 accept_angle_tg; guint8 accept_angle_tg;
guint8 accept_angle_ctg; guint8 accept_angle_ctg;
guint8 one_over_kc; guint8 one_over_kc;
guint8 kfgy_scale; guint8 kfgy_scale;
guint noise_level2;
void (*process) (const guint8 *src, guint8 *dest, gint width, gint height, GstAlpha *alpha);
}; };
struct _GstAlphaClass struct _GstAlphaClass