35 #define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n))
43 while (w > 1 || h > 1) {
59 t = res = av_mallocz_array(tt_size,
sizeof(*t));
63 while (w > 1 || h > 1) {
72 for (i = 0; i < ph; i++)
73 for (j = 0; j < pw; j++)
74 t[i * pw + j].parent = &t2[(i >> 1) * w + (j >> 1)];
86 for (i = 0; i < siz; i++) {
108 if (h == 2)
return 8;
110 if (v >= 1)
return 7;
111 if (d >= 1)
return 6;
114 if (v == 2)
return 4;
115 if (v == 1)
return 3;
116 if (d >= 2)
return 2;
117 if (d == 1)
return 1;
119 if (d >= 3)
return 8;
121 if (h+v >= 1)
return 7;
125 if (h+v >= 2)
return 5;
126 if (h+v == 1)
return 4;
129 if (h+v >= 2)
return 2;
130 if (h+v == 1)
return 1;
136 static const int contribtab[3][3] = { { 0, -1, 1 }, { -1, -1, 0 }, { 1, 0, 1 } };
137 static const int ctxlbltab[3][3] = { { 13, 12, 11 }, { 10, 9, 10 }, { 11, 12, 13 } };
138 static const int xorbittab[3][3] = { { 1, 1, 1 }, { 1, 0, 0 }, { 0, 0, 0 } };
142 int vcontrib, hcontrib;
181 int cbps,
int dx,
int dy,
184 uint8_t log2_band_prec_width, log2_band_prec_height;
185 int reslevelno, bandno, gbandno = 0,
ret, i, j, csize = 1;
189 for (i = 0; i < 2; i++)
190 csize *= comp->
coord[i][1] - comp->
coord[i][0];
192 comp->
data = av_malloc_array(csize,
sizeof(*comp->
data));
199 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
206 for (i = 0; i < 2; i++)
207 for (j = 0; j < 2; j++)
208 reslevel->
coord[i][j] =
227 if (reslevel->
coord[0][1] == reslevel->
coord[0][0])
235 if (reslevel->
coord[1][1] == reslevel->
coord[1][0])
243 reslevel->
band = av_malloc_array(reslevel->
nbands,
sizeof(*reslevel->
band));
247 for (bandno = 0; bandno < reslevel->
nbands; bandno++, gbandno++) {
266 2 + numbps - qntsty->
expn[gbandno]);
297 if (reslevelno == 0) {
299 for (i = 0; i < 2; i++)
300 for (j = 0; j < 2; j++)
314 for (i = 0; i < 2; i++)
315 for (j = 0; j < 2; j++)
319 (((bandno + 1 >> i) & 1) << declvl - 1),
334 for (j = 0; j < 2; j++)
336 for (j = 0; j < 2; j++)
341 sizeof(*band->
prec));
347 for (precno = 0; precno < nb_precincts; precno++) {
355 (1 << log2_band_prec_width);
360 (1 << log2_band_prec_height);
365 (1 << log2_band_prec_width);
370 (1 << log2_band_prec_height);
397 sizeof(*prec->
cblk));
423 if((bandno + !!reslevelno) & 1) {
427 if((bandno + !!reslevelno) & 2) {
446 int reslevelno, bandno, cblkno, precno;
447 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
449 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
467 int reslevelno, bandno, precno;
468 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
471 for (bandno = 0; bandno < reslevel->
nbands; bandno++) {