[FFmpeg-cvslog] avcodec/jpeg2000dwt: Allow testing with a maximum allowed difference

Michael Niedermayer git at videolan.org
Sun Jun 21 14:00:03 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Jun 21 13:01:17 2015 +0200| [3bd46914fbf2c476d437b6312d1f714f35ae5299] | committer: Michael Niedermayer

avcodec/jpeg2000dwt: Allow testing with a maximum allowed difference

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3bd46914fbf2c476d437b6312d1f714f35ae5299
---

 libavcodec/jpeg2000dwt.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
index e8b3e12..c0483c3 100644
--- a/libavcodec/jpeg2000dwt.c
+++ b/libavcodec/jpeg2000dwt.c
@@ -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;
     }



More information about the ffmpeg-cvslog mailing list