51 thr = ((thr >> 1) + 4 * m->
cum_prob[0]) / thr;
53 return FFMIN(thr, 0x3FFF);
112 for (i = val - 1; i >= 0; i--)
133 for (i = 0; i < 15; i++)
134 for (j = 0; j < 4; j++)
139 int full_model_syms,
int special_initial_cache)
150 for (i = 0, idx = 0; i < 4; i++)
152 for (k = 0; k < 4; k++)
158 uint8_t *ngb,
int num_ngb,
int any_ngb)
163 if (val < pctx->num_syms) {
169 for (j = 0; j < num_ngb; j++)
170 if (pctx->
cache[i] == ngb[j])
180 pix = pctx->
cache[val];
184 if (pctx->
cache[i] == pix)
189 for (i = val; i > 0; i--)
191 pctx->
cache[0] = pix;
209 memset(neighbours, src[-1], 4);
215 neighbours[
TOP_LEFT] = src[-stride - 1];
216 neighbours[
LEFT] = src[-1];
219 neighbours[
TOP_RIGHT] = src[-stride + 1];
225 if (x >= 2 && src[-2] == neighbours[
LEFT])
227 if (y >= 2 && src[-2 * stride] == neighbours[
TOP])
231 ref_pix[0] = neighbours[0];
232 for (i = 1; i < 4; i++) {
233 for (j = 0; j < nlen; j++)
234 if (ref_pix[j] == neighbours[i])
237 ref_pix[nlen++] = neighbours[i];
245 if (neighbours[TOP] == neighbours[
TOP_LEFT]) {
246 if (neighbours[
TOP_RIGHT] == neighbours[TOP_LEFT])
248 else if (neighbours[LEFT] == neighbours[TOP_LEFT])
252 }
else if (neighbours[
TOP_RIGHT] == neighbours[TOP_LEFT]) {
253 if (neighbours[LEFT] == neighbours[TOP_LEFT])
257 }
else if (neighbours[LEFT] == neighbours[TOP_LEFT]) {
264 if (neighbours[TOP] == neighbours[TOP_LEFT])
266 else if (neighbours[
TOP_RIGHT] == neighbours[TOP_LEFT])
268 else if (neighbours[LEFT] == neighbours[TOP_LEFT])
270 else if (neighbours[
TOP_RIGHT] == neighbours[TOP])
272 else if (neighbours[TOP] == neighbours[LEFT])
292 int rgb_stride,
PixContext *pctx,
const uint32_t *pal)
295 uint8_t *rgb_dst = rgb_pic + x * 3 + y * rgb_stride;
299 for (j = 0; j <
height; j++) {
300 for (i = 0; i <
width; i++) {
305 i, j, width - i - 1);
309 AV_WB24(rgb_dst + i * 3, pal[p]);
312 rgb_dst += rgb_stride;
324 for (j = y; j < y +
height; j++) {
356 for (j = 0; j <
height; j++) {
357 memmove(dst, src, width);
358 memmove(rgb_dst, rgb_src, width * 3);
370 int mask_stride,
int x,
int y,
378 mask += x + y * mask_stride;
380 for (j = 0; j <
height; j++) {
381 for (i = 0; i <
width; i++) {
383 ( c->
rgb_pic && mask[i] != 0x01 && mask[i] != 0x02 && mask[i] != 0x04 ||
384 !c->
rgb_pic && mask[i] != 0x80 && mask[i] != 0xFF))
387 if (mask[i] == 0x02) {
389 }
else if (mask[i] == 0x04) {
392 }
else if (mask[i] != 0x80) {
397 i, j, width - i - 1);
412 int version,
int full_model_syms)
423 full_model_syms, version ? 1 : 0);
445 if ((base + 1) / 2 - 2 <= 0)
448 val = acoder->
get_number(acoder, (base + 1) / 2 - 2) + 3;
451 if ((
unsigned)val >= base)
454 return inv ? base - val : val;
466 int i, j, pix, rgb_pix;
473 rgb_pix = c->
pal[pix];
474 for (i = 0; i <
height; i++, dst +=
stride, rgb_dst += rgb_stride) {
475 memset(dst, pix, width);
477 for (j = 0; j < width * 3; j += 3)
501 ( c->
rgb_pic && mode != 0x01 && mode != 0x02 && mode != 0x04 ||
502 !c->
rgb_pic && mode != 0x80 && mode != 0xFF))
507 else if (mode == 0x04)
509 else if (mode != 0x80)
576 "Insufficient extradata size: expected %d got %d\n",
594 "Header version doesn't match codec tag\n");
601 "Incorrect number of changeable palette entries: %d\n",
625 "Insufficient extradata size %d for v2\n",
636 "Incorrect number of used colours %d\n",
647 for (i = 0; i < 256; i++)
649 (version ? 8 : 0) + i * 3);