34 #define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n))
42 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++) {
110 if (h == 2)
return 8;
112 if (v >= 1)
return 7;
113 if (d >= 1)
return 6;
116 if (v == 2)
return 4;
117 if (v == 1)
return 3;
118 if (d >= 2)
return 2;
119 if (d == 1)
return 1;
121 if (d >= 3)
return 8;
123 if (h+v >= 1)
return 7;
127 if (h+v >= 2)
return 5;
128 if (h+v == 1)
return 4;
131 if (h+v >= 2)
return 2;
132 if (h+v == 1)
return 1;
139 static const int contribtab[3][3] = { { 0, -1, 1 }, { -1, -1, 0 }, { 1, 0, 1 } };
140 static const int ctxlbltab[3][3] = { { 13, 12, 11 }, { 10, 9, 10 }, { 11, 12, 13 } };
141 static const int xorbittab[3][3] = { { 1, 1, 1 }, { 1, 0, 0 }, { 0, 0, 0 } };
145 int vcontrib, hcontrib;
159 for (i = 0; i < 256; i++)
160 for (j = 0; j < 4; j++)
162 for (i = 0; i < 16; i++)
163 for (j = 0; j < 16; j++)
196 int cbps,
int dx,
int dy,
199 uint8_t log2_band_prec_width, log2_band_prec_height;
200 int reslevelno, bandno, gbandno = 0,
ret, i, j;
213 csize = (comp->
coord[0][1] - comp->
coord[0][0]) *
218 comp->
f_data = av_malloc_array(csize,
sizeof(*comp->
f_data));
223 comp->
i_data = av_malloc_array(csize,
sizeof(*comp->
i_data));
231 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
238 for (i = 0; i < 2; i++)
239 for (j = 0; j < 2; j++)
240 reslevel->
coord[i][j] =
259 if (reslevel->
coord[0][1] == reslevel->
coord[0][0])
267 if (reslevel->
coord[1][1] == reslevel->
coord[1][0])
275 reslevel->
band = av_malloc_array(reslevel->
nbands,
sizeof(*reslevel->
band));
279 for (bandno = 0; bandno < reslevel->
nbands; bandno++, gbandno++) {
298 2 + numbps - qntsty->
expn[gbandno]);
329 if (reslevelno == 0) {
331 for (i = 0; i < 2; i++)
332 for (j = 0; j < 2; j++)
346 for (i = 0; i < 2; i++)
347 for (j = 0; j < 2; j++)
351 (((bandno + 1 >> i) & 1) << declvl - 1),
366 for (j = 0; j < 2; j++)
368 for (j = 0; j < 2; j++)
373 sizeof(*band->
prec));
379 for (precno = 0; precno < nb_precincts; precno++) {
387 (1 << log2_band_prec_width);
392 (1 << log2_band_prec_height);
397 (1 << log2_band_prec_width);
402 (1 << log2_band_prec_height);
429 sizeof(*prec->
cblk));
455 if ((bandno + !!reslevelno) & 1) {
461 if ((bandno + !!reslevelno) & 2) {
482 int reslevelno, bandno, cblkno, precno;
483 for (reslevelno = 0; reslevelno < codsty->
nreslevels; reslevelno++) {
485 for (bandno = 0; bandno < rlevel->
nbands; bandno++) {
503 int reslevelno, bandno, precno;
509 for (bandno = 0; bandno < reslevel->
nbands; bandno++) {