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) {
83 av_dlog(
NULL,
"v:%d bias:%d error:%d drift:%d count:%d k:%d",
87 if (k == 0 && 2 * state->
drift <= -state->
count)
90 v ^= ((2 * state->
drift + state->
count) >> 31);
102 int plane_index,
int bits)
111 for (x = 0; x < w; x++) {
112 int diff, context, sign;
114 context =
get_context(p, sample[1] + x, sample[0] + x, sample[1] + x);
126 if (context == 0 && run_mode == 0)
130 if (run_count == 0 && run_mode == 1) {
133 if (x + run_count <= w)
158 av_dlog(s->
avctx,
"count:%d index:%d, mode:%d, x:%d pos:%d\n",
165 sample[1][x] = (
predict(sample[1] + x, sample[0] + x) + diff) &
172 int w,
int h,
int stride,
int plane_index)
183 for (y = 0; y < h; y++) {
184 int16_t *temp = sample[0];
186 sample[0] = sample[1];
189 sample[1][-1] = sample[0][0];
190 sample[0][w] = sample[0][w - 1];
195 for (x = 0; x < w; x++)
196 src[x + stride * y] = sample[1][x];
201 for (x = 0; x < w; x++)
202 ((uint16_t *)(src + stride * y))[x] = sample[1][x];
204 for (x = 0; x < w; x++)
221 int offset = 1 <<
bits;
223 for (x = 0; x < 4; x++) {
232 for (y = 0; y < h; y++) {
234 int16_t *temp = sample[p][0];
236 sample[p][0] = sample[p][1];
239 sample[p][1][-1] = sample[p][0][0];
240 sample[p][0][w] = sample[p][0][w - 1];
244 decode_line(s, w, sample[p], (p + 1) / 2, bits + 1);
246 for (x = 0; x < w; x++) {
247 int g = sample[0][1][x];
248 int b = sample[1][1][x];
249 int r = sample[2][1][x];
250 int a = sample[3][1][x];
259 *((uint32_t *)(src[0] + x * 4 + stride[0] * y)) = b +
260 (g << 8) + (r << 16) + (a << 24);
262 *((uint16_t *)(src[0] + x * 2 + stride[0] * y)) = b;
263 *((uint16_t *)(src[1] + x * 2 + stride[1] * y)) = g;
264 *((uint16_t *)(src[2] + x * 2 + stride[2] * y)) = r;
275 memset(state, 128,
sizeof(state));
278 for (i = 1; i < 256; i++) {
322 }
else if (ps == 2) {
325 }
else if (ps == 3) {
369 if (f->colorspace == 0) {
370 const int chroma_width = -((-
width) >> f->chroma_h_shift);
371 const int chroma_height = -((-
height) >> f->chroma_v_shift);
372 const int cx = x >> f->chroma_h_shift;
373 const int cy = y >> f->chroma_v_shift;
378 if (f->chroma_planes) {
379 decode_plane(fs, p->data[1] + ps * cx + cy * p->linesize[1],
380 chroma_width, chroma_height, p->linesize[1],
382 decode_plane(fs, p->data[2] + ps * cx + cy * p->linesize[2],
383 chroma_width, chroma_height, p->linesize[2],
386 if (fs->transparency)
391 uint8_t *planes[3] = { p->data[0] + ps * x + y * p->linesize[0],
392 p->data[1] + ps * x + y * p->linesize[1],
393 p->data[2] + ps * x + y * p->linesize[2] };
396 if (fs->ac && f->version > 2) {
399 v = fs->c.bytestream_end - fs->c.bytestream - 2 - 5 * f->ec;
401 av_log(f->avctx, AV_LOG_ERROR,
"bytestream end mismatching by %d\n",
403 fs->slice_damaged = 1;
418 memset(state, 128,
sizeof(state));
420 for (v = 0; i < 128; v++) {
427 quant_table[i] = scale * v;
432 for (i = 1; i < 128; i++)
433 quant_table[256 - i] = -quant_table[i];
434 quant_table[128] = -quant_table[127];
445 for (i = 0; i < 5; i++) {
447 if (context_count > 32768
U) {
451 return (context_count + 1) / 2;
461 memset(state2, 128,
sizeof(state2));
462 memset(state, 128,
sizeof(state));
475 for (i = 1; i < 256; i++)
542 memset(state, 128,
sizeof(state));
548 "invalid version %d in version 1 header\n", v);
556 for (i = 1; i < 256; i++)
669 "chroma subsampling not supported in this colorspace\n");
684 "bit depth %d not supported\n",
697 if (context_count < 0) {
708 int trailer = 3 + 5 * !!f->
ec;
756 "quant_table_index out of range\n");
800 int buf_size = avpkt->
size;
827 "Cannot decode non-keyframe without valid keyframe\n");
841 "ver:%d keyframe:%d coder:%d ec:%d slices:%d bps:%d\n",
845 buf_p = buf + buf_size;
848 int trailer = 3 + 5 * !!f->
ec;
852 v =
AV_RB24(buf_p - trailer) + trailer;
885 for (j = 0; j < 4; j++) {