From 216791c3fb2858bc32159d70e917b4abae47e000 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Wed, 24 Oct 2012 09:29:34 +0000 Subject: [PATCH] [trunk] Finalize dwt.v/.h with the v2 style : remove last functions already optimized, add opj_ prefix, use new name of the functions --- src/lib/openjp2/dwt.c | 145 +----------------------------------------- src/lib/openjp2/dwt.h | 8 +-- src/lib/openjp2/t1.c | 4 +- src/lib/openjp2/tcd.c | 2 +- 4 files changed, 6 insertions(+), 153 deletions(-) diff --git a/src/lib/openjp2/dwt.c b/src/lib/openjp2/dwt.c index a94f21bb..bb52718f 100644 --- a/src/lib/openjp2/dwt.c +++ b/src/lib/openjp2/dwt.c @@ -484,13 +484,6 @@ OPJ_UINT32 opj_dwt_getgain(OPJ_UINT32 orient) { return 2; } -/* */ -/* Get norm of 5-3 wavelet. */ -/* */ -double dwt_getnorm(int level, int orient) { - return opj_dwt_norms[orient][level]; -} - /* */ /* Get norm of 5-3 wavelet. */ /* */ @@ -514,13 +507,6 @@ OPJ_UINT32 opj_dwt_getgain_real(OPJ_UINT32 orient) { return 0; } -/* */ -/* Get norm of 9-7 wavelet. */ -/* */ -double dwt_getnorm_real(int level, int orient) { - return opj_dwt_norms_real[orient][level]; -} - /* */ /* Get norm of 9-7 wavelet. */ /* */ @@ -549,39 +535,6 @@ void opj_dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, OPJ_UINT32 prec) { } } -#ifdef OPJ_V1 -/* */ -/* Determine maximum computed resolution level for inverse wavelet transform */ -/* */ -static int dwt_decode_max_resolution(opj_tcd_resolution_t* restrict r, int i) { - int mr = 1; - int w; - while( --i ) { - r++; - if( mr < ( w = r->x1 - r->x0 ) ) - mr = w ; - if( mr < ( w = r->y1 - r->y0 ) ) - mr = w ; - } - return mr ; -} -#endif -/* */ -/* Determine maximum computed resolution level for inverse wavelet transform */ -/* */ -static OPJ_UINT32 dwt_max_resolution(opj_tcd_resolution_t* restrict r, OPJ_UINT32 i) { - OPJ_UINT32 mr = 0; - OPJ_UINT32 w; - while( --i ) { - ++r; - if( mr < ( w = r->x1 - r->x0 ) ) - mr = w ; - if( mr < ( w = r->y1 - r->y0 ) ) - mr = w ; - } - return mr ; -} - /* */ /* Determine maximum computed resolution level for inverse wavelet transform */ /* */ @@ -614,9 +567,7 @@ opj_bool opj_dwt_decode_tile(opj_tcd_tilecomp_v2_t* tilec, OPJ_UINT32 numres, DW h.mem = (OPJ_INT32*) opj_aligned_malloc(opj_dwt_max_resolution(tr, numres) * sizeof(OPJ_INT32)); - if - (! h.mem) - { + if (! h.mem){ return OPJ_FALSE; } @@ -872,102 +823,10 @@ void opj_v4dwt_decode(v4dwt_t* restrict dwt) } -/* KEEP TRUNK VERSION + return type of v2 because rev557 */ -/* */ -/* Inverse 9-7 wavelet transform in 2-D. */ -/* */ -/* V1 void dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){ */ -opj_bool dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres) -{ - v4dwt_t h; - v4dwt_t v; - - opj_tcd_resolution_t* res = tilec->resolutions; - - int rw = res->x1 - res->x0; /* width of the resolution level computed */ - int rh = res->y1 - res->y0; /* height of the resolution level computed */ - - int w = tilec->x1 - tilec->x0; - - h.wavelet = (v4*) opj_aligned_malloc((dwt_max_resolution(res, numres)+5) * sizeof(v4)); - v.wavelet = h.wavelet; - - while( --numres) { - float * restrict aj = (float*) tilec->data; - int bufsize = (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0); - int j; - - h.sn = rw; - v.sn = rh; - - ++res; - - rw = res->x1 - res->x0; /* width of the resolution level computed */ - rh = res->y1 - res->y0; /* height of the resolution level computed */ - - h.dn = rw - h.sn; - h.cas = res->x0 % 2; - - for(j = rh; j > 3; j -= 4){ - int k; - opj_v4dwt_interleave_h(&h, aj, w, bufsize); - opj_v4dwt_decode(&h); - for(k = rw; --k >= 0;){ - aj[k ] = h.wavelet[k].f[0]; - aj[k+w ] = h.wavelet[k].f[1]; - aj[k+w*2] = h.wavelet[k].f[2]; - aj[k+w*3] = h.wavelet[k].f[3]; - } - aj += w*4; - bufsize -= w*4; - } - if (rh & 0x03) { - int k; - j = rh & 0x03; - opj_v4dwt_interleave_h(&h, aj, w, bufsize); - opj_v4dwt_decode(&h); - for(k = rw; --k >= 0;){ - switch(j) { - case 3: aj[k+w*2] = h.wavelet[k].f[2]; - case 2: aj[k+w ] = h.wavelet[k].f[1]; - case 1: aj[k ] = h.wavelet[k].f[0]; - } - } - } - - v.dn = rh - v.sn; - v.cas = res->y0 % 2; - - aj = (float*) tilec->data; - for(j = rw; j > 3; j -= 4){ - int k; - opj_v4dwt_interleave_v(&v, aj, w, 4); - opj_v4dwt_decode(&v); - for(k = 0; k < rh; ++k){ - memcpy(&aj[k*w], &v.wavelet[k], 4 * sizeof(float)); - } - aj += 4; - } - if (rw & 0x03){ - int k; - j = rw & 0x03; - opj_v4dwt_interleave_v(&v, aj, w, j); - opj_v4dwt_decode(&v); - for(k = 0; k < rh; ++k){ - memcpy(&aj[k*w], &v.wavelet[k], j * sizeof(float)); - } - } - } - - opj_aligned_free(h.wavelet); - return OPJ_TRUE; -} - - /* */ /* Inverse 9-7 wavelet transform in 2-D. */ /* */ -opj_bool dwt_decode_real_v2(opj_tcd_tilecomp_v2_t* restrict tilec, OPJ_UINT32 numres) +opj_bool opj_dwt_decode_real(opj_tcd_tilecomp_v2_t* restrict tilec, OPJ_UINT32 numres) { v4dwt_t h; v4dwt_t v; diff --git a/src/lib/openjp2/dwt.h b/src/lib/openjp2/dwt.h index 88308164..a6c98d31 100644 --- a/src/lib/openjp2/dwt.h +++ b/src/lib/openjp2/dwt.h @@ -74,7 +74,6 @@ Get the norm of a wavelet function of a subband at a specified level for the rev @param orient Band of the wavelet function @return Returns the norm of the wavelet function */ -double dwt_getnorm(int level, int orient); /* TODO REMOVE IT*/ OPJ_FLOAT64 opj_dwt_getnorm(OPJ_UINT32 level, OPJ_UINT32 orient); /** Forward 9-7 wavelet transform in 2-D. @@ -83,16 +82,12 @@ Apply an irreversible DWT transform to a component of an image. */ opj_bool opj_dwt_encode_real(opj_tcd_tilecomp_v2_t * tilec); /** -KEEP TRUNK VERSION + return type of v2 because rev557 Inverse 9-7 wavelet transform in 2-D. Apply an irreversible inverse DWT transform to a component of an image. @param tilec Tile component information (current tile) @param numres Number of resolution levels to decode */ -/* V1 void dwt_decode_real(opj_tcd_tilecomp_t* tilec, int numres); */ -opj_bool dwt_decode_real(opj_tcd_tilecomp_t* tilec, int numres); - -opj_bool dwt_decode_real_v2(opj_tcd_tilecomp_v2_t* restrict tilec, OPJ_UINT32 numres); +opj_bool opj_dwt_decode_real(opj_tcd_tilecomp_v2_t* restrict tilec, OPJ_UINT32 numres); /** Get the gain of a subband for the irreversible 9-7 DWT. @@ -106,7 +101,6 @@ Get the norm of a wavelet function of a subband at a specified level for the irr @param orient Band of the wavelet function @return Returns the norm of the 9-7 wavelet */ -double dwt_getnorm_real(int level, int orient); OPJ_FLOAT64 opj_dwt_getnorm_real(OPJ_UINT32 level, OPJ_UINT32 orient); /** Explicit calculation of the Quantization Stepsizes diff --git a/src/lib/openjp2/t1.c b/src/lib/openjp2/t1.c index b0482860..41f23b64 100644 --- a/src/lib/openjp2/t1.c +++ b/src/lib/openjp2/t1.c @@ -748,10 +748,10 @@ static double t1_getwmsedec( double w1, w2, wmsedec; if (qmfbid == 1) { w1 = (mct && numcomps==3) ? opj_mct_getnorm(compno) : 1.0; - w2 = dwt_getnorm(level, orient); + w2 = opj_dwt_getnorm(level, orient); } else { /* if (qmfbid == 0) */ w1 = (mct && numcomps==3) ? opj_mct_getnorm_real(compno) : 1.0; - w2 = dwt_getnorm_real(level, orient); + w2 = opj_dwt_getnorm_real(level, orient); } wmsedec = w1 * w2 * stepsize * (1 << bpno); wmsedec *= wmsedec * nmsedec / 8192.0; diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index 6d5706fb..3b66e432 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -1543,7 +1543,7 @@ opj_bool opj_tcd_dwt_decode ( opj_tcd_v2_t *p_tcd ) } } else { - if (! dwt_decode_real_v2(l_tile_comp, l_img_comp->resno_decoded+1)) { + if (! opj_dwt_decode_real(l_tile_comp, l_img_comp->resno_decoded+1)) { return OPJ_FALSE; } } -- 2.40.0