mirror of https://git.ffmpeg.org/ffmpeg.git
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:
parent
a75ca3ca6a
commit
116e7d5418
|
@ -614,12 +614,41 @@ void ff_dwt_destroy(DWTContext *s)
|
|||
|
||||
#define MAX_W 256
|
||||
|
||||
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;
|
||||
|
||||
ret = ff_jpeg2000_dwt_init(s, border, decomp_levels, type);
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -634,28 +663,10 @@ int main(void) {
|
|||
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);
|
||||
|
||||
ret = test_dwt(array, ref, border, decomp_levels, FF_DWT53);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue