diff options
author | James Almer <jamrial@gmail.com> | 2015-09-17 21:22:25 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2015-09-17 21:33:07 +0300 |
commit | 763ffa202978100a55398adbb79c94fcc81566df (patch) | |
tree | 48ce7201e55cc758a64c5ef0674ffa35c1742b4d /tests/checkasm | |
parent | 63cdb6e4a59e296e27a78ac08f15500b42cd27fc (diff) |
checkasm: add flacdsp decorrelate tests
Reviewed-by: Henrik Gramner <henrik@gramner.com>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'tests/checkasm')
-rw-r--r-- | tests/checkasm/Makefile | 1 | ||||
-rw-r--r-- | tests/checkasm/checkasm.c | 3 | ||||
-rw-r--r-- | tests/checkasm/checkasm.h | 1 | ||||
-rw-r--r-- | tests/checkasm/flacdsp.c | 90 |
4 files changed, 95 insertions, 0 deletions
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 359ec6917d..ae85321b0c 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -1,5 +1,6 @@ # libavcodec tests AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o +AVCODECOBJS-$(CONFIG_FLACDSP) += flacdsp.o AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o AVCODECOBJS-$(CONFIG_V210_ENCODER) += v210enc.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 8d648be4e2..00a7c1878a 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -60,6 +60,9 @@ static const struct { #if CONFIG_BSWAPDSP { "bswapdsp", checkasm_check_bswapdsp }, #endif +#if CONFIG_FLACDSP + { "flacdsp", checkasm_check_flacdsp }, +#endif #if CONFIG_H264PRED { "h264pred", checkasm_check_h264pred }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index fdc6fe0259..6014f5a935 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -30,6 +30,7 @@ #include "libavutil/timer.h" void checkasm_check_bswapdsp(void); +void checkasm_check_flacdsp(void); void checkasm_check_h264pred(void); void checkasm_check_h264qpel(void); void checkasm_check_v210enc(void); diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c new file mode 100644 index 0000000000..dccb54d672 --- /dev/null +++ b/tests/checkasm/flacdsp.c @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015 James Almer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <string.h> +#include "checkasm.h" +#include "libavcodec/flacdsp.h" +#include "libavutil/common.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" + +#define BUF_SIZE 256 +#define MAX_CHANNELS 8 + +#define randomize_buffers() \ + do { \ + int i, j; \ + for (i = 0; i < BUF_SIZE; i += 4) { \ + for (j = 0; j < channels; j++) { \ + uint32_t r = rnd() & (1 << (bits - 2)) - 1; \ + AV_WN32A(ref_src[j] + i, r); \ + AV_WN32A(new_src[j] + i, r); \ + } \ + } \ + } while (0) + +static void check_decorrelate(uint8_t **ref_dst, uint8_t **ref_src, uint8_t **new_dst, uint8_t **new_src, + int channels, int bits) { + declare_func(void, uint8_t **out, int32_t **in, int channels, int len, int shift); + + randomize_buffers(); + call_ref(ref_dst, (int32_t **)ref_src, channels, BUF_SIZE / sizeof(int32_t), 8); + call_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE / sizeof(int32_t), 8); + if (memcmp(*ref_dst, *new_dst, bits == 16 ? BUF_SIZE * (channels/2) : BUF_SIZE * channels) || + memcmp(*ref_src, *new_src, BUF_SIZE * channels)) + fail(); + bench_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE / sizeof(int32_t), 8); +} + +void checkasm_check_flacdsp(void) +{ + LOCAL_ALIGNED_16(uint8_t, ref_dst, [BUF_SIZE*MAX_CHANNELS]); + LOCAL_ALIGNED_16(uint8_t, ref_buf, [BUF_SIZE*MAX_CHANNELS]); + LOCAL_ALIGNED_16(uint8_t, new_dst, [BUF_SIZE*MAX_CHANNELS]); + LOCAL_ALIGNED_16(uint8_t, new_buf, [BUF_SIZE*MAX_CHANNELS]); + uint8_t *ref_src[] = { &ref_buf[BUF_SIZE*0], &ref_buf[BUF_SIZE*1], &ref_buf[BUF_SIZE*2], &ref_buf[BUF_SIZE*3], + &ref_buf[BUF_SIZE*4], &ref_buf[BUF_SIZE*5], &ref_buf[BUF_SIZE*6], &ref_buf[BUF_SIZE*7] }; + uint8_t *new_src[] = { &new_buf[BUF_SIZE*0], &new_buf[BUF_SIZE*1], &new_buf[BUF_SIZE*2], &new_buf[BUF_SIZE*3], + &new_buf[BUF_SIZE*4], &new_buf[BUF_SIZE*5], &new_buf[BUF_SIZE*6], &new_buf[BUF_SIZE*7] }; + static const char * const names[3] = { "ls", "rs", "ms" }; + static const struct { + enum AVSampleFormat fmt; + int bits; + } fmts[] = { + { AV_SAMPLE_FMT_S16, 16 }, + { AV_SAMPLE_FMT_S32, 32 }, + }; + FLACDSPContext h; + int i, j; + + for (i = 0; i < 2; i++) { + ff_flacdsp_init(&h, fmts[i].fmt, 2, 0); + for (j = 0; j < 3; j++) + if (check_func(h.decorrelate[j], "flac_decorrelate_%s_%d", names[j], fmts[i].bits)) + check_decorrelate(&ref_dst, ref_src, &new_dst, new_src, 2, fmts[i].bits); + for (j = 2; j <= MAX_CHANNELS; j += 2) { + ff_flacdsp_init(&h, fmts[i].fmt, j, 0); + if (check_func(h.decorrelate[0], "flac_decorrelate_indep%d_%d", j, fmts[i].bits)) + check_decorrelate(&ref_dst, ref_src, &new_dst, new_src, j, fmts[i].bits); + } + } + + report("decorrelate"); +} |