avcodec/jpeg2000dwt: Factor dwt test code out so it can be easily used with the other dwts too

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-06-20 01:45:18 +02:00
parent a75ca3ca6a
commit 116e7d5418
1 changed files with 34 additions and 23 deletions

View File

@ -614,27 +614,11 @@ void ff_dwt_destroy(DWTContext *s)
#define MAX_W 256
int main(void) {
int array[MAX_W * MAX_W];
int ref [MAX_W * MAX_W];
AVLFG prng;
int i,j;
static int test_dwt(int *array, int *ref, uint16_t border[2][2], int decomp_levels, int type) {
int ret, 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;
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);
ret = ff_jpeg2000_dwt_init(s, border, decomp_levels, type);
if (ret < 0) {
fprintf(stderr, "ff_jpeg2000_dwt_init failed\n");
return 1;
@ -656,6 +640,33 @@ int main(void) {
return 2;
}
ff_dwt_destroy(s);
return 0;
}
int main(void) {
int array[MAX_W * MAX_W];
int ref [MAX_W * MAX_W];
AVLFG prng;
int i,j;
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;
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 = test_dwt(array, ref, border, decomp_levels, FF_DWT53);
if (ret)
return ret;
}
return 0;