avcodec/jpeg2000dwt: Allow testing with a maximum allowed difference

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-06-21 13:01:17 +02:00
parent a49154e9d7
commit 3bd46914fb
1 changed files with 6 additions and 4 deletions

View File

@ -614,7 +614,7 @@ 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) {
static int test_dwt(int *array, int *ref, uint16_t border[2][2], int decomp_levels, int type, int max_diff) {
int ret, j;
DWTContext s1={{{0}}}, *s= &s1;
@ -633,12 +633,14 @@ static int test_dwt(int *array, int *ref, uint16_t border[2][2], int decomp_leve
fprintf(stderr, "ff_dwt_encode failed\n");
return 1;
}
for (j = 0; j<MAX_W * MAX_W; j++)
if (array[j] != ref[j]) {
for (j = 0; j<MAX_W * MAX_W; j++) {
if (FFABS(array[j] - ref[j]) > max_diff) {
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;
}
array[j] = ref[j];
}
ff_dwt_destroy(s);
return 0;
@ -664,7 +666,7 @@ int main(void) {
continue;
decomp_levels = av_lfg_get(&prng) % FF_DWT_MAX_DECLVLS;
ret = test_dwt(array, ref, border, decomp_levels, FF_DWT53);
ret = test_dwt(array, ref, border, decomp_levels, FF_DWT53, 0);
if (ret)
return ret;
}