56 for (i = e - 1; i >= 0; i--)
59 e = -(is_signed &&
get_rac(c, state + 11 +
FFMIN(e, 10)));
76 while (i < state->error_sum) {
82 av_dlog(
NULL,
"v:%d bias:%d error:%d drift:%d count:%d k:%d",
86 if (k == 0 && 2 * state->
drift <= -state->
count)
89 v ^= ((2 * state->
drift + state->
count) >> 31);
101 int plane_index,
int bits)
110 for (x = 0; x < w; x++) {
111 int diff, context, sign;
113 context =
get_context(p, sample[1] + x, sample[0] + x, sample[1] + x);
125 if (context == 0 && run_mode == 0)
129 if (run_count == 0 && run_mode == 1) {
132 if (x + run_count <= w)
157 av_dlog(s->
avctx,
"count:%d index:%d, mode:%d, x:%d pos:%d\n",
164 sample[1][x] = (
predict(sample[1] + x, sample[0] + x) +
diff) &
171 int w,
int h,
int stride,
int plane_index)
182 for (y = 0; y < h; y++) {
183 int16_t *
temp = sample[0];
185 sample[0] = sample[1];
188 sample[1][-1] = sample[0][0];
189 sample[0][w] = sample[0][w - 1];
194 for (x = 0; x < w; x++)
195 src[x + stride * y] = sample[1][x];
199 for (x = 0; x < w; x++) {
200 ((uint16_t*)(src + stride*y))[x] = sample[1][x];
203 for (x = 0; x < w; x++) {
220 for (x = 0; x < 4; x++) {
229 for (y = 0; y < h; y++) {
231 int16_t *
temp = sample[p][0];
233 sample[p][0] = sample[p][1];
236 sample[p][1][-1]= sample[p][0][0 ];
237 sample[p][0][ w]= sample[p][0][w-1];
243 for (x = 0; x < w; x++) {
244 int g = sample[0][1][x];
245 int b = sample[1][1][x];
246 int r = sample[2][1][x];
247 int a = sample[3][1][x];
256 *((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + (g<<8) + (r<<16) + (a<<24);
258 *((uint16_t*)(src[0] + x*2 + stride[0]*y)) = b;
259 *((uint16_t*)(src[1] + x*2 + stride[1]*y)) = g;
260 *((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;
271 memset(state, 128,
sizeof(state));
312 }
else if (ps == 2) {
315 }
else if (ps == 3) {
360 if (f->colorspace == 0) {
361 const int chroma_width = -((-
width) >> f->chroma_h_shift);
362 const int chroma_height = -((-
height) >> f->chroma_v_shift);
363 const int cx = x >> f->chroma_h_shift;
364 const int cy = y >> f->chroma_v_shift;
367 if (f->chroma_planes) {
368 decode_plane(fs, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1);
369 decode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1);
371 if (fs->transparency)
374 uint8_t *planes[3] = { p->data[0] + ps * x + y * p->linesize[0],
375 p->data[1] + ps * x + y * p->linesize[1],
376 p->data[2] + ps * x + y * p->linesize[2] };
379 if (fs->ac && f->version > 2) {
382 v = fs->c.bytestream_end - fs->c.bytestream - 2 - 5*f->ec;
385 fs->slice_damaged = 1;
400 memset(state, 128,
sizeof(state));
402 for (v = 0; i < 128; v++) {
409 quant_table[i] = scale * v;
414 for (i = 1; i < 128; i++)
415 quant_table[256 - i] = -quant_table[i];
416 quant_table[128] = -quant_table[127];
427 for (i = 0; i < 5; i++) {
429 if (context_count > 32768
U) {
433 return (context_count + 1) / 2;
443 memset(state2, 128,
sizeof(state2));
444 memset(state, 128,
sizeof(state));
456 for (i = 1; i < 256; i++)
524 memset(state, 128,
sizeof(state));
535 for (i = 1; i < 256; i++)
611 "chroma subsampling not supported in this colorspace\n");
634 if (context_count < 0) {
645 int trailer = 3 + 5*!!f->
ec;
689 "quant_table_index out of range\n");
733 int buf_size = avpkt->
size;
760 "Cannot decode non-keyframe without valid keyframe\n");
776 buf_p = buf + buf_size;
779 int trailer = 3 + 5*!!f->
ec;
825 for (j = 0; j < 4; j++) {