[FFmpeg-cvslog] checkasm: add aacencdsp.quant_bands test

Rémi Denis-Courmont git at videolan.org
Mon Jun 3 22:45:29 EEST 2024


ffmpeg | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri May 31 21:17:41 2024 +0300| [be6f8c439a6aceca7a6ca6980b678b74e5f23261] | committer: Rémi Denis-Courmont

checkasm: add aacencdsp.quant_bands test

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

 tests/checkasm/aacencdsp.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/tests/checkasm/aacencdsp.c b/tests/checkasm/aacencdsp.c
index 1756c4ecd5..791dd30320 100644
--- a/tests/checkasm/aacencdsp.c
+++ b/tests/checkasm/aacencdsp.c
@@ -22,7 +22,9 @@
 
 #include "libavutil/mem_internal.h"
 
+#include "libavcodec/aacenc_utils.h"
 #include "libavcodec/aacencdsp.h"
+#include "libavcodec/aactab.h"
 
 #include "checkasm.h"
 
@@ -35,6 +37,8 @@
         }                                                       \
     } while (0)
 
+#define randomize_elem(tab) (tab[rnd() % FF_ARRAY_ELEMS(tab)])
+
 static void test_abs_pow34(AACEncDSPContext *s)
 {
 #define BUF_SIZE 1024
@@ -60,6 +64,38 @@ static void test_abs_pow34(AACEncDSPContext *s)
     report("abs_pow34");
 }
 
+static void test_quant_bands(AACEncDSPContext *s)
+{
+    int maxval = randomize_elem(aac_cb_maxval);
+    float q34 = randomize_elem(ff_aac_pow34sf_tab);
+    float rounding = (rnd() & 1) ? ROUND_TO_ZERO : ROUND_STANDARD;
+    LOCAL_ALIGNED_16(float, in, [BUF_SIZE]);
+    LOCAL_ALIGNED_16(float, scaled, [BUF_SIZE]);
+
+    declare_func(void, int *, const float *, const float *, int, int, int,
+                 const float, const float);
+
+    randomize_float(in, BUF_SIZE);
+    randomize_float(scaled, BUF_SIZE);
+
+    for (int sign = 0; sign <= 1; sign++) {
+        if (check_func(s->quant_bands, "quant_bands_%s",
+                       sign ? "signed" : "unsigned")) {
+            LOCAL_ALIGNED_16(int, out, [BUF_SIZE]);
+            LOCAL_ALIGNED_16(int, out2, [BUF_SIZE]);
+
+            call_ref(out, in, scaled, BUF_SIZE, sign, maxval, q34, rounding);
+            call_new(out2, in, scaled, BUF_SIZE, sign, maxval, q34, rounding);
+
+            if (memcmp(out, out2, BUF_SIZE * sizeof (int)))
+                fail();
+
+            bench_new(out, in, scaled, BUF_SIZE, sign, maxval, q34, rounding);
+        }
+    }
+
+    report("quant_bands");
+}
 
 void checkasm_check_aacencdsp(void)
 {
@@ -67,4 +103,5 @@ void checkasm_check_aacencdsp(void)
     ff_aacenc_dsp_init(&s);
 
     test_abs_pow34(&s);
+    test_quant_bands(&s);
 }



More information about the ffmpeg-cvslog mailing list