55 for (i = e - 1; i >= 0; i--)
58 e = -(is_signed &&
get_rac(c, state + 11 +
FFMIN(e, 10)));
75 while (i < state->error_sum) {
81 av_dlog(
NULL,
"v:%d bias:%d error:%d drift:%d count:%d k:%d",
85 if (k == 0 && 2 * state->
drift <= -state->
count)
88 v ^= ((2 * state->
drift + state->
count) >> 31);
100 int plane_index,
int bits)
109 for (x = 0; x < w; x++) {
110 int diff, context, sign;
112 context =
get_context(p, sample[1] + x, sample[0] + x, sample[1] + x);
124 if (context == 0 && run_mode == 0)
128 if (run_count == 0 && run_mode == 1) {
131 if (x + run_count <= w)
156 av_dlog(s->
avctx,
"count:%d index:%d, mode:%d, x:%d pos:%d\n",
163 sample[1][x] = (
predict(sample[1] + x, sample[0] + x) +
diff) &
170 int w,
int h,
int stride,
int plane_index)
181 for (y = 0; y < h; y++) {
182 int16_t *
temp = sample[0];
184 sample[0] = sample[1];
187 sample[1][-1] = sample[0][0];
188 sample[0][w] = sample[0][w - 1];
193 for (x = 0; x < w; x++)
194 src[x + stride * y] = sample[1][x];
198 for (x = 0; x < w; x++) {
199 ((uint16_t*)(src + stride*y))[x] = sample[1][x];
202 for (x = 0; x < w; x++) {
219 for (x = 0; x < 4; x++) {
228 for (y = 0; y < h; y++) {
230 int16_t *
temp = sample[p][0];
232 sample[p][0] = sample[p][1];
235 sample[p][1][-1]= sample[p][0][0 ];
236 sample[p][0][ w]= sample[p][0][w-1];
242 for (x = 0; x < w; x++) {
243 int g = sample[0][1][x];
244 int b = sample[1][1][x];
245 int r = sample[2][1][x];
246 int a = sample[3][1][x];
255 *((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + (g<<8) + (r<<16) + (a<<24);
257 *((uint16_t*)(src[0] + x*2 + stride[0]*y)) = b;
258 *((uint16_t*)(src[1] + x*2 + stride[1]*y)) = g;
259 *((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;
270 memset(state, 128,
sizeof(state));
311 }
else if (ps == 2) {
314 }
else if (ps == 3) {
359 if (f->colorspace == 0) {
360 const int chroma_width = -((-
width) >> f->chroma_h_shift);
361 const int chroma_height = -((-
height) >> f->chroma_v_shift);
362 const int cx = x >> f->chroma_h_shift;
363 const int cy =
y >> f->chroma_v_shift;
366 if (f->chroma_planes) {
367 decode_plane(fs, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1);
368 decode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1);
370 if (fs->transparency)
373 uint8_t *planes[3] = { p->data[0] + ps * x +
y * p->linesize[0],
374 p->data[1] + ps * x +
y * p->linesize[1],
375 p->data[2] + ps * x +
y * p->linesize[2] };
378 if (fs->ac && f->version > 2) {
381 v = fs->c.bytestream_end - fs->c.bytestream - 2 - 5*f->ec;
384 fs->slice_damaged = 1;
399 memset(state, 128,
sizeof(state));
401 for (v = 0; i < 128; v++) {
408 quant_table[i] = scale *
v;
413 for (i = 1; i < 128; i++)
414 quant_table[256 - i] = -quant_table[i];
415 quant_table[128] = -quant_table[127];
426 for (i = 0; i < 5; i++) {
428 if (context_count > 32768
U) {
432 return (context_count + 1) / 2;
442 memset(state2, 128,
sizeof(state2));
443 memset(state, 128,
sizeof(state));
455 for (i = 1; i < 256; i++)
523 memset(state, 128,
sizeof(state));
534 for (i = 1; i < 256; i++)
610 "chroma subsampling not supported in this colorspace\n");
633 if (context_count < 0) {
644 int trailer = 3 + 5*!!f->
ec;
688 "quant_table_index out of range\n");
732 int buf_size = avpkt->
size;
759 "Cannot decode non-keyframe without valid keyframe\n");
775 buf_p = buf + buf_size;
778 int trailer = 3 + 5*!!f->
ec;
824 for (j = 0; j < 4; j++) {