avcodec/jpeg2000dwt: add test for the 5/3 wavelet

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-06-20 01:24:08 +02:00
parent 75651cd63f
commit de99ce4306
2 changed files with 57 additions and 0 deletions

View File

@ -892,6 +892,7 @@ SKIPHEADERS-$(CONFIG_VDA) += vda.h vda_internal.h
SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h
TESTPROGS = imgconvert \ TESTPROGS = imgconvert \
jpeg2000dwt \
mathops \ mathops \
options \ options \
avfft \ avfft \

View File

@ -606,3 +606,59 @@ void ff_dwt_destroy(DWTContext *s)
av_freep(&s->f_linebuf); av_freep(&s->f_linebuf);
av_freep(&s->i_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