summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-05-20 19:24:09 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-05-20 20:31:28 +0200
commitadccbc8336ce5c46ca7de85ac364d9c992d337c7 (patch)
tree3703001156ba3d43cb8e07bde7cfc2dbe01dac79 /src/lib
parent3cd1305596f191a01afdc11f9355f9c6590065dd (diff)
Irreversible decoding: partially revert previous commit, to fix failures in test suite
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/openjp2/dwt.c12
-rw-r--r--src/lib/openjp2/tcd.c6
2 files changed, 15 insertions, 3 deletions
diff --git a/src/lib/openjp2/dwt.c b/src/lib/openjp2/dwt.c
index de8fdf4e..5710e802 100644
--- a/src/lib/openjp2/dwt.c
+++ b/src/lib/openjp2/dwt.c
@@ -2608,6 +2608,14 @@ static void opj_v4dwt_decode_step2(opj_v4_t* l, opj_v4_t* w,
static void opj_v4dwt_decode(opj_v4dwt_t* OPJ_RESTRICT dwt)
{
OPJ_INT32 a, b;
+ /* BUG_WEIRD_TWO_INVK (look for this identifier in tcd.c) */
+ /* Historic value for 2 / opj_invK */
+ /* Normally, we should use invK, but if we do so, we have failures in the */
+ /* conformance test, due to MSE and peak errors significantly higher than */
+ /* accepted value */
+ /* Due to using two_invK instead of invK, we have to compensate in tcd.c */
+ /* the computation of the stepsize for the non LL subbands */
+ const float two_invK = 1.625732422f;
if (dwt->cas == 0) {
if (!((dwt->dn > 0) || (dwt->sn > 1))) {
return;
@@ -2625,7 +2633,7 @@ static void opj_v4dwt_decode(opj_v4dwt_t* OPJ_RESTRICT dwt)
opj_v4dwt_decode_step1_sse(dwt->wavelet + a, dwt->win_l_x0, dwt->win_l_x1,
_mm_set1_ps(opj_K));
opj_v4dwt_decode_step1_sse(dwt->wavelet + b, dwt->win_h_x0, dwt->win_h_x1,
- _mm_set1_ps(opj_invK));
+ _mm_set1_ps(two_invK));
opj_v4dwt_decode_step2_sse(dwt->wavelet + b, dwt->wavelet + a + 1,
dwt->win_l_x0, dwt->win_l_x1,
(OPJ_UINT32)opj_int_min(dwt->sn, dwt->dn - a),
@@ -2646,7 +2654,7 @@ static void opj_v4dwt_decode(opj_v4dwt_t* OPJ_RESTRICT dwt)
opj_v4dwt_decode_step1(dwt->wavelet + a, dwt->win_l_x0, dwt->win_l_x1,
opj_K);
opj_v4dwt_decode_step1(dwt->wavelet + b, dwt->win_h_x0, dwt->win_h_x1,
- opj_invK);
+ two_invK);
opj_v4dwt_decode_step2(dwt->wavelet + b, dwt->wavelet + a + 1,
dwt->win_l_x0, dwt->win_l_x1,
(OPJ_UINT32)opj_int_min(dwt->sn, dwt->dn - a),
diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c
index 02fb11db..810f83ec 100644
--- a/src/lib/openjp2/tcd.c
+++ b/src/lib/openjp2/tcd.c
@@ -1000,7 +1000,11 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
{
/* Table E-1 - Sub-band gains */
- const OPJ_INT32 log2_gain = (l_band->bandno == 0) ? 0 :
+ /* BUG_WEIRD_TWO_INVK (look for this identifier in dwt.c): */
+ /* the test (!isEncoder && l_tccp->qmfbid == 0) is strongly */
+ /* linked to the use of two_invK instead of invK */
+ const OPJ_INT32 log2_gain = (!isEncoder &&
+ l_tccp->qmfbid == 0) ? 0 : (l_band->bandno == 0) ? 0 :
(l_band->bandno == 3) ? 2 : 1;
/* Nominal dynamic range. Equation E-4 */