[FFmpeg-cvslog] avfilter/af_afreqshift: cache nb_coeffs value

Paul B Mahol git at videolan.org
Wed May 3 21:14:31 EEST 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Wed May  3 20:07:39 2023 +0200| [d94c6df975e277b6f64db865074a4b64cbf0ae7a] | committer: Paul B Mahol

avfilter/af_afreqshift: cache nb_coeffs value

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

 libavfilter/af_afreqshift.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavfilter/af_afreqshift.c b/libavfilter/af_afreqshift.c
index 70bf8e419f..4df92a499a 100644
--- a/libavfilter/af_afreqshift.c
+++ b/libavfilter/af_afreqshift.c
@@ -66,6 +66,7 @@ static void pfilter_channel_## name(AVFilterContext *ctx,     \
     type *o1 = (type *)s->o1->extended_data[ch];              \
     type *i2 = (type *)s->i2->extended_data[ch];              \
     type *o2 = (type *)s->o2->extended_data[ch];              \
+    const int nb_coeffs = s->nb_coeffs;                       \
     const type *c = s->cc;                                    \
     const type level = s->level;                              \
     type shift = s->shift * M_PI;                             \
@@ -76,7 +77,7 @@ static void pfilter_channel_## name(AVFilterContext *ctx,     \
         type xn1 = src[n], xn2 = src[n];                      \
         type I, Q;                                            \
                                                               \
-        for (int j = 0; j < s->nb_coeffs; j++) {              \
+        for (int j = 0; j < nb_coeffs; j++) {                 \
             I = c[j] * (xn1 + o2[j]) - i2[j];                 \
             i2[j] = i1[j];                                    \
             i1[j] = xn1;                                      \
@@ -85,7 +86,7 @@ static void pfilter_channel_## name(AVFilterContext *ctx,     \
             xn1 = I;                                          \
         }                                                     \
                                                               \
-        for (int j = s->nb_coeffs; j < s->nb_coeffs*2; j++) { \
+        for (int j = nb_coeffs; j < nb_coeffs*2; j++) {       \
             Q = c[j] * (xn2 + o2[j]) - i2[j];                 \
             i2[j] = i1[j];                                    \
             i1[j] = xn2;                                      \
@@ -93,7 +94,7 @@ static void pfilter_channel_## name(AVFilterContext *ctx,     \
             o1[j] = Q;                                        \
             xn2 = Q;                                          \
         }                                                     \
-        Q = o2[s->nb_coeffs * 2 - 1];                         \
+        Q = o2[nb_coeffs * 2 - 1];                            \
                                                               \
         dst[n] = (I * cos_theta - Q * sin_theta) * level;     \
     }                                                         \
@@ -115,6 +116,7 @@ static void ffilter_channel_## name(AVFilterContext *ctx,     \
     type *o1 = (type *)s->o1->extended_data[ch];              \
     type *i2 = (type *)s->i2->extended_data[ch];              \
     type *o2 = (type *)s->o2->extended_data[ch];              \
+    const int nb_coeffs = s->nb_coeffs;                       \
     const type *c = s->cc;                                    \
     const type level = s->level;                              \
     type ts = 1. / in->sample_rate;                           \
@@ -125,7 +127,7 @@ static void ffilter_channel_## name(AVFilterContext *ctx,     \
         type xn1 = src[n], xn2 = src[n];                      \
         type I, Q, theta;                                     \
                                                               \
-        for (int j = 0; j < s->nb_coeffs; j++) {              \
+        for (int j = 0; j < nb_coeffs; j++) {                 \
             I = c[j] * (xn1 + o2[j]) - i2[j];                 \
             i2[j] = i1[j];                                    \
             i1[j] = xn1;                                      \
@@ -134,7 +136,7 @@ static void ffilter_channel_## name(AVFilterContext *ctx,     \
             xn1 = I;                                          \
         }                                                     \
                                                               \
-        for (int j = s->nb_coeffs; j < s->nb_coeffs*2; j++) { \
+        for (int j = nb_coeffs; j < nb_coeffs*2; j++) {       \
             Q = c[j] * (xn2 + o2[j]) - i2[j];                 \
             i2[j] = i1[j];                                    \
             i1[j] = xn2;                                      \
@@ -142,7 +144,7 @@ static void ffilter_channel_## name(AVFilterContext *ctx,     \
             o1[j] = Q;                                        \
             xn2 = Q;                                          \
         }                                                     \
-        Q = o2[s->nb_coeffs * 2 - 1];                         \
+        Q = o2[nb_coeffs * 2 - 1];                            \
                                                               \
         theta = 2. * M_PI * fmod(shift * (N + n) * ts, 1.);   \
         dst[n] = (I * cos(theta) - Q * sin(theta)) * level;   \



More information about the ffmpeg-cvslog mailing list