Commit 116e7d54 authored by Michael Niedermayer's avatar Michael Niedermayer

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

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent a75ca3ca
...@@ -614,27 +614,11 @@ void ff_dwt_destroy(DWTContext *s) ...@@ -614,27 +614,11 @@ void ff_dwt_destroy(DWTContext *s)
#define MAX_W 256 #define MAX_W 256
int main(void) { static int test_dwt(int *array, int *ref, uint16_t border[2][2], int decomp_levels, int type) {
int array[MAX_W * MAX_W]; int ret, j;
int ref [MAX_W * MAX_W];
AVLFG prng;
int i,j;
DWTContext s1={{{0}}}, *s= &s1; 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++) ret = ff_jpeg2000_dwt_init(s, border, decomp_levels, type);
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);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "ff_jpeg2000_dwt_init failed\n"); fprintf(stderr, "ff_jpeg2000_dwt_init failed\n");
return 1; return 1;
...@@ -656,6 +640,33 @@ int main(void) { ...@@ -656,6 +640,33 @@ int main(void) {
return 2; return 2;
} }
ff_dwt_destroy(s); 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; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment