33 #define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n))
41 while (w > 1 || h > 1) {
43 if (res + 1 >= INT32_MAX)
65 while (w > 1 || h > 1) {
74 for (i = 0; i < ph; i++)
75 for (j = 0; j < pw; j++)
76 t[i * pw + j].parent = &t2[(i >> 1) * w + (j >> 1)];
143 static const int contribtab[3][3] = { { 0, -1, 1 }, { -1, -1, 0 }, { 1, 0, 1 } };
144 static const int ctxlbltab[3][3] = { { 13, 12, 11 }, { 10, 9, 10 }, { 11, 12, 13 } };
145 static const int xorbittab[3][3] = { { 1, 1, 1 }, { 1, 0, 0 }, { 0, 0, 0 } };
149 int vcontrib, hcontrib;
163 for (i = 0; i < 256; i++)
164 for (j = 0; j < 4; j++)
166 for (i = 0; i < 16; i++)
167 for (j = 0; j < 16; j++)
200 int cbps,
int dx,
int dy,
203 uint8_t log2_band_prec_width, log2_band_prec_height;
204 int reslevelno, bandno, gbandno = 0, ret, i, j;
217 csize = (comp->
coord[0][1] - comp->
coord[0][0]) *
235 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
242 for (i = 0; i < 2; i++)
243 for (j = 0; j < 2; j++)
244 reslevel->
coord[i][j] =
263 if (reslevel->
coord[0][1] == reslevel->
coord[0][0])
271 if (reslevel->
coord[1][1] == reslevel->
coord[1][0])
283 for (bandno = 0; bandno < reslevel->
nbands; bandno++, gbandno++) {
302 2 + numbps - qntsty->
expn[gbandno]);
333 if (reslevelno == 0) {
335 for (i = 0; i < 2; i++)
336 for (j = 0; j < 2; j++)
350 for (i = 0; i < 2; i++)
351 for (j = 0; j < 2; j++)
355 (((bandno + 1 >> i) & 1) << declvl - 1),
370 for (j = 0; j < 2; j++)
372 for (j = 0; j < 2; j++)
377 sizeof(*band->
prec));
383 for (precno = 0; precno < nb_precincts; precno++) {
391 (1 << log2_band_prec_width);
396 (1 << log2_band_prec_height);
401 (1 << log2_band_prec_width);
406 (1 << log2_band_prec_height);
433 sizeof(*prec->
cblk));
459 if ((bandno + !!reslevelno) & 1) {
465 if ((bandno + !!reslevelno) & 2) {
486 int reslevelno, bandno, precno;
495 reslevel = comp->
reslevel + reslevelno;
496 for (bandno = 0; bandno < reslevel->
nbands; bandno++) {
502 band = reslevel->
band + bandno;
509 prec = band->
prec + precno;