[FFmpeg-cvslog] avfilter/vf_bilateral: remove unneeded multiplications

Paul B Mahol git at videolan.org
Thu Oct 21 23:03:35 EEST 2021


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Oct 21 21:05:02 2021 +0200| [f0ad40b525b5f882f048cf69139bbe496ba59eea] | committer: Paul B Mahol

avfilter/vf_bilateral: remove unneeded multiplications

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f0ad40b525b5f882f048cf69139bbe496ba59eea
---

 libavfilter/vf_bilateral.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c
index 2a4a3df6cc..61c9084933 100644
--- a/libavfilter/vf_bilateral.c
+++ b/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_++;                                                                    \
         }                                                                                 \



More information about the ffmpeg-cvslog mailing list