36 #define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n))
44 while (w > 1 || h > 1) {
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)];
88 for (i = 0; i < siz; i++) {
112 if (h == 2)
return 8;
114 if (v >= 1)
return 7;
115 if (d >= 1)
return 6;
118 if (v == 2)
return 4;
119 if (v == 1)
return 3;
120 if (d >= 2)
return 2;
121 if (d == 1)
return 1;
123 if (d >= 3)
return 8;
125 if (h+v >= 1)
return 7;
129 if (h+v >= 2)
return 5;
130 if (h+v == 1)
return 4;
133 if (h+v >= 2)
return 2;
134 if (h+v == 1)
return 1;
141 static const int contribtab[3][3] = { { 0, -1, 1 }, { -1, -1, 0 }, { 1, 0, 1 } };
142 static const int ctxlbltab[3][3] = { { 13, 12, 11 }, { 10, 9, 10 }, { 11, 12, 13 } };
143 static const int xorbittab[3][3] = { { 1, 1, 1 }, { 1, 0, 0 }, { 0, 0, 0 } };
147 int vcontrib, hcontrib;
161 for (i = 0; i < 256; i++)
162 for (j = 0; j < 4; j++)
164 for (i = 0; i < 16; i++)
165 for (j = 0; j < 16; j++)
198 int cbps,
int dx,
int dy,
201 uint8_t log2_band_prec_width, log2_band_prec_height;
202 int reslevelno, bandno, gbandno = 0,
ret, i, j;
216 comp->
coord[1][1] - comp->
coord[1][0], 0, avctx))
218 csize = (comp->
coord[0][1] - comp->
coord[0][0]) *
220 if (comp->
coord[0][1] > 32768 ||
221 comp->
coord[1][1] > 32768) {
241 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
248 for (i = 0; i < 2; i++)
249 for (j = 0; j < 2; j++)
250 reslevel->
coord[i][j] =
269 if (reslevel->
coord[0][1] == reslevel->
coord[0][0])
277 if (reslevel->
coord[1][1] == reslevel->
coord[1][0])
289 for (bandno = 0; bandno < reslevel->
nbands; bandno++, gbandno++) {
308 2 + numbps - qntsty->
expn[gbandno]);
339 if (reslevelno == 0) {
341 for (i = 0; i < 2; i++)
342 for (j = 0; j < 2; j++)
356 for (i = 0; i < 2; i++)
357 for (j = 0; j < 2; j++)
361 (((bandno + 1 >> i) & 1) << declvl - 1),
376 for (j = 0; j < 2; j++)
378 for (j = 0; j < 2; j++)
390 for (precno = 0; precno < nb_precincts; precno++) {
399 (1 << log2_band_prec_width);
404 (1 << log2_band_prec_height);
409 (1 << log2_band_prec_width);
414 (1 << log2_band_prec_height);
447 for (cblkno = 0; cblkno < nb_codeblocks; cblkno++) {
470 if ((bandno + !!reslevelno) & 1) {
476 if ((bandno + !!reslevelno) & 2) {
497 int reslevelno, bandno, cblkno, precno;
498 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
500 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
518 int reslevelno, bandno, precno;
527 reslevel = comp->
reslevel + reslevelno;
528 for (bandno = 0; bandno < reslevel->
nbands; bandno++) {
534 band = reslevel->
band + bandno;