54 for (i = e - 1; i >= 0; i--)
57 e = -(is_signed &&
get_rac(c, state + 11 +
FFMIN(e, 10)));
74 while (i < state->error_sum) {
80 av_dlog(
NULL,
"v:%d bias:%d error:%d drift:%d count:%d k:%d",
84 if (k == 0 && 2 * state->
drift <= -state->
count)
87 v ^= ((2 * state->
drift + state->
count) >> 31);
99 int plane_index,
int bits)
110 for (x = 0; x < w; x++) {
112 for (i=0; i<
bits; i++) {
121 for (x = 0; x < w; x++) {
122 int diff, context, sign;
124 context =
get_context(p, sample[1] + x, sample[0] + x, sample[1] + x);
136 if (context == 0 && run_mode == 0)
140 if (run_count == 0 && run_mode == 1) {
143 if (x + run_count <= w)
168 av_dlog(s->
avctx,
"count:%d index:%d, mode:%d, x:%d pos:%d\n",
175 sample[1][x] = (
predict(sample[1] + x, sample[0] + x) +
diff) &
182 int w,
int h,
int stride,
int plane_index)
193 for (y = 0; y < h; y++) {
194 int16_t *
temp = sample[0];
196 sample[0] = sample[1];
199 sample[1][-1] = sample[0][0];
200 sample[0][w] = sample[0][w - 1];
205 for (x = 0; x < w; x++)
206 src[x + stride * y] = sample[1][x];
210 for (x = 0; x < w; x++) {
211 ((uint16_t*)(src + stride*y))[x] = sample[1][x];
214 for (x = 0; x < w; x++) {
231 for (x = 0; x < 4; x++) {
240 for (y = 0; y < h; y++) {
242 int16_t *
temp = sample[p][0];
244 sample[p][0] = sample[p][1];
247 sample[p][1][-1]= sample[p][0][0 ];
248 sample[p][0][ w]= sample[p][0][w-1];
254 for (x = 0; x < w; x++) {
255 int g = sample[0][1][x];
256 int b = sample[1][1][x];
257 int r = sample[2][1][x];
258 int a = sample[3][1][x];
269 *((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + (g<<8) + (r<<16) + (a<<24);
271 *((uint16_t*)(src[0] + x*2 + stride[0]*y)) = b;
272 *((uint16_t*)(src[1] + x*2 + stride[1]*y)) = g;
273 *((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;
284 memset(state, 128,
sizeof(state));
325 }
else if (ps == 2) {
328 }
else if (ps == 3) {
388 memcpy(pdst, psrc,
sizeof(*pdst));
433 if (f->colorspace == 0) {
436 const int cx = x >> f->chroma_h_shift;
437 const int cy =
y >> f->chroma_v_shift;
440 if (f->chroma_planes) {
441 decode_plane(fs, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1);
442 decode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1);
444 if (fs->transparency)
447 uint8_t *planes[3] = { p->data[0] + ps * x +
y * p->linesize[0],
448 p->data[1] + ps * x +
y * p->linesize[1],
449 p->data[2] + ps * x +
y * p->linesize[2] };
452 if (fs->ac && f->version > 2) {
455 v = fs->c.bytestream_end - fs->c.bytestream - 2 - 5*f->ec;
458 fs->slice_damaged = 1;
475 memset(state, 128,
sizeof(state));
477 for (v = 0; i < 128; v++) {
484 quant_table[i] = scale *
v;
489 for (i = 1; i < 128; i++)
490 quant_table[256 - i] = -quant_table[i];
491 quant_table[128] = -quant_table[127];
502 for (i = 0; i < 5; i++) {
504 if (context_count > 32768
U) {
508 return (context_count + 1) / 2;
518 memset(state2, 128,
sizeof(state2));
519 memset(state, 128,
sizeof(state));
535 for (i = 1; i < 256; i++)
598 "global: ver:%d.%d, coder:%d, colorspace: %d bpr:%d chroma:%d(%d:%d), alpha:%d slices:%dx%d qtabs:%d ec:%d intra:%d\n",
619 memset(state, 128,
sizeof(state));
631 for (i = 1; i < 256; i++)
637 chroma_planes =
get_rac(c, state);
640 transparency =
get_rac(c, state);
730 "chroma subsampling not supported in this colorspace\n");
757 if (context_count < 0) {
768 int trailer = 3 + 5*!!f->
ec;
812 "quant_table_index out of range\n");
858 int buf_size = avpkt->
size;
893 "Cannot decode non-keyframe without valid keyframe\n");
908 buf_p = buf + buf_size;
911 int trailer = 3 + 5*!!f->
ec;
961 for (j = 0; j < 4; j++) {
1025 fsdst->
ac = fsrc->
ac;
1028 fsdst->
ec = fsrc->
ec;
1060 memcpy(fdst, fsrc,
sizeof(*fdst));