[FFmpeg-cvslog] avfilter/arls_template: use defines for all constants

Paul B Mahol git at videolan.org
Tue Nov 28 17:01:52 EET 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Nov 28 16:04:01 2023 +0100| [47e214245bc2fd373ac285fcd7c33ac128506948] | committer: Paul B Mahol

avfilter/arls_template: use defines for all constants

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

 libavfilter/arls_template.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavfilter/arls_template.c b/libavfilter/arls_template.c
index e5b91d0a85..d8b19d89a5 100644
--- a/libavfilter/arls_template.c
+++ b/libavfilter/arls_template.c
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#undef ZERO
+#undef HALF
 #undef ONE
 #undef ftype
 #undef SAMPLE_FORMAT
@@ -23,10 +25,14 @@
 #define SAMPLE_FORMAT float
 #define ftype float
 #define ONE 1.f
+#define HALF 0.5f
+#define ZERO 0.f
 #else
 #define SAMPLE_FORMAT double
 #define ftype double
 #define ONE 1.0
+#define HALF 0.5
+#define ZERO 0.0
 #endif
 
 #define fn3(a,b)   a##_##b
@@ -92,21 +98,21 @@ static ftype fn(process_sample)(AudioRLSContext *s, ftype input, ftype desired,
     for (int i = 0, pos = offset; i < order; i++, pos++) {
         const int ikernel_size = i * kernel_size;
 
-        u[i] = 0.f;
+        u[i] = ZERO;
         for (int k = 0, pos = offset; k < order; k++, pos++)
             u[i] += p[ikernel_size + k] * delay[pos];
 
         g += u[i] * delay[pos];
     }
 
-    g = 1.f / g;
+    g = ONE / g;
 
     for (int i = 0; i < order; i++) {
         const int ikernel_size = i * kernel_size;
 
         gains[i] = u[i] * g;
         coeffs[i] = coeffs[order + i] = coeffs[i] + gains[i] * e;
-        tmp[i] = 0.f;
+        tmp[i] = ZERO;
         for (int k = 0, pos = offset; k < order; k++, pos++)
             tmp[i] += p[ikernel_size + k] * delay[pos];
     }
@@ -122,7 +128,7 @@ static ftype fn(process_sample)(AudioRLSContext *s, ftype input, ftype desired,
         const int ikernel_size = i * kernel_size;
 
         for (int k = 0; k < order; k++)
-            p[ikernel_size + k] = (p[ikernel_size + k] - (dp[ikernel_size + k] + dp[kernel_size * k + i]) * 0.5f) * lambda;
+            p[ikernel_size + k] = (p[ikernel_size + k] - (dp[ikernel_size + k] + dp[kernel_size * k + i]) * HALF) * lambda;
     }
 
     switch (s->output_mode) {



More information about the ffmpeg-cvslog mailing list