[FFmpeg-devel] [PATCH 8/8] checkasm: add tests for flacenc lpc coder
James Darnley
james.darnley at gmail.com
Mon Nov 27 00:51:11 EET 2017
---
tests/checkasm/flacdsp.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
index dccb54d672..08e5e264ea 100644
--- a/tests/checkasm/flacdsp.c
+++ b/tests/checkasm/flacdsp.c
@@ -20,13 +20,16 @@
#include <string.h>
#include "checkasm.h"
+#include "libavcodec/flac.h"
#include "libavcodec/flacdsp.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
+#include "libavcodec/mathops.h"
#define BUF_SIZE 256
#define MAX_CHANNELS 8
+#define BLOCKSIZE 4608
#define randomize_buffers() \
do { \
@@ -53,6 +56,23 @@ static void check_decorrelate(uint8_t **ref_dst, uint8_t **ref_src, uint8_t **ne
bench_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE / sizeof(int32_t), 8);
}
+static void randomize_coefs(int32_t coef[32], int bits)
+{
+ int i;
+ for (i = 0; i < 32; i++)
+ coef[i] = sign_extend(rnd(), bits);
+}
+
+static void randomize_audio(int32_t *a, int32_t *b, int bits)
+{
+ int i;
+ for (i = 0; i < BLOCKSIZE; i++) {
+ int32_t value = sign_extend(rnd(), bits);
+ a[i] = value;
+ b[i] = value;
+ }
+}
+
void checkasm_check_flacdsp(void)
{
LOCAL_ALIGNED_16(uint8_t, ref_dst, [BUF_SIZE*MAX_CHANNELS]);
@@ -87,4 +107,56 @@ void checkasm_check_flacdsp(void)
}
report("decorrelate");
+
+ if (check_func(h.lpc16_encode, "flacdsp.lpc16_encode")) {
+ int32_t samples_ref[BLOCKSIZE];
+ int32_t samples_new[BLOCKSIZE];
+ int32_t residual_ref[BLOCKSIZE+23];
+ int32_t residual_new[BLOCKSIZE+23];
+ int32_t coefs[32];
+ declare_func(void, int32_t *res, const int32_t *smp, int len, int order,
+ const int32_t coefs[32], int shift);
+ int order;
+
+ randomize_audio(samples_ref, samples_new, 16);
+ randomize_coefs(coefs, 16);
+ for (order = 1; order < 32; order++) {
+ int shift = rnd() & 15;
+ call_ref(residual_ref, samples_ref, BLOCKSIZE, order, coefs, shift);
+ call_new(residual_new, samples_new, BLOCKSIZE, order, coefs, shift);
+ if (memcmp(samples_ref, samples_new, sizeof samples_ref)
+ || memcmp(residual_ref, residual_new, BLOCKSIZE * sizeof(int32_t))) {
+ fprintf(stderr, "failed at order= %d\n", order);
+ fail();
+ }
+ bench_new(residual_new, samples_new, BLOCKSIZE, order, coefs, shift);
+ }
+ }
+ report("flacdsp.lpc16_encode");
+
+ if (check_func(h.lpc32_encode, "flacdsp.lpc32_encode")) {
+ int32_t samples_ref[BLOCKSIZE];
+ int32_t samples_new[BLOCKSIZE];
+ int32_t residual_ref[BLOCKSIZE+23];
+ int32_t residual_new[BLOCKSIZE+23];
+ int32_t coefs[32];
+ declare_func(void, int32_t *res, const int32_t *smp, int len, int order,
+ const int32_t coefs[32], int shift);
+ int order;
+
+ randomize_audio(samples_ref, samples_new, 24);
+ randomize_coefs(coefs, 24);
+ for (order = 1; order < 32; order++) {
+ int shift = rnd() & 15;
+ call_ref(residual_ref, samples_ref, BLOCKSIZE, order, coefs, shift);
+ call_new(residual_new, samples_new, BLOCKSIZE, order, coefs, shift);
+ if (memcmp(samples_ref, samples_new, sizeof samples_ref)
+ || memcmp(residual_ref, residual_new, BLOCKSIZE * sizeof(int32_t))) {
+ fprintf(stderr, "failed at order= %d\n", order);
+ fail();
+ }
+ bench_new(residual_new, samples_new, BLOCKSIZE, order, coefs, shift);
+ }
+ }
+ report("flacdsp.lpc32_encode");
}
--
2.15.0
More information about the ffmpeg-devel
mailing list