2
* Copyright (c) 1999-2000 Image Power, Inc. and the University of
4
* Copyright (c) 2001-2003 Michael David Adams.
8
/* __START_OF_JASPER_LICENSE__
10
* JasPer License Version 2.0
12
* Copyright (c) 2001-2006 Michael David Adams
13
* Copyright (c) 1999-2000 Image Power, Inc.
14
* Copyright (c) 1999-2000 The University of British Columbia
16
* All rights reserved.
18
* Permission is hereby granted, free of charge, to any person (the
19
* "User") obtaining a copy of this software and associated documentation
20
* files (the "Software"), to deal in the Software without restriction,
21
* including without limitation the rights to use, copy, modify, merge,
22
* publish, distribute, and/or sell copies of the Software, and to permit
23
* persons to whom the Software is furnished to do so, subject to the
24
* following conditions:
26
* 1. The above copyright notices and this permission notice (which
27
* includes the disclaimer below) shall be included in all copies or
28
* substantial portions of the Software.
30
* 2. The name of a copyright holder shall not be used to endorse or
31
* promote products derived from the Software without specific prior
34
* THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
35
* LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
36
* THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
37
* "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
39
* PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
40
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
41
* INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
42
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
43
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
44
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
45
* PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
46
* THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
47
* EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
48
* BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
49
* PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
50
* GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
51
* ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
52
* IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
53
* SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
54
* AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
55
* SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
56
* THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
57
* PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
58
* RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
59
* EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
61
* __END_OF_JASPER_LICENSE__
67
* $Id: jpc_t1dec.c,v 1.2 2008-05-26 09:40:52 vp153 Exp $
70
/******************************************************************************\
72
\******************************************************************************/
78
#include "jasper/jas_fix.h"
79
#include "jasper/jas_stream.h"
80
#include "jasper/jas_math.h"
83
#include "jpc_mqdec.h"
84
#include "jpc_t1dec.h"
85
#include "jpc_t1cod.h"
88
/******************************************************************************\
90
\******************************************************************************/
92
static int jpc_dec_decodecblk(jpc_dec_t *dec, jpc_dec_tile_t *tile, jpc_dec_tcomp_t *tcomp, jpc_dec_band_t *band,
93
jpc_dec_cblk_t *cblk, int dopartial, int maxlyrs);
94
static int dec_sigpass(jpc_dec_t *dec, jpc_mqdec_t *mqdec, int bitpos, int orient,
95
int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data);
96
static int dec_rawsigpass(jpc_dec_t *dec, jpc_bitstream_t *in, int bitpos,
97
int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data);
98
static int dec_refpass(jpc_dec_t *dec, jpc_mqdec_t *mqdec, int bitpos, int vcausalflag,
99
jas_matrix_t *flags, jas_matrix_t *data);
100
static int dec_rawrefpass(jpc_dec_t *dec, jpc_bitstream_t *in, int bitpos,
101
int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data);
102
static int dec_clnpass(jpc_dec_t *dec, jpc_mqdec_t *mqdec, int bitpos, int orient,
103
int vcausalflag, int segsymflag, jas_matrix_t *flags, jas_matrix_t *data);
106
static long t1dec_cnt = 0;
110
#define JPC_T1D_GETBIT(mqdec, v, passtypename, symtypename) \
111
((v) = jpc_mqdec_getbit(mqdec))
113
#define JPC_T1D_GETBIT(mqdec, v, passtypename, symtypename) \
115
(v) = jpc_mqdec_getbit(mqdec); \
116
if (jas_getdbglevel() >= 100) { \
117
jas_eprintf("index = %ld; passtype = %s; symtype = %s; sym = %d\n", t1dec_cnt, passtypename, symtypename, v); \
122
#define JPC_T1D_GETBITNOSKEW(mqdec, v, passtypename, symtypename) \
123
JPC_T1D_GETBIT(mqdec, v, passtypename, symtypename)
126
#define JPC_T1D_RAWGETBIT(bitstream, v, passtypename, symtypename) \
127
((v) = jpc_bitstream_getbit(bitstream))
129
#define JPC_T1D_RAWGETBIT(bitstream, v, passtypename, symtypename) \
131
(v) = jpc_bitstream_getbit(bitstream); \
132
if (jas_getdbglevel() >= 100) { \
133
jas_eprintf("index = %ld; passtype = %s; symtype = %s; sym = %d\n", t1dec_cnt, passtypename, symtypename, v); \
139
/******************************************************************************\
141
\******************************************************************************/
143
int jpc_dec_decodecblks(jpc_dec_t *dec, jpc_dec_tile_t *tile)
145
jpc_dec_tcomp_t *tcomp;
147
jpc_dec_rlvl_t *rlvl;
149
jpc_dec_band_t *band;
153
jpc_dec_cblk_t *cblk;
156
for (compcnt = dec->numcomps, tcomp = tile->tcomps; compcnt > 0;
157
--compcnt, ++tcomp) {
158
for (rlvlcnt = tcomp->numrlvls, rlvl = tcomp->rlvls;
159
rlvlcnt > 0; --rlvlcnt, ++rlvl) {
163
for (bandcnt = rlvl->numbands, band = rlvl->bands;
164
bandcnt > 0; --bandcnt, ++band) {
168
for (prccnt = rlvl->numprcs, prc = band->prcs;
169
prccnt > 0; --prccnt, ++prc) {
173
for (cblkcnt = prc->numcblks,
174
cblk = prc->cblks; cblkcnt > 0;
176
if (jpc_dec_decodecblk(dec, tile, tcomp,
177
band, cblk, 1, JPC_MAXLYRS)) {
190
static int jpc_dec_decodecblk(jpc_dec_t *dec, jpc_dec_tile_t *tile, jpc_dec_tcomp_t *tcomp, jpc_dec_band_t *band,
191
jpc_dec_cblk_t *cblk, int dopartial, int maxlyrs)
203
compno = tcomp - tile->tcomps;
206
/* Note: matrix is assumed to be zeroed */
207
if (!(cblk->flags = jas_matrix_create(jas_matrix_numrows(cblk->data) +
208
2, jas_matrix_numcols(cblk->data) + 2))) {
213
seg = cblk->segs.head;
214
while (seg && (seg != cblk->curseg || dopartial) && (maxlyrs < 0 ||
215
seg->lyrno < maxlyrs)) {
216
assert(seg->numpasses >= seg->maxpasses || dopartial);
218
jas_stream_rewind(seg->stream);
219
jas_stream_setrwcount(seg->stream, 0);
220
if (seg->type == JPC_SEG_MQ) {
222
if (!(cblk->mqdec = jpc_mqdec_create(JPC_NUMCTXS, 0))) {
225
jpc_mqdec_setctxs(cblk->mqdec, JPC_NUMCTXS, jpc_mqctxs);
227
jpc_mqdec_setinput(cblk->mqdec, seg->stream);
228
jpc_mqdec_init(cblk->mqdec);
230
assert(seg->type == JPC_SEG_RAW);
231
if (!cblk->nulldec) {
232
if (!(cblk->nulldec = jpc_bitstream_sopen(seg->stream, "r"))) {
239
for (i = 0; i < seg->numpasses; ++i) {
240
if (cblk->numimsbs > band->numbps) {
241
ccp = &tile->cp->ccps[compno];
242
if (ccp->roishift <= 0) {
243
jas_eprintf("warning: corrupt code stream\n");
245
if (cblk->numimsbs < ccp->roishift - band->numbps) {
246
jas_eprintf("warning: corrupt code stream\n");
250
bpno = band->roishift + band->numbps - 1 - (cblk->numimsbs +
251
(seg->passno + i - cblk->firstpassno + 2) / 3);
256
passtype = (seg->passno + i + 2) % 3;
258
passtype = JPC_PASSTYPE(seg->passno + i + 2);
260
assert(bpno >= 0 && bpno < 31);
263
ret = (seg->type == JPC_SEG_MQ) ? dec_sigpass(dec,
264
cblk->mqdec, bpno, band->orient,
265
(tile->cp->ccps[compno].cblkctx & JPC_COX_VSC) != 0,
266
cblk->flags, cblk->data) :
267
dec_rawsigpass(dec, cblk->nulldec, bpno,
268
(tile->cp->ccps[compno].cblkctx & JPC_COX_VSC) != 0,
269
cblk->flags, cblk->data);
272
ret = (seg->type == JPC_SEG_MQ) ?
273
dec_refpass(dec, cblk->mqdec, bpno,
274
(tile->cp->ccps[compno].cblkctx & JPC_COX_VSC) != 0,
275
cblk->flags, cblk->data) :
276
dec_rawrefpass(dec, cblk->nulldec, bpno,
277
(tile->cp->ccps[compno].cblkctx & JPC_COX_VSC) != 0,
278
cblk->flags, cblk->data);
281
assert(seg->type == JPC_SEG_MQ);
282
ret = dec_clnpass(dec, cblk->mqdec, bpno,
283
band->orient, (tile->cp->ccps[compno].cblkctx &
284
JPC_COX_VSC) != 0, (tile->cp->ccps[compno].cblkctx &
285
JPC_COX_SEGSYM) != 0, cblk->flags,
292
/* Do we need to reset after each coding pass? */
293
if (tile->cp->ccps[compno].cblkctx & JPC_COX_RESET) {
294
jpc_mqdec_setctxs(cblk->mqdec, JPC_NUMCTXS, jpc_mqctxs);
298
jas_eprintf("coding pass failed passtype=%d segtype=%d\n", passtype, seg->type);
304
if (seg->type == JPC_SEG_MQ) {
305
/* Note: dont destroy mq decoder because context info will be lost */
307
assert(seg->type == JPC_SEG_RAW);
308
if (tile->cp->ccps[compno].cblkctx & JPC_COX_PTERM) {
315
if ((ret = jpc_bitstream_inalign(cblk->nulldec, fillmask,
318
} else if (ret > 0) {
319
jas_eprintf("warning: bad termination pattern detected\n");
321
jpc_bitstream_close(cblk->nulldec);
325
cblk->curseg = seg->next;
326
jpc_seglist_remove(&cblk->segs, seg);
327
jpc_seg_destroy(seg);
331
assert(dopartial ? (!cblk->curseg) : 1);
337
/******************************************************************************\
338
* Code for significance pass.
339
\******************************************************************************/
341
#define jpc_sigpass_step(fp, frowstep, dp, bitpos, oneplushalf, orient, mqdec, vcausalflag) \
346
if ((f & JPC_OTHSIGMSK) && !(f & (JPC_SIG | JPC_VISIT))) { \
347
jpc_mqdec_setcurctx((mqdec), JPC_GETZCCTXNO(f, (orient))); \
348
JPC_T1D_GETBIT((mqdec), v, "SIG", "ZC"); \
350
jpc_mqdec_setcurctx((mqdec), JPC_GETSCCTXNO(f)); \
351
JPC_T1D_GETBIT((mqdec), v, "SIG", "SC"); \
352
v ^= JPC_GETSPB(f); \
353
JPC_UPDATEFLAGS4((fp), (frowstep), v, (vcausalflag)); \
355
*(dp) = (v) ? (-(oneplushalf)) : (oneplushalf); \
357
*(fp) |= JPC_VISIT; \
361
static int dec_sigpass(jpc_dec_t *dec, register jpc_mqdec_t *mqdec, int bitpos, int orient,
362
int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data)
375
jpc_fix_t *fstripestart;
376
jpc_fix_t *fvscanstart;
380
jpc_fix_t *dstripestart;
381
jpc_fix_t *dvscanstart;
384
/* Avoid compiler warning about unused parameters. */
387
width = jas_matrix_numcols(data);
388
height = jas_matrix_numrows(data);
389
frowstep = jas_matrix_rowstep(flags);
390
drowstep = jas_matrix_rowstep(data);
391
fstripestep = frowstep << 2;
392
dstripestep = drowstep << 2;
396
oneplushalf = one | half;
398
fstripestart = jas_matrix_getref(flags, 1, 1);
399
dstripestart = jas_matrix_getref(data, 0, 0);
400
for (i = height; i > 0; i -= 4, fstripestart += fstripestep,
401
dstripestart += dstripestep) {
402
fvscanstart = fstripestart;
403
dvscanstart = dstripestart;
404
vscanlen = JAS_MIN(i, 4);
405
for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) {
410
/* Process first sample in vertical scan. */
411
jpc_sigpass_step(fp, frowstep, dp, bitpos, oneplushalf,
412
orient, mqdec, vcausalflag);
419
/* Process second sample in vertical scan. */
420
jpc_sigpass_step(fp, frowstep, dp, bitpos, oneplushalf,
428
/* Process third sample in vertical scan. */
429
jpc_sigpass_step(fp, frowstep, dp, bitpos, oneplushalf,
437
/* Process fourth sample in vertical scan. */
438
jpc_sigpass_step(fp, frowstep, dp, bitpos, oneplushalf,
445
#define jpc_rawsigpass_step(fp, frowstep, dp, oneplushalf, in, vcausalflag) \
447
jpc_fix_t f = *(fp); \
449
if ((f & JPC_OTHSIGMSK) && !(f & (JPC_SIG | JPC_VISIT))) { \
450
JPC_T1D_RAWGETBIT(in, v, "SIG", "ZC"); \
455
JPC_T1D_RAWGETBIT(in, v, "SIG", "SC"); \
459
JPC_UPDATEFLAGS4((fp), (frowstep), v, (vcausalflag)); \
461
*(dp) = v ? (-oneplushalf) : (oneplushalf); \
463
*(fp) |= JPC_VISIT; \
467
static int dec_rawsigpass(jpc_dec_t *dec, jpc_bitstream_t *in, int bitpos, int vcausalflag,
468
jas_matrix_t *flags, jas_matrix_t *data)
482
jpc_fix_t *fstripestart;
483
jpc_fix_t *fvscanstart;
487
jpc_fix_t *dstripestart;
488
jpc_fix_t *dvscanstart;
490
/* Avoid compiler warning about unused parameters. */
493
width = jas_matrix_numcols(data);
494
height = jas_matrix_numrows(data);
495
frowstep = jas_matrix_rowstep(flags);
496
drowstep = jas_matrix_rowstep(data);
497
fstripestep = frowstep << 2;
498
dstripestep = drowstep << 2;
502
oneplushalf = one | half;
504
fstripestart = jas_matrix_getref(flags, 1, 1);
505
dstripestart = jas_matrix_getref(data, 0, 0);
506
for (i = height; i > 0; i -= 4, fstripestart += fstripestep,
507
dstripestart += dstripestep) {
508
fvscanstart = fstripestart;
509
dvscanstart = dstripestart;
510
vscanlen = JAS_MIN(i, 4);
511
for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) {
516
/* Process first sample in vertical scan. */
517
jpc_rawsigpass_step(fp, frowstep, dp, oneplushalf,
525
/* Process second sample in vertical scan. */
526
jpc_rawsigpass_step(fp, frowstep, dp, oneplushalf,
534
/* Process third sample in vertical scan. */
535
jpc_rawsigpass_step(fp, frowstep, dp, oneplushalf,
543
/* Process fourth sample in vertical scan. */
544
jpc_rawsigpass_step(fp, frowstep, dp, oneplushalf,
552
/******************************************************************************\
553
* Code for refinement pass.
554
\******************************************************************************/
556
#define jpc_refpass_step(fp, dp, poshalf, neghalf, mqdec, vcausalflag) \
560
if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \
561
jpc_mqdec_setcurctx((mqdec), JPC_GETMAGCTXNO(*(fp))); \
562
JPC_T1D_GETBITNOSKEW((mqdec), v, "REF", "MR"); \
563
t = (v ? (poshalf) : (neghalf)); \
564
*(dp) += (*(dp) < 0) ? (-t) : t; \
565
*(fp) |= JPC_REFINE; \
569
static int dec_refpass(jpc_dec_t *dec, register jpc_mqdec_t *mqdec, int bitpos,
570
int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data)
583
jpc_fix_t *fstripestart;
584
jpc_fix_t *fvscanstart;
588
jpc_fix_t *dstripestart;
589
jpc_fix_t *dvscanstart;
592
/* Avoid compiler warning about unused parameters. */
596
width = jas_matrix_numcols(data);
597
height = jas_matrix_numrows(data);
598
frowstep = jas_matrix_rowstep(flags);
599
drowstep = jas_matrix_rowstep(data);
600
fstripestep = frowstep << 2;
601
dstripestep = drowstep << 2;
605
neghalf = (bitpos > 0) ? (-poshalf) : (-1);
607
fstripestart = jas_matrix_getref(flags, 1, 1);
608
dstripestart = jas_matrix_getref(data, 0, 0);
609
for (i = height; i > 0; i -= 4, fstripestart += fstripestep,
610
dstripestart += dstripestep) {
611
fvscanstart = fstripestart;
612
dvscanstart = dstripestart;
613
vscanlen = JAS_MIN(i, 4);
614
for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) {
619
/* Process first sample in vertical scan. */
620
jpc_refpass_step(fp, dp, poshalf, neghalf, mqdec,
628
/* Process second sample in vertical scan. */
629
jpc_refpass_step(fp, dp, poshalf, neghalf, mqdec, 0);
636
/* Process third sample in vertical scan. */
637
jpc_refpass_step(fp, dp, poshalf, neghalf, mqdec, 0);
644
/* Process fourth sample in vertical scan. */
645
jpc_refpass_step(fp, dp, poshalf, neghalf, mqdec, 0);
652
#define jpc_rawrefpass_step(fp, dp, poshalf, neghalf, in, vcausalflag) \
656
if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \
657
JPC_T1D_RAWGETBIT(in, v, "REF", "MAGREF"); \
661
t = (v ? poshalf : neghalf); \
662
*(dp) += (*(dp) < 0) ? (-t) : t; \
663
*(fp) |= JPC_REFINE; \
667
static int dec_rawrefpass(jpc_dec_t *dec, jpc_bitstream_t *in, int bitpos, int vcausalflag,
668
jas_matrix_t *flags, jas_matrix_t *data)
682
jpc_fix_t *fstripestart;
683
jpc_fix_t *fvscanstart;
687
jpc_fix_t *dstripestart;
688
jpc_fix_t *dvscanstart;
690
/* Avoid compiler warning about unused parameters. */
694
width = jas_matrix_numcols(data);
695
height = jas_matrix_numrows(data);
696
frowstep = jas_matrix_rowstep(flags);
697
drowstep = jas_matrix_rowstep(data);
698
fstripestep = frowstep << 2;
699
dstripestep = drowstep << 2;
703
neghalf = (bitpos > 0) ? (-poshalf) : (-1);
705
fstripestart = jas_matrix_getref(flags, 1, 1);
706
dstripestart = jas_matrix_getref(data, 0, 0);
707
for (i = height; i > 0; i -= 4, fstripestart += fstripestep,
708
dstripestart += dstripestep) {
709
fvscanstart = fstripestart;
710
dvscanstart = dstripestart;
711
vscanlen = JAS_MIN(i, 4);
712
for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) {
717
/* Process first sample in vertical scan. */
718
jpc_rawrefpass_step(fp, dp, poshalf, neghalf, in,
726
/* Process second sample in vertical scan. */
727
jpc_rawrefpass_step(fp, dp, poshalf, neghalf, in, 0);
734
/* Process third sample in vertical scan. */
735
jpc_rawrefpass_step(fp, dp, poshalf, neghalf, in, 0);
742
/* Process fourth sample in vertical scan. */
743
jpc_rawrefpass_step(fp, dp, poshalf, neghalf, in, 0);
749
/******************************************************************************\
750
* Code for cleanup pass.
751
\******************************************************************************/
753
#define jpc_clnpass_step(f, fp, frowstep, dp, oneplushalf, orient, mqdec, flabel, plabel, vcausalflag) \
757
if (!((f) & (JPC_SIG | JPC_VISIT))) { \
758
jpc_mqdec_setcurctx((mqdec), JPC_GETZCCTXNO((f), (orient))); \
759
JPC_T1D_GETBIT((mqdec), v, "CLN", "ZC"); \
762
/* Coefficient is significant. */ \
763
jpc_mqdec_setcurctx((mqdec), JPC_GETSCCTXNO(f)); \
764
JPC_T1D_GETBIT((mqdec), v, "CLN", "SC"); \
765
v ^= JPC_GETSPB(f); \
766
*(dp) = (v) ? (-(oneplushalf)) : (oneplushalf); \
767
JPC_UPDATEFLAGS4((fp), (frowstep), v, (vcausalflag)); \
771
/* XXX - Is this correct? Can aggregation cause some VISIT bits not to be reset? Check. */ \
772
*(fp) &= ~JPC_VISIT; \
775
static int dec_clnpass(jpc_dec_t *dec, register jpc_mqdec_t *mqdec, int bitpos, int orient,
776
int vcausalflag, int segsymflag, jas_matrix_t *flags, jas_matrix_t *data)
794
jpc_fix_t *fstripestart;
795
jpc_fix_t *fvscanstart;
800
jpc_fix_t *dstripestart;
801
jpc_fix_t *dvscanstart;
803
/* Avoid compiler warning about unused parameters. */
808
oneplushalf = one | half;
810
width = jas_matrix_numcols(data);
811
height = jas_matrix_numrows(data);
813
frowstep = jas_matrix_rowstep(flags);
814
drowstep = jas_matrix_rowstep(data);
815
fstripestep = frowstep << 2;
816
dstripestep = drowstep << 2;
818
fstripestart = jas_matrix_getref(flags, 1, 1);
819
dstripestart = jas_matrix_getref(data, 0, 0);
820
for (i = 0; i < height; i += 4, fstripestart += fstripestep,
821
dstripestart += dstripestep) {
822
fvscanstart = fstripestart;
823
dvscanstart = dstripestart;
824
vscanlen = JAS_MIN(4, height - i);
825
for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) {
827
if (vscanlen >= 4 && (!((*fp) & (JPC_SIG | JPC_VISIT |
828
JPC_OTHSIGMSK))) && (fp += frowstep, !((*fp) & (JPC_SIG |
829
JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep, !((*fp) &
830
(JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep,
831
!((*fp) & (JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK)))) {
833
jpc_mqdec_setcurctx(mqdec, JPC_AGGCTXNO);
834
JPC_T1D_GETBIT(mqdec, v, "CLN", "AGG");
838
jpc_mqdec_setcurctx(mqdec, JPC_UCTXNO);
839
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "RL");
841
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "RL");
842
runlen = (runlen << 1) | v;
843
f = *(fp = fvscanstart + frowstep * runlen);
844
dp = dvscanstart + drowstep * runlen;
845
k = vscanlen - runlen;
848
goto clnpass_partial0;
851
goto clnpass_partial1;
854
goto clnpass_partial2;
857
goto clnpass_partial3;
861
f = *(fp = fvscanstart);
867
/* Process first sample in vertical scan. */
868
jpc_clnpass_step(f, fp, frowstep, dp, oneplushalf, orient,
869
mqdec, clnpass_full0:, clnpass_partial0:,
877
/* Process second sample in vertical scan. */
879
jpc_clnpass_step(f, fp, frowstep, dp, oneplushalf, orient,
880
mqdec, ;, clnpass_partial1:, 0);
887
/* Process third sample in vertical scan. */
889
jpc_clnpass_step(f, fp, frowstep, dp, oneplushalf, orient,
890
mqdec, ;, clnpass_partial2:, 0);
897
/* Process fourth sample in vertical scan. */
899
jpc_clnpass_step(f, fp, frowstep, dp, oneplushalf, orient,
900
mqdec, ;, clnpass_partial3:, 0);
907
jpc_mqdec_setcurctx(mqdec, JPC_UCTXNO);
908
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "SEGSYM");
909
segsymval = (segsymval << 1) | (v & 1);
910
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "SEGSYM");
911
segsymval = (segsymval << 1) | (v & 1);
912
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "SEGSYM");
913
segsymval = (segsymval << 1) | (v & 1);
914
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "SEGSYM");
915
segsymval = (segsymval << 1) | (v & 1);
916
if (segsymval != 0xa) {
917
jas_eprintf("warning: bad segmentation symbol\n");