diff options
-rw-r--r-- | libavcodec/jpeg2000.c | 5 | ||||
-rw-r--r-- | libavcodec/jpeg2000dwt.c | 28 | ||||
-rw-r--r-- | tests/ref/fate/j2k-dwt | 40 | ||||
-rw-r--r-- | tests/ref/fate/jpeg2000-dcinema | 4 | ||||
-rw-r--r-- | tests/ref/vsynth/vsynth1-jpeg2000-97 | 8 | ||||
-rw-r--r-- | tests/ref/vsynth/vsynth2-jpeg2000-97 | 8 | ||||
-rw-r--r-- | tests/ref/vsynth/vsynth3-jpeg2000-97 | 8 | ||||
-rw-r--r-- | tests/ref/vsynth/vsynth_lena-jpeg2000-97 | 8 |
8 files changed, 54 insertions, 55 deletions
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 427f6f7423..3bb55786b7 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -305,9 +305,6 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, * delta_b = 2 ^ (R_b - expn_b) * (1 + (mant_b / 2 ^ 11)) * R_b = R_I + log2 (gain_b ) * see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */ - /* TODO/WARN: value of log2 (gain_b ) not taken into account - * but it works (compared to OpenJPEG). Why? - * Further investigation needed. */ gain = cbps; band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]); band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0; @@ -317,6 +314,8 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n"); break; } + band->f_stepsize *= 1<<lut_gain[codsty->transform != FF_DWT53][bandno + (reslevelno > 0)]; + /* FIXME: In openjepg code stespize = stepsize * 0.5. Why? * If not set output of entropic decoder is not correct. */ if (!av_codec_is_encoder(avctx->codec)) diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c index 5c2ec679c8..9c887d2afd 100644 --- a/libavcodec/jpeg2000dwt.c +++ b/libavcodec/jpeg2000dwt.c @@ -38,7 +38,7 @@ #define F_LFTG_GAMMA 0.882911075530934f #define F_LFTG_DELTA 0.443506852043971f #define F_LFTG_K 1.230174104914001f -#define F_LFTG_X 1.625786132231922f +#define F_LFTG_X 0.812893066115961f /* Lifting parameters in integer format. * Computed as param = (float param) * (1 << 16) */ @@ -47,7 +47,7 @@ #define I_LFTG_GAMMA 57862 #define I_LFTG_DELTA 29066 #define I_LFTG_K 80621 -#define I_LFTG_X 106548 +#define I_LFTG_X 53274 static inline void extend53(int *p, int i0, int i1) { @@ -151,7 +151,7 @@ static void sd_1d97_float(float *p, int i0, int i1) if (i1 <= i0 + 1) { if (i0 == 1) - p[1] *= F_LFTG_X; + p[1] *= F_LFTG_X * 2; else p[0] *= F_LFTG_K; return; @@ -197,9 +197,9 @@ static void dwt_encode97_float(DWTContext *s, float *t) // copy back and deinterleave for (i = mh; i < lh; i+=2, j++) - t[w*lp + j] = F_LFTG_X * l[i] / 2; + t[w*lp + j] = F_LFTG_X * l[i]; for (i = 1-mh; i < lh; i+=2, j++) - t[w*lp + j] = F_LFTG_K * l[i] / 2; + t[w*lp + j] = F_LFTG_K * l[i]; } // VER_SD @@ -214,9 +214,9 @@ static void dwt_encode97_float(DWTContext *s, float *t) // copy back and deinterleave for (i = mv; i < lv; i+=2, j++) - t[w*j + lp] = F_LFTG_X * l[i] / 2; + t[w*j + lp] = F_LFTG_X * l[i]; for (i = 1-mv; i < lv; i+=2, j++) - t[w*j + lp] = F_LFTG_K * l[i] / 2; + t[w*j + lp] = F_LFTG_K * l[i]; } } } @@ -227,7 +227,7 @@ static void sd_1d97_int(int *p, int i0, int i1) if (i1 <= i0 + 1) { if (i0 == 1) - p[1] = (p[1] * I_LFTG_X + (1<<15)) >> 16; + p[1] = (p[1] * I_LFTG_X + (1<<14)) >> 15; else p[0] = (p[0] * I_LFTG_K + (1<<15)) >> 16; return; @@ -273,9 +273,9 @@ static void dwt_encode97_int(DWTContext *s, int *t) // copy back and deinterleave for (i = mv; i < lv; i+=2, j++) - t[w*j + lp] = ((l[i] * I_LFTG_X) + (1 << 16)) >> 17; + t[w*j + lp] = ((l[i] * I_LFTG_X) + (1 << 15)) >> 16; for (i = 1-mv; i < lv; i+=2, j++) - t[w*j + lp] = ((l[i] * I_LFTG_K) + (1 << 16)) >> 17; + t[w*j + lp] = ((l[i] * I_LFTG_K) + (1 << 15)) >> 16; } // HOR_SD @@ -290,9 +290,9 @@ static void dwt_encode97_int(DWTContext *s, int *t) // copy back and deinterleave for (i = mh; i < lh; i+=2, j++) - t[w*lp + j] = ((l[i] * I_LFTG_X) + (1 << 16)) >> 17; + t[w*lp + j] = ((l[i] * I_LFTG_X) + (1 << 15)) >> 16; for (i = 1-mh; i < lh; i+=2, j++) - t[w*lp + j] = ((l[i] * I_LFTG_K) + (1 << 16)) >> 17; + t[w*lp + j] = ((l[i] * I_LFTG_K) + (1 << 15)) >> 16; } } @@ -373,7 +373,7 @@ static void sr_1d97_float(float *p, int i0, int i1) if (i0 == 1) p[1] *= F_LFTG_K/2; else - p[0] *= F_LFTG_X/2; + p[0] *= F_LFTG_X; return; } @@ -450,7 +450,7 @@ static void sr_1d97_int(int32_t *p, int i0, int i1) if (i0 == 1) p[1] = (p[1] * I_LFTG_K + (1<<16)) >> 17; else - p[0] = (p[0] * I_LFTG_X + (1<<16)) >> 17; + p[0] = (p[0] * I_LFTG_X + (1<<15)) >> 16; return; } diff --git a/tests/ref/fate/j2k-dwt b/tests/ref/fate/j2k-dwt index 74b4d04458..aba9458dfd 100644 --- a/tests/ref/fate/j2k-dwt +++ b/tests/ref/fate/j2k-dwt @@ -1,60 +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: 13160 +9/7i, decomp:15 border 151 170 140 183 milli-err2: 5407 9/7f, decomp:15 border 151 170 140 183 err2: 0.0001 5/3i, decomp:21 border 173 201 81 189 milli-err2: 0 -9/7i, decomp:21 border 173 201 81 189 milli-err2: 24635 +9/7i, decomp:21 border 173 201 81 189 milli-err2: 8289 9/7f, decomp:21 border 173 201 81 189 err2: 0.0001 5/3i, decomp:22 border 213 227 76 245 milli-err2: 0 -9/7i, decomp:22 border 213 227 76 245 milli-err2: 15253 +9/7i, decomp:22 border 213 227 76 245 milli-err2: 7210 9/7f, decomp:22 border 213 227 76 245 err2: 0.0001 5/3i, decomp:13 border 134 157 184 203 milli-err2: 0 -9/7i, decomp:13 border 134 157 184 203 milli-err2: 21846 +9/7i, decomp:13 border 134 157 184 203 milli-err2: 17748 9/7f, decomp:13 border 134 157 184 203 err2: 0.0001 5/3i, decomp: 1 border 204 237 6 106 milli-err2: 0 -9/7i, decomp: 1 border 204 237 6 106 milli-err2: 2317 +9/7i, decomp: 1 border 204 237 6 106 milli-err2: 824 9/7f, decomp: 1 border 204 237 6 106 err2: 0.0000 5/3i, decomp:28 border 76 211 13 210 milli-err2: 0 -9/7i, decomp:28 border 76 211 13 210 milli-err2: 21360 +9/7i, decomp:28 border 76 211 13 210 milli-err2: 11710 9/7f, decomp:28 border 76 211 13 210 err2: 0.0002 5/3i, decomp:21 border 76 99 43 123 milli-err2: 0 -9/7i, decomp:21 border 76 99 43 123 milli-err2: 13513 +9/7i, decomp:21 border 76 99 43 123 milli-err2: 8555 9/7f, decomp:21 border 76 99 43 123 err2: 0.0001 5/3i, decomp:15 border 192 243 174 204 milli-err2: 0 -9/7i, decomp:15 border 192 243 174 204 milli-err2: 13302 +9/7i, decomp:15 border 192 243 174 204 milli-err2: 7769 9/7f, decomp:15 border 192 243 174 204 err2: 0.0001 5/3i, decomp:21 border 17 68 93 204 milli-err2: 0 -9/7i, decomp:21 border 17 68 93 204 milli-err2: 22975 +9/7i, decomp:21 border 17 68 93 204 milli-err2: 7727 9/7f, decomp:21 border 17 68 93 204 err2: 0.0001 5/3i, decomp:11 border 142 168 82 174 milli-err2: 0 -9/7i, decomp:11 border 142 168 82 174 milli-err2: 11936 +9/7i, decomp:11 border 142 168 82 174 milli-err2: 12277 9/7f, decomp:11 border 142 168 82 174 err2: 0.0001 5/3i, decomp:23 border 142 209 171 235 milli-err2: 0 -9/7i, decomp:23 border 142 209 171 235 milli-err2: 19428 +9/7i, decomp:23 border 142 209 171 235 milli-err2: 6570 9/7f, decomp:23 border 142 209 171 235 err2: 0.0001 5/3i, decomp:30 border 37 185 79 245 milli-err2: 0 -9/7i, decomp:30 border 37 185 79 245 milli-err2: 22981 +9/7i, decomp:30 border 37 185 79 245 milli-err2: 12266 9/7f, decomp:30 border 37 185 79 245 err2: 0.0002 5/3i, decomp: 5 border 129 236 30 243 milli-err2: 0 -9/7i, decomp: 5 border 129 236 30 243 milli-err2: 16632 +9/7i, decomp: 5 border 129 236 30 243 milli-err2: 8686 9/7f, decomp: 5 border 129 236 30 243 err2: 0.0001 5/3i, decomp:10 border 5 160 146 247 milli-err2: 0 -9/7i, decomp:10 border 5 160 146 247 milli-err2: 39669 +9/7i, decomp:10 border 5 160 146 247 milli-err2: 12231 9/7f, decomp:10 border 5 160 146 247 err2: 0.0002 5/3i, decomp: 5 border 104 162 6 47 milli-err2: 0 -9/7i, decomp: 5 border 104 162 6 47 milli-err2: 18290 +9/7i, decomp: 5 border 104 162 6 47 milli-err2: 7794 9/7f, decomp: 5 border 104 162 6 47 err2: 0.0001 5/3i, decomp:24 border 78 250 102 218 milli-err2: 0 -9/7i, decomp:24 border 78 250 102 218 milli-err2: 36623 +9/7i, decomp:24 border 78 250 102 218 milli-err2: 11632 9/7f, decomp:24 border 78 250 102 218 err2: 0.0002 5/3i, decomp:28 border 86 98 56 79 milli-err2: 0 -9/7i, decomp:28 border 86 98 56 79 milli-err2: 9891 +9/7i, decomp:28 border 86 98 56 79 milli-err2: 11105 9/7f, decomp:28 border 86 98 56 79 err2: 0.0001 5/3i, decomp: 6 border 95 238 197 214 milli-err2: 0 -9/7i, decomp: 6 border 95 238 197 214 milli-err2: 17172 +9/7i, decomp: 6 border 95 238 197 214 milli-err2: 8308 9/7f, decomp: 6 border 95 238 197 214 err2: 0.0001 5/3i, decomp:17 border 77 169 93 165 milli-err2: 0 -9/7i, decomp:17 border 77 169 93 165 milli-err2: 23573 +9/7i, decomp:17 border 77 169 93 165 milli-err2: 8820 9/7f, decomp:17 border 77 169 93 165 err2: 0.0001 5/3i, decomp:22 border 178 187 7 119 milli-err2: 0 -9/7i, decomp:22 border 178 187 7 119 milli-err2: 11305 +9/7i, decomp:22 border 178 187 7 119 milli-err2: 5554 9/7f, decomp:22 border 178 187 7 119 err2: 0.0000 diff --git a/tests/ref/fate/jpeg2000-dcinema b/tests/ref/fate/jpeg2000-dcinema index 343f438b86..00a0cae1ae 100644 --- a/tests/ref/fate/jpeg2000-dcinema +++ b/tests/ref/fate/jpeg2000-dcinema @@ -1,3 +1,3 @@ #tb 0: 1/24 -0, 0, 0, 1, 12441600, 0x35b017fd -0, 1, 1, 1, 12441600, 0xe94551b9 +0, 0, 0, 1, 12441600, 0x330aac66 +0, 1, 1, 1, 12441600, 0x112db395 diff --git a/tests/ref/vsynth/vsynth1-jpeg2000-97 b/tests/ref/vsynth/vsynth1-jpeg2000-97 index 15ca696a07..20ff0733cf 100644 --- a/tests/ref/vsynth/vsynth1-jpeg2000-97 +++ b/tests/ref/vsynth/vsynth1-jpeg2000-97 @@ -1,4 +1,4 @@ -4cac63aaf880ab0ee199ac44e520640a *tests/data/fate/vsynth1-jpeg2000-97.avi -2188956 tests/data/fate/vsynth1-jpeg2000-97.avi -d9227e7a7413cb48362654d879df985a *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo -stddev: 6.18 PSNR: 32.30 MAXDIFF: 57 bytes: 7603200/ 7603200 +0c704936bf54fad2b072dc0c8c289bb7 *tests/data/fate/vsynth1-jpeg2000-97.avi +4336566 tests/data/fate/vsynth1-jpeg2000-97.avi +1207ed65ca04d2c91936c4bc73c3a562 *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo +stddev: 4.36 PSNR: 35.34 MAXDIFF: 51 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth2-jpeg2000-97 b/tests/ref/vsynth/vsynth2-jpeg2000-97 index f6f4505bc5..caeb9adaab 100644 --- a/tests/ref/vsynth/vsynth2-jpeg2000-97 +++ b/tests/ref/vsynth/vsynth2-jpeg2000-97 @@ -1,4 +1,4 @@ -352d3dc81b5c78638a2e7b575ce468c2 *tests/data/fate/vsynth2-jpeg2000-97.avi -1448342 tests/data/fate/vsynth2-jpeg2000-97.avi -d7b18b6dcac0139858e64e00073db1c6 *tests/data/fate/vsynth2-jpeg2000-97.out.rawvideo -stddev: 5.35 PSNR: 33.56 MAXDIFF: 56 bytes: 7603200/ 7603200 +7bb7ccf4e9743888a5bda48f431630cf *tests/data/fate/vsynth2-jpeg2000-97.avi +3124708 tests/data/fate/vsynth2-jpeg2000-97.avi +fe0f3a97aa8c0b2f02dd11ccd1b77ca6 *tests/data/fate/vsynth2-jpeg2000-97.out.rawvideo +stddev: 3.26 PSNR: 37.86 MAXDIFF: 26 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth3-jpeg2000-97 b/tests/ref/vsynth/vsynth3-jpeg2000-97 index 236519863f..eff6945989 100644 --- a/tests/ref/vsynth/vsynth3-jpeg2000-97 +++ b/tests/ref/vsynth/vsynth3-jpeg2000-97 @@ -1,4 +1,4 @@ -36dddf487c4919d890db3484ab5d6486 *tests/data/fate/vsynth3-jpeg2000-97.avi -66522 tests/data/fate/vsynth3-jpeg2000-97.avi -332c0924bc1477a41eb413455c5b9d90 *tests/data/fate/vsynth3-jpeg2000-97.out.rawvideo -stddev: 6.17 PSNR: 32.32 MAXDIFF: 51 bytes: 86700/ 86700 +d551b1b1bfc691356e6f45f4386aff1d *tests/data/fate/vsynth3-jpeg2000-97.avi +92144 tests/data/fate/vsynth3-jpeg2000-97.avi +533535dad2ccc7aef3eb0e7ccb239bf2 *tests/data/fate/vsynth3-jpeg2000-97.out.rawvideo +stddev: 4.60 PSNR: 34.87 MAXDIFF: 46 bytes: 86700/ 86700 diff --git a/tests/ref/vsynth/vsynth_lena-jpeg2000-97 b/tests/ref/vsynth/vsynth_lena-jpeg2000-97 index 21160ef061..426787c0cd 100644 --- a/tests/ref/vsynth/vsynth_lena-jpeg2000-97 +++ b/tests/ref/vsynth/vsynth_lena-jpeg2000-97 @@ -1,4 +1,4 @@ -a39e052e7d109e33714329800c9df90f *tests/data/fate/vsynth_lena-jpeg2000-97.avi -1105046 tests/data/fate/vsynth_lena-jpeg2000-97.avi -c151476d2ed807575122064ada37d5ef *tests/data/fate/vsynth_lena-jpeg2000-97.out.rawvideo -stddev: 4.85 PSNR: 34.41 MAXDIFF: 59 bytes: 7603200/ 7603200 +6600b19f6c2e84c599f37d33a295ee35 *tests/data/fate/vsynth_lena-jpeg2000-97.avi +2459730 tests/data/fate/vsynth_lena-jpeg2000-97.avi +9d9c07b0d1936810032820a08d0b0b5d *tests/data/fate/vsynth_lena-jpeg2000-97.out.rawvideo +stddev: 3.01 PSNR: 38.55 MAXDIFF: 27 bytes: 7603200/ 7603200 |