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) {
378 memcpy(pdst, psrc,
sizeof(*pdst));
423 if (f->colorspace == 0) {
426 const int cx = x >> f->chroma_h_shift;
427 const int cy =
y >> f->chroma_v_shift;
430 if (f->chroma_planes) {
431 decode_plane(fs, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1);
432 decode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1);
434 if (fs->transparency)
437 uint8_t *planes[3] = { p->data[0] + ps * x +
y * p->linesize[0],
438 p->data[1] + ps * x +
y * p->linesize[1],
439 p->data[2] + ps * x +
y * p->linesize[2] };
442 if (fs->ac && f->version > 2) {
445 v = fs->c.bytestream_end - fs->c.bytestream - 2 - 5*f->ec;
448 fs->slice_damaged = 1;
465 memset(state, 128,
sizeof(state));
467 for (v = 0; i < 128; v++) {
474 quant_table[i] = scale *
v;
479 for (i = 1; i < 128; i++)
480 quant_table[256 - i] = -quant_table[i];
481 quant_table[128] = -quant_table[127];
492 for (i = 0; i < 5; i++) {
494 if (context_count > 32768
U) {
498 return (context_count + 1) / 2;
508 memset(state2, 128,
sizeof(state2));
509 memset(state, 128,
sizeof(state));
525 for (i = 1; i < 256; i++)
588 "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",
609 memset(state, 128,
sizeof(state));
621 for (i = 1; i < 256; i++)
627 chroma_planes =
get_rac(c, state);
630 transparency =
get_rac(c, state);
720 "chroma subsampling not supported in this colorspace\n");
747 if (context_count < 0) {
758 int trailer = 3 + 5*!!f->
ec;
802 "quant_table_index out of range\n");
848 int buf_size = avpkt->
size;
883 "Cannot decode non-keyframe without valid keyframe\n");
898 buf_p = buf + buf_size;
901 int trailer = 3 + 5*!!f->
ec;
951 for (j = 0; j < 4; j++) {
1015 fsdst->
ac = fsrc->
ac;
1018 fsdst->
ec = fsrc->
ec;
1045 memcpy(fdst, fsrc,
sizeof(*fdst));