diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-20 01:24:08 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-20 01:37:43 +0200 |
commit | de99ce4306b1ea84fe28c44d76c4df8316ef4359 (patch) | |
tree | 1dcbf2972f7ff261dc61c83952a1a5f00050eb02 | |
parent | 75651cd63f2d7b99fe92fa96eccdd18b7f9c37fe (diff) | |
download | ffmpeg-de99ce4306b1ea84fe28c44d76c4df8316ef4359.tar.gz |
avcodec/jpeg2000dwt: add test for the 5/3 wavelet
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/Makefile | 1 | ||||
-rw-r--r-- | libavcodec/jpeg2000dwt.c | 56 |
2 files changed, 57 insertions, 0 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 98af702de1..7a964ecaa1 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -892,6 +892,7 @@ SKIPHEADERS-$(CONFIG_VDA) += vda.h vda_internal.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h TESTPROGS = imgconvert \ + jpeg2000dwt \ mathops \ options \ avfft \ diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c index 381764f3ad..d0cfc9a4ad 100644 --- a/libavcodec/jpeg2000dwt.c +++ b/libavcodec/jpeg2000dwt.c @@ -606,3 +606,59 @@ void ff_dwt_destroy(DWTContext *s) av_freep(&s->f_linebuf); av_freep(&s->i_linebuf); } + +#ifdef TEST + +#include "libavutil/lfg.h" + +#define MAX_W 256 + +int main(void) { + int array[MAX_W * MAX_W]; + int ref [MAX_W * MAX_W]; + AVLFG prng; + int i,j; + DWTContext s1={{{0}}}, *s= &s1; + uint16_t border[2][2]; + int ret, decomp_levels; + + av_lfg_init(&prng, 1); + + for (i = 0; i<MAX_W * MAX_W; i++) + array[i] = ref[i] = av_lfg_get(&prng) % 2048; + + for (i = 0; i < 40; i++) { + for (j=0; j<4; j++) + border[0][j] = av_lfg_get(&prng) % MAX_W; + border[0][0] = border [1][0] =0; + if (border[0][0] >= border[0][1] || border[1][0] >= border[1][1]) + continue; + decomp_levels = av_lfg_get(&prng) % FF_DWT_MAX_DECLVLS; + ret = ff_jpeg2000_dwt_init(s, border, decomp_levels, FF_DWT53); + if (ret < 0) { + fprintf(stderr, "ff_jpeg2000_dwt_init failed\n"); + return 1; + } + ret = ff_dwt_encode(s, array); + if (ret < 0) { + fprintf(stderr, "ff_dwt_encode failed\n"); + return 1; + } + ret = ff_dwt_decode(s, array); + if (ret < 0) { + fprintf(stderr, "ff_dwt_encode failed\n"); + return 1; + } + for (j = 0; j<MAX_W * MAX_W; j++) + if (array[j] != ref[j]) { + fprintf(stderr, "missmatch at %d (%d != %d) decomp:%d border %d %d %d %d\n", + j, array[j], ref[j],decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1]); + return 2; + } + ff_dwt_destroy(s); + } + + return 0; +} + +#endif |