avfilter/vf_bilateral: remove unneeded multiplications

pull/373/head
Paul B Mahol 3 years ago
parent 7216458c96
commit f0ad40b525
  1. 16
      libavfilter/vf_bilateral.c

@ -186,11 +186,11 @@ static void bilateral_##name(BilateralContext *s, const uint8_t *ssrc, uint8_t *
*temp_factor_x++ = fc = inv_alpha_ + alpha_ * fp; \
fp = fc; \
} \
--temp_x; *temp_x = 0.5f*((*temp_x) + (*--in_x)); \
--temp_x; *temp_x = ((*temp_x) + (*--in_x)); \
tpr = *--texture_x; \
ypr = *in_x; \
\
--temp_factor_x; *temp_factor_x = 0.5f*((*temp_factor_x) + 1); \
--temp_factor_x; *temp_factor_x = ((*temp_factor_x) + 1); \
fp = 1; \
\
for (int x = width - 2; x >= 0; x--) { \
@ -200,13 +200,13 @@ static void bilateral_##name(BilateralContext *s, const uint8_t *ssrc, uint8_t *
float alpha_ = range_table[range_dist]; \
\
ycr = inv_alpha_ * (*--in_x) + alpha_ * ypr; \
--temp_x; *temp_x = 0.5f*((*temp_x) + ycr); \
--temp_x; *temp_x = ((*temp_x) + ycr); \
tpr = tcr; \
ypr = ycr; \
\
fc = inv_alpha_ + alpha_*fp; \
--temp_factor_x; \
*temp_factor_x = 0.5f*((*temp_factor_x) + fc); \
*temp_factor_x = ((*temp_factor_x) + fc); \
fp = fc; \
} \
} \
@ -238,14 +238,14 @@ static void bilateral_##name(BilateralContext *s, const uint8_t *ssrc, uint8_t *
ypf = line_factor_b; \
memcpy(ypf, &in_factor[h1 * width], sizeof(float) * width); \
for (int x = 0; x < width; x++) \
map_factor_b[h1 * width + x] = 0.5f*(map_factor_b[h1 * width + x] + ypf[x]); \
map_factor_b[h1 * width + x] = (map_factor_b[h1 * width + x] + ypf[x]); \
\
ycy = slice_factor_a; \
ypy = slice_factor_b; \
memcpy(ypy, &img_temp[h1 * width], sizeof(float) * width); \
for (int x = 0, k = 0; x < width; x++) { \
int idx = h1 * width + x; \
img_out_f[idx] = 0.5f*(img_out_f[idx] + ypy[k++]) / map_factor_b[h1 * width + x]; \
img_out_f[idx] = (img_out_f[idx] + ypy[k++]) / map_factor_b[h1 * width + x]; \
} \
\
for (int y = h1 - 1; y >= 0; y--) { \
@ -270,11 +270,11 @@ static void bilateral_##name(BilateralContext *s, const uint8_t *ssrc, uint8_t *
float ycc, fcc = inv_alpha_*(*xcf++) + alpha_*(*ypf_++); \
\
*ycf_++ = fcc; \
*factor_ = 0.5f * (*factor_ + fcc); \
*factor_ = (*factor_ + fcc); \
\
ycc = inv_alpha_*(*xcy++) + alpha_*(*ypy_++); \
*ycy_++ = ycc; \
*out_ = 0.5f * (*out_ + ycc) / (*factor_); \
*out_ = (*out_ + ycc) / (*factor_); \
out_++; \
factor_++; \
} \

Loading…
Cancel
Save