2
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
3
* Copyright (c) 2002-2007, Professor Benoit Macq
4
* Copyright (c) 2001-2003, David Janssens
5
* Copyright (c) 2002-2003, Yannick Verschueren
6
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
7
* Copyright (c) 2005, Herve Drolon, FreeImage Team
8
* Copyright (c) 2007, Jonathan Ballard <dzonatas@dzonux.net>
9
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
10
* All rights reserved.
12
* Redistribution and use in source and binary forms, with or without
13
* modification, are permitted provided that the following conditions
15
* 1. Redistributions of source code must retain the above copyright
16
* notice, this list of conditions and the following disclaimer.
17
* 2. Redistributions in binary form must reproduce the above copyright
18
* notice, this list of conditions and the following disclaimer in the
19
* documentation and/or other materials provided with the distribution.
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
22
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
* POSSIBILITY OF SUCH DAMAGE.
35
#include <xmmintrin.h>
38
#include "opj_includes.h"
40
/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
43
#define WS(i) v->mem[(i)*2]
44
#define WD(i) v->mem[(1+(i)*2)]
46
/** @name Local data structures */
49
typedef struct dwt_local {
60
typedef struct v4dwt_local {
67
static const float dwt_alpha = 1.586134342f; // 12994
68
static const float dwt_beta = 0.052980118f; // 434
69
static const float dwt_gamma = -0.882911075f; // -7233
70
static const float dwt_delta = -0.443506852f; // -3633
72
static const float K = 1.230174105f; // 10078
73
/* FIXME: What is this constant? */
74
static const float c13318 = 1.625732422f;
79
Virtual function type for wavelet transform in 1-D
81
typedef void (*DWT1DFN)(dwt_t* v);
83
/** @name Local static functions */
87
Forward lazy transform (horizontal)
89
static void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas);
91
Forward lazy transform (vertical)
93
static void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas);
95
Inverse lazy transform (horizontal)
97
static void dwt_interleave_h(dwt_t* h, int *a);
99
Inverse lazy transform (vertical)
101
static void dwt_interleave_v(dwt_t* v, int *a, int x);
103
Forward 5-3 wavelet transform in 1-D
105
static void dwt_encode_1(int *a, int dn, int sn, int cas);
107
Inverse 5-3 wavelet transform in 1-D
109
static void dwt_decode_1(dwt_t *v);
111
Forward 9-7 wavelet transform in 1-D
113
static void dwt_encode_1_real(int *a, int dn, int sn, int cas);
115
Explicit calculation of the Quantization Stepsizes
117
static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno_stepsize);
119
Inverse wavelet transform in 2-D.
121
static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int i, DWT1DFN fn);
127
#define S(i) a[(i)*2]
128
#define D(i) a[(1+(i)*2)]
129
#define S_(i) ((i)<0?S(0):((i)>=sn?S(sn-1):S(i)))
130
#define D_(i) ((i)<0?D(0):((i)>=dn?D(dn-1):D(i)))
132
#define SS_(i) ((i)<0?S(0):((i)>=dn?S(dn-1):S(i)))
133
#define DD_(i) ((i)<0?D(0):((i)>=sn?D(sn-1):D(i)))
136
/* This table contains the norms of the 5-3 wavelets for different bands. */
138
static const double dwt_norms[4][10] = {
139
{1.000, 1.500, 2.750, 5.375, 10.68, 21.34, 42.67, 85.33, 170.7, 341.3},
140
{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
141
{1.038, 1.592, 2.919, 5.703, 11.33, 22.64, 45.25, 90.48, 180.9},
142
{.7186, .9218, 1.586, 3.043, 6.019, 12.01, 24.00, 47.97, 95.93}
146
/* This table contains the norms of the 9-7 wavelets for different bands. */
148
static const double dwt_norms_real[4][10] = {
149
{1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
150
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
151
{2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
152
{2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
156
==========================================================
158
==========================================================
162
/* Forward lazy transform (horizontal). */
164
static void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas) {
166
for (i=0; i<sn; i++) b[i]=a[2*i+cas];
167
for (i=0; i<dn; i++) b[sn+i]=a[(2*i+1-cas)];
171
/* Forward lazy transform (vertical). */
173
static void dwt_deinterleave_v(int *a, int *b, int dn, int sn, int x, int cas) {
175
for (i=0; i<sn; i++) b[i*x]=a[2*i+cas];
176
for (i=0; i<dn; i++) b[(sn+i)*x]=a[(2*i+1-cas)];
180
/* Inverse lazy transform (horizontal). */
182
static void dwt_interleave_h(dwt_t* h, int *a) {
184
int *bi = h->mem + h->cas;
191
bi = h->mem + 1 - h->cas;
200
/* Inverse lazy transform (vertical). */
202
static void dwt_interleave_v(dwt_t* v, int *a, int x) {
204
int *bi = v->mem + v->cas;
211
ai = a + (v->sn * x);
212
bi = v->mem + 1 - v->cas;
223
/* Forward 5-3 wavelet transform in 1-D. */
225
static void dwt_encode_1(int *a, int dn, int sn, int cas) {
229
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
230
for (i = 0; i < dn; i++) D(i) -= (S_(i) + S_(i + 1)) >> 1;
231
for (i = 0; i < sn; i++) S(i) += (D_(i - 1) + D_(i) + 2) >> 2;
234
if (!sn && dn == 1) /* NEW : CASE ONE ELEMENT */
237
for (i = 0; i < dn; i++) S(i) -= (DD_(i) + DD_(i - 1)) >> 1;
238
for (i = 0; i < sn; i++) D(i) += (SS_(i) + SS_(i + 1) + 2) >> 2;
244
/* Inverse 5-3 wavelet transform in 1-D. */
246
static void dwt_decode_1_(int *a, int dn, int sn, int cas) {
250
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
251
for (i = 0; i < sn; i++) S(i) -= (D_(i - 1) + D_(i) + 2) >> 2;
252
for (i = 0; i < dn; i++) D(i) += (S_(i) + S_(i + 1)) >> 1;
255
if (!sn && dn == 1) /* NEW : CASE ONE ELEMENT */
258
for (i = 0; i < sn; i++) D(i) -= (SS_(i) + SS_(i + 1) + 2) >> 2;
259
for (i = 0; i < dn; i++) S(i) += (DD_(i) + DD_(i - 1)) >> 1;
265
/* Inverse 5-3 wavelet transform in 1-D. */
267
static void dwt_decode_1(dwt_t *v) {
268
dwt_decode_1_(v->mem, v->dn, v->sn, v->cas);
272
/* Forward 9-7 wavelet transform in 1-D. */
274
static void dwt_encode_1_real(int *a, int dn, int sn, int cas) {
277
if ((dn > 0) || (sn > 1)) { /* NEW : CASE ONE ELEMENT */
278
for (i = 0; i < dn; i++)
279
D(i) -= fix_mul(S_(i) + S_(i + 1), 12993);
280
for (i = 0; i < sn; i++)
281
S(i) -= fix_mul(D_(i - 1) + D_(i), 434);
282
for (i = 0; i < dn; i++)
283
D(i) += fix_mul(S_(i) + S_(i + 1), 7233);
284
for (i = 0; i < sn; i++)
285
S(i) += fix_mul(D_(i - 1) + D_(i), 3633);
286
for (i = 0; i < dn; i++)
287
D(i) = fix_mul(D(i), 5038); /*5038 */
288
for (i = 0; i < sn; i++)
289
S(i) = fix_mul(S(i), 6659); /*6660 */
292
if ((sn > 0) || (dn > 1)) { /* NEW : CASE ONE ELEMENT */
293
for (i = 0; i < dn; i++)
294
S(i) -= fix_mul(DD_(i) + DD_(i - 1), 12993);
295
for (i = 0; i < sn; i++)
296
D(i) -= fix_mul(SS_(i) + SS_(i + 1), 434);
297
for (i = 0; i < dn; i++)
298
S(i) += fix_mul(DD_(i) + DD_(i - 1), 7233);
299
for (i = 0; i < sn; i++)
300
D(i) += fix_mul(SS_(i) + SS_(i + 1), 3633);
301
for (i = 0; i < dn; i++)
302
S(i) = fix_mul(S(i), 5038); /*5038 */
303
for (i = 0; i < sn; i++)
304
D(i) = fix_mul(D(i), 6659); /*6660 */
309
static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno_stepsize) {
311
p = int_floorlog2(stepsize) - 13;
312
n = 11 - int_floorlog2(stepsize);
313
bandno_stepsize->mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
314
bandno_stepsize->expn = numbps - p;
318
==========================================================
320
==========================================================
324
/* Forward 5-3 wavelet transform in 2-D. */
326
void dwt_encode(opj_tcd_tilecomp_t * tilec) {
333
w = tilec->x1-tilec->x0;
334
l = tilec->numresolutions-1;
337
for (i = 0; i < l; i++) {
338
int rw; /* width of the resolution level computed */
339
int rh; /* height of the resolution level computed */
340
int rw1; /* width of the resolution level once lower than computed one */
341
int rh1; /* height of the resolution level once lower than computed one */
342
int cas_col; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
343
int cas_row; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering */
346
rw = tilec->resolutions[l - i].x1 - tilec->resolutions[l - i].x0;
347
rh = tilec->resolutions[l - i].y1 - tilec->resolutions[l - i].y0;
348
rw1= tilec->resolutions[l - i - 1].x1 - tilec->resolutions[l - i - 1].x0;
349
rh1= tilec->resolutions[l - i - 1].y1 - tilec->resolutions[l - i - 1].y0;
351
cas_row = tilec->resolutions[l - i].x0 % 2;
352
cas_col = tilec->resolutions[l - i].y0 % 2;
356
bj = (int*)opj_malloc(rh * sizeof(int));
357
for (j = 0; j < rw; j++) {
359
for (k = 0; k < rh; k++) bj[k] = aj[k*w];
360
dwt_encode_1(bj, dn, sn, cas_col);
361
dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
367
bj = (int*)opj_malloc(rw * sizeof(int));
368
for (j = 0; j < rh; j++) {
370
for (k = 0; k < rw; k++) bj[k] = aj[k];
371
dwt_encode_1(bj, dn, sn, cas_row);
372
dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
380
/* Inverse 5-3 wavelet transform in 2-D. */
382
void dwt_decode(opj_tcd_tilecomp_t* tilec, int numres) {
383
dwt_decode_tile(tilec, numres, &dwt_decode_1);
388
/* Get gain of 5-3 wavelet transform. */
390
int dwt_getgain(int orient) {
393
if (orient == 1 || orient == 2)
399
/* Get norm of 5-3 wavelet. */
401
double dwt_getnorm(int level, int orient) {
402
return dwt_norms[orient][level];
406
/* Forward 9-7 wavelet transform in 2-D. */
409
void dwt_encode_real(opj_tcd_tilecomp_t * tilec) {
416
w = tilec->x1-tilec->x0;
417
l = tilec->numresolutions-1;
420
for (i = 0; i < l; i++) {
421
int rw; /* width of the resolution level computed */
422
int rh; /* height of the resolution level computed */
423
int rw1; /* width of the resolution level once lower than computed one */
424
int rh1; /* height of the resolution level once lower than computed one */
425
int cas_col; /* 0 = non inversion on horizontal filtering 1 = inversion between low-pass and high-pass filtering */
426
int cas_row; /* 0 = non inversion on vertical filtering 1 = inversion between low-pass and high-pass filtering */
429
rw = tilec->resolutions[l - i].x1 - tilec->resolutions[l - i].x0;
430
rh = tilec->resolutions[l - i].y1 - tilec->resolutions[l - i].y0;
431
rw1= tilec->resolutions[l - i - 1].x1 - tilec->resolutions[l - i - 1].x0;
432
rh1= tilec->resolutions[l - i - 1].y1 - tilec->resolutions[l - i - 1].y0;
434
cas_row = tilec->resolutions[l - i].x0 % 2;
435
cas_col = tilec->resolutions[l - i].y0 % 2;
439
bj = (int*)opj_malloc(rh * sizeof(int));
440
for (j = 0; j < rw; j++) {
442
for (k = 0; k < rh; k++) bj[k] = aj[k*w];
443
dwt_encode_1_real(bj, dn, sn, cas_col);
444
dwt_deinterleave_v(bj, aj, dn, sn, w, cas_col);
450
bj = (int*)opj_malloc(rw * sizeof(int));
451
for (j = 0; j < rh; j++) {
453
for (k = 0; k < rw; k++) bj[k] = aj[k];
454
dwt_encode_1_real(bj, dn, sn, cas_row);
455
dwt_deinterleave_h(bj, aj, dn, sn, cas_row);
463
/* Get gain of 9-7 wavelet transform. */
465
int dwt_getgain_real(int orient) {
471
/* Get norm of 9-7 wavelet. */
473
double dwt_getnorm_real(int level, int orient) {
474
return dwt_norms_real[orient][level];
477
void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec) {
478
int numbands, bandno;
479
numbands = 3 * tccp->numresolutions - 2;
480
for (bandno = 0; bandno < numbands; bandno++) {
482
int resno, level, orient, gain;
484
resno = (bandno == 0) ? 0 : ((bandno - 1) / 3 + 1);
485
orient = (bandno == 0) ? 0 : ((bandno - 1) % 3 + 1);
486
level = tccp->numresolutions - 1 - resno;
487
gain = (tccp->qmfbid == 0) ? 0 : ((orient == 0) ? 0 : (((orient == 1) || (orient == 2)) ? 1 : 2));
488
if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
491
double norm = dwt_norms_real[orient][level];
492
stepsize = (1 << (gain)) / norm;
494
dwt_encode_stepsize((int) floor(stepsize * 8192.0), prec + gain, &tccp->stepsizes[bandno]);
500
/* Determine maximum computed resolution level for inverse wavelet transform */
502
static int dwt_decode_max_resolution(opj_tcd_resolution_t* restrict r, int i) {
507
if( mr < ( w = r->x1 - r->x0 ) )
509
if( mr < ( w = r->y1 - r->y0 ) )
517
/* Inverse wavelet transform in 2-D. */
519
static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1D) {
523
opj_tcd_resolution_t* tr = tilec->resolutions;
525
int rw = tr->x1 - tr->x0; /* width of the resolution level computed */
526
int rh = tr->y1 - tr->y0; /* height of the resolution level computed */
528
int w = tilec->x1 - tilec->x0;
530
h.mem = opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
534
int * restrict tiledp = tilec->data;
541
rw = tr->x1 - tr->x0;
542
rh = tr->y1 - tr->y0;
547
for(j = 0; j < rh; ++j) {
548
dwt_interleave_h(&h, &tiledp[j*w]);
550
memcpy(&tiledp[j*w], h.mem, rw * sizeof(int));
556
for(j = 0; j < rw; ++j){
558
dwt_interleave_v(&v, &tiledp[j], w);
560
for(k = 0; k < rh; ++k) {
561
tiledp[k * w + j] = v.mem[k];
565
opj_aligned_free(h.mem);
568
static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, int size){
569
float* restrict bi = (float*) (w->wavelet + w->cas);
572
for(k = 0; k < 2; ++k){
573
for(i = 0; i < count; ++i){
577
if(j > size) continue;
580
if(j > size) continue;
583
if(j > size) continue;
586
bi = (float*) (w->wavelet + 1 - w->cas);
593
static void v4dwt_interleave_v(v4dwt_t* restrict v , float* restrict a , int x){
594
v4* restrict bi = v->wavelet + v->cas;
596
for(i = 0; i < v->sn; ++i){
597
memcpy(&bi[i*2], &a[i*x], 4 * sizeof(float));
600
bi = v->wavelet + 1 - v->cas;
601
for(i = 0; i < v->dn; ++i){
602
memcpy(&bi[i*2], &a[i*x], 4 * sizeof(float));
608
static void v4dwt_decode_step1_sse(v4* w, int count, const __m128 c){
609
__m128* restrict vw = (__m128*) w;
611
for(i = 0; i < count; ++i){
612
__m128 tmp = vw[i*2];
617
static void v4dwt_decode_step2_sse(v4* l, v4* w, int k, int m, __m128 c){
618
__m128* restrict vl = (__m128*) l;
619
__m128* restrict vw = (__m128*) w;
621
for(i = 0; i < m; ++i){
622
__m128 tmp1 = vl[ 0];
623
__m128 tmp2 = vw[-1];
624
__m128 tmp3 = vw[ 0];
625
vw[-1] = tmp2 + ((tmp1 + tmp3) * c);
643
static void v4dwt_decode_step1(v4* w, int count, const float c){
644
float* restrict fw = (float*) w;
646
for(i = 0; i < count; ++i){
647
float tmp1 = fw[i*8 ];
648
float tmp2 = fw[i*8 + 1];
649
float tmp3 = fw[i*8 + 2];
650
float tmp4 = fw[i*8 + 3];
652
fw[i*8 + 1] = tmp2 * c;
653
fw[i*8 + 2] = tmp3 * c;
654
fw[i*8 + 3] = tmp4 * c;
658
static void v4dwt_decode_step2(v4* l, v4* w, int k, int m, float c){
659
float* restrict fl = (float*) l;
660
float* restrict fw = (float*) w;
662
for(i = 0; i < m; ++i){
663
float tmp1_1 = fl[0];
664
float tmp1_2 = fl[1];
665
float tmp1_3 = fl[2];
666
float tmp1_4 = fl[3];
667
float tmp2_1 = fw[-4];
668
float tmp2_2 = fw[-3];
669
float tmp2_3 = fw[-2];
670
float tmp2_4 = fw[-1];
671
float tmp3_1 = fw[0];
672
float tmp3_2 = fw[1];
673
float tmp3_3 = fw[2];
674
float tmp3_4 = fw[3];
675
fw[-4] = tmp2_1 + ((tmp1_1 + tmp3_1) * c);
676
fw[-3] = tmp2_2 + ((tmp1_2 + tmp3_2) * c);
677
fw[-2] = tmp2_3 + ((tmp1_3 + tmp3_3) * c);
678
fw[-1] = tmp2_4 + ((tmp1_4 + tmp3_4) * c);
709
/* Inverse 9-7 wavelet transform in 1-D. */
711
static void v4dwt_decode(v4dwt_t* restrict dwt){
714
if(!((dwt->dn > 0) || (dwt->sn > 1))){
720
if(!((dwt->sn > 0) || (dwt->dn > 1))) {
727
v4dwt_decode_step1_sse(dwt->wavelet+a, dwt->sn, _mm_set1_ps(K));
728
v4dwt_decode_step1_sse(dwt->wavelet+b, dwt->dn, _mm_set1_ps(c13318));
729
v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_delta));
730
v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_gamma));
731
v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_beta));
732
v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_alpha));
734
v4dwt_decode_step1(dwt->wavelet+a, dwt->sn, K);
735
v4dwt_decode_step1(dwt->wavelet+b, dwt->dn, c13318);
736
v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_delta);
737
v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_gamma);
738
v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_beta);
739
v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_alpha);
744
/* Inverse 9-7 wavelet transform in 2-D. */
746
void dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){
750
opj_tcd_resolution_t* res = tilec->resolutions;
752
int rw = res->x1 - res->x0; /* width of the resolution level computed */
753
int rh = res->y1 - res->y0; /* height of the resolution level computed */
755
int w = tilec->x1 - tilec->x0;
757
h.wavelet = (v4*) opj_aligned_malloc((dwt_decode_max_resolution(res, numres)+5) * sizeof(v4));
758
v.wavelet = h.wavelet;
761
float * restrict aj = (float*) tilec->data;
762
int bufsize = (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0);
770
rw = res->x1 - res->x0; /* width of the resolution level computed */
771
rh = res->y1 - res->y0; /* height of the resolution level computed */
776
for(j = rh; j > 0; j -= 4){
777
v4dwt_interleave_h(&h, aj, w, bufsize);
781
for(k = rw; --k >= 0;){
782
aj[k ] = h.wavelet[k].f[0];
783
aj[k+w ] = h.wavelet[k].f[1];
784
aj[k+w*2] = h.wavelet[k].f[2];
785
aj[k+w*3] = h.wavelet[k].f[3];
789
for(k = rw; --k >= 0;){
791
case 3: aj[k+w*2] = h.wavelet[k].f[2];
792
case 2: aj[k+w ] = h.wavelet[k].f[1];
793
case 1: aj[k ] = h.wavelet[k].f[0];
804
aj = (float*) tilec->data;
805
for(j = rw; j > 0; j -= 4){
806
v4dwt_interleave_v(&v, aj, w);
810
for(k = 0; k < rh; ++k){
811
memcpy(&aj[k*w], &v.wavelet[k], 4 * sizeof(float));
815
for(k = 0; k < rh; ++k){
816
memcpy(&aj[k*w], &v.wavelet[k], j * sizeof(float));
823
opj_aligned_free(h.wavelet);