[FFmpeg-cvslog] avcodec/jpeg2000dwt: add test for the 5/3 wavelet

Michael Niedermayer git at videolan.org
Sat Jun 20 01:38:47 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Jun 20 01:24:08 2015 +0200| [de99ce4306b1ea84fe28c44d76c4df8316ef4359] | committer: Michael Niedermayer

avcodec/jpeg2000dwt: add test for the 5/3 wavelet

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

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

 libavcodec/Makefile      |    1 +
 libavcodec/jpeg2000dwt.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 98af702..7a964ec 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -892,6 +892,7 @@ SKIPHEADERS-$(CONFIG_VDA)              += vda.h vda_internal.h
 SKIPHEADERS-$(CONFIG_VDPAU)            += vdpau.h vdpau_internal.h
 
 TESTPROGS = imgconvert                                                  \
+            jpeg2000dwt                                                 \
             mathops                                                    \
             options                                                     \
             avfft                                                       \
diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
index 381764f..d0cfc9a 100644
--- a/libavcodec/jpeg2000dwt.c
+++ b/libavcodec/jpeg2000dwt.c
@@ -606,3 +606,59 @@ void ff_dwt_destroy(DWTContext *s)
     av_freep(&s->f_linebuf);
     av_freep(&s->i_linebuf);
 }
+
+#ifdef TEST
+
+#include "libavutil/lfg.h"
+
+#define MAX_W 256
+
+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;
+
+    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;
+        border[0][0] = border [1][0] =0;
+        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);
+    }
+
+    return 0;
+}
+
+#endif



More information about the ffmpeg-cvslog mailing list