[FFmpeg-cvslog] avcodec/jpeg2000dwt: also test 9/7 float DWT

Michael Niedermayer git at videolan.org
Sun Jun 21 17:52:05 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Jun 21 15:51:48 2015 +0200| [4299f085f45cdd8fcb3ecf681d9fef0c4b3fe207] | committer: Michael Niedermayer

avcodec/jpeg2000dwt: also test 9/7 float DWT

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

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

 libavcodec/jpeg2000dwt.c |   46 ++++++++++++++++++++++++++++++++++++++++++++--
 tests/ref/fate/j2k-dwt   |   20 ++++++++++++++++++++
 2 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
index 811a869..b7363a0 100644
--- a/libavcodec/jpeg2000dwt.c
+++ b/libavcodec/jpeg2000dwt.c
@@ -188,7 +188,6 @@ static void dwt_encode97_float(DWTContext *s, float *t)
             lp;
         float *l;
 
-        av_assert1(!mh && !mv);
         // HOR_SD
         l = line + mh;
         for (lp = 0; lp < lv; lp++){
@@ -651,9 +650,49 @@ static int test_dwt(int *array, int *ref, uint16_t border[2][2], int decomp_leve
     return 0;
 }
 
+static int test_dwtf(float *array, float *ref, uint16_t border[2][2], int decomp_levels, float max_diff) {
+    int ret, j;
+    DWTContext s1={{{0}}}, *s= &s1;
+    double err2 = 0;
+
+    ret = ff_jpeg2000_dwt_init(s,  border, decomp_levels, FF_DWT97);
+    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 (FFABS(array[j] - ref[j]) > max_diff) {
+            fprintf(stderr, "missmatch at %d (%f != %f) 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;
+        }
+        err2 += (array[j] - ref[j]) * (array[j] - ref[j]);
+        array[j] = ref[j];
+    }
+    ff_dwt_destroy(s);
+
+    printf("9/7f, decomp:%2d border %3d %3d %3d %3d err2:%20.4f\n",
+           decomp_levels, border[0][0], border[0][1], border[1][0], border[1][1],
+           err2 / ((border[0][1] - border[0][0])*(border[1][1] - border[1][0])));
+
+    return 0;
+}
+
 int main(void) {
     int array[MAX_W * MAX_W];
     int ref  [MAX_W * MAX_W];
+    float arrayf[MAX_W * MAX_W];
+    float reff  [MAX_W * MAX_W];
     AVLFG prng;
     int i,j;
     uint16_t border[2][2];
@@ -662,7 +701,7 @@ int main(void) {
     av_lfg_init(&prng, 1);
 
     for (i = 0; i<MAX_W * MAX_W; i++)
-        array[i] = ref[i] =  av_lfg_get(&prng) % 2048;
+        arrayf[i] = reff[i] = array[i] = ref[i] =  av_lfg_get(&prng) % 2048;
 
     for (i = 0; i < 100; i++) {
         for (j=0; j<4; j++)
@@ -677,6 +716,9 @@ int main(void) {
         ret = test_dwt(array, ref, border, decomp_levels, FF_DWT97_INT, FFMIN(7+5*decomp_levels, 15+3*decomp_levels));
         if (ret)
             return ret;
+        ret = test_dwtf(arrayf, reff, border, decomp_levels, 1.0);
+        if (ret)
+            return ret;
     }
 
     return 0;
diff --git a/tests/ref/fate/j2k-dwt b/tests/ref/fate/j2k-dwt
index f3317b7..0ebcc86 100644
--- a/tests/ref/fate/j2k-dwt
+++ b/tests/ref/fate/j2k-dwt
@@ -1,40 +1,60 @@
 5/3i, decomp:15 border 151 170 140 183 milli-err2:        0
 9/7i, decomp:15 border 151 170 140 183 milli-err2:    13030
+9/7f, decomp:15 border 151 170 140 183 err2:              0.2626
 5/3i, decomp:21 border 173 201  81 189 milli-err2:        0
 9/7i, decomp:21 border 173 201  81 189 milli-err2:    21587
+9/7f, decomp:21 border 173 201  81 189 err2:              0.3460
 5/3i, decomp:22 border 213 227  76 245 milli-err2:        0
 9/7i, decomp:22 border 213 227  76 245 milli-err2:    13454
+9/7f, decomp:22 border 213 227  76 245 err2:              0.2393
 5/3i, decomp:13 border 134 157 184 203 milli-err2:        0
 9/7i, decomp:13 border 134 157 184 203 milli-err2:    19745
+9/7f, decomp:13 border 134 157 184 203 err2:              0.1715
 5/3i, decomp: 1 border 204 237   6 106 milli-err2:        0
 9/7i, decomp: 1 border 204 237   6 106 milli-err2:     2236
+9/7f, decomp: 1 border 204 237   6 106 err2:              0.0063
 5/3i, decomp:28 border  76 211  13 210 milli-err2:        0
 9/7i, decomp:28 border  76 211  13 210 milli-err2:    22341
+9/7f, decomp:28 border  76 211  13 210 err2:              0.3931
 5/3i, decomp:21 border  76  99  43 123 milli-err2:        0
 9/7i, decomp:21 border  76  99  43 123 milli-err2:    15450
+9/7f, decomp:21 border  76  99  43 123 err2:              0.2005
 5/3i, decomp:15 border 192 243 174 204 milli-err2:        0
 9/7i, decomp:15 border 192 243 174 204 milli-err2:    56308
+9/7f, decomp:15 border 192 243 174 204 err2:              0.3373
 5/3i, decomp:21 border  17  68  93 204 milli-err2:        0
 9/7i, decomp:21 border  17  68  93 204 milli-err2:    26234
+9/7f, decomp:21 border  17  68  93 204 err2:              0.2765
 5/3i, decomp:11 border 142 168  82 174 milli-err2:        0
 9/7i, decomp:11 border 142 168  82 174 milli-err2:    14802
+9/7f, decomp:11 border 142 168  82 174 err2:              0.2064
 5/3i, decomp:23 border 142 209 171 235 milli-err2:        0
 9/7i, decomp:23 border 142 209 171 235 milli-err2:    26230
+9/7f, decomp:23 border 142 209 171 235 err2:              0.3092
 5/3i, decomp:30 border  37 185  79 245 milli-err2:        0
 9/7i, decomp:30 border  37 185  79 245 milli-err2:    18994
+9/7f, decomp:30 border  37 185  79 245 err2:              0.3921
 5/3i, decomp: 5 border 129 236  30 243 milli-err2:        0
 9/7i, decomp: 5 border 129 236  30 243 milli-err2:    14600
+9/7f, decomp: 5 border 129 236  30 243 err2:              0.1252
 5/3i, decomp:10 border   5 160 146 247 milli-err2:        0
 9/7i, decomp:10 border   5 160 146 247 milli-err2:    43905
+9/7f, decomp:10 border   5 160 146 247 err2:              0.2753
 5/3i, decomp: 5 border 104 162   6  47 milli-err2:        0
 9/7i, decomp: 5 border 104 162   6  47 milli-err2:    12942
+9/7f, decomp: 5 border 104 162   6  47 err2:              0.1237
 5/3i, decomp:24 border  78 250 102 218 milli-err2:        0
 9/7i, decomp:24 border  78 250 102 218 milli-err2:    24997
+9/7f, decomp:24 border  78 250 102 218 err2:              0.3907
 5/3i, decomp:28 border  86  98  56  79 milli-err2:        0
 9/7i, decomp:28 border  86  98  56  79 milli-err2:     8112
+9/7f, decomp:28 border  86  98  56  79 err2:              0.3094
 5/3i, decomp: 6 border  95 238 197 214 milli-err2:        0
 9/7i, decomp: 6 border  95 238 197 214 milli-err2:    12925
+9/7f, decomp: 6 border  95 238 197 214 err2:              0.1481
 5/3i, decomp:17 border  77 169  93 165 milli-err2:        0
 9/7i, decomp:17 border  77 169  93 165 milli-err2:    24949
+9/7f, decomp:17 border  77 169  93 165 err2:              0.4816
 5/3i, decomp:22 border 178 187   7 119 milli-err2:        0
 9/7i, decomp:22 border 178 187   7 119 milli-err2:     9838
+9/7f, decomp:22 border 178 187   7 119 err2:              0.0999



More information about the ffmpeg-cvslog mailing list