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)
108 for (x = 0; x < w; x++) {
109 int diff, context, sign;
111 context =
get_context(p, sample[1] + x, sample[0] + x, sample[1] + x);
123 if (context == 0 && run_mode == 0)
127 if (run_count == 0 && run_mode == 1) {
130 if (x + run_count <= w)
155 av_dlog(s->
avctx,
"count:%d index:%d, mode:%d, x:%d pos:%d\n",
162 sample[1][x] = (
predict(sample[1] + x, sample[0] + x) +
diff) &
169 int w,
int h,
int stride,
int plane_index)
180 for (y = 0; y < h; y++) {
181 int16_t *
temp = sample[0];
183 sample[0] = sample[1];
186 sample[1][-1] = sample[0][0];
187 sample[0][w] = sample[0][w - 1];
192 for (x = 0; x < w; x++)
193 src[x + stride * y] = sample[1][x];
197 for (x = 0; x < w; x++) {
198 ((uint16_t*)(src + stride*y))[x] = sample[1][x];
201 for (x = 0; x < w; x++) {
218 for (x = 0; x < 4; x++) {
227 for (y = 0; y < h; y++) {
229 int16_t *
temp = sample[p][0];
231 sample[p][0] = sample[p][1];
234 sample[p][1][-1]= sample[p][0][0 ];
235 sample[p][0][ w]= sample[p][0][w-1];
241 for (x = 0; x < w; x++) {
242 int g = sample[0][1][x];
243 int b = sample[1][1][x];
244 int r = sample[2][1][x];
245 int a = sample[3][1][x];
254 *((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + (g<<8) + (r<<16) + (a<<24);
256 *((uint16_t*)(src[0] + x*2 + stride[0]*y)) = b;
257 *((uint16_t*)(src[1] + x*2 + stride[1]*y)) = g;
258 *((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;
269 memset(state, 128,
sizeof(state));
310 }
else if (ps == 2) {
313 }
else if (ps == 3) {
352 memcpy(pdst, psrc,
sizeof(*pdst));
394 if (f->colorspace == 0) {
397 const int cx = x >> f->chroma_h_shift;
398 const int cy =
y >> f->chroma_v_shift;
401 if (f->chroma_planes) {
402 decode_plane(fs, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1);
403 decode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1);
405 if (fs->transparency)
408 uint8_t *planes[3] = { p->data[0] + ps * x +
y * p->linesize[0],
409 p->data[1] + ps * x +
y * p->linesize[1],
410 p->data[2] + ps * x +
y * p->linesize[2] };
413 if (fs->ac && f->version > 2) {
416 v = fs->c.bytestream_end - fs->c.bytestream - 2 - 5*f->ec;
419 fs->slice_damaged = 1;
436 memset(state, 128,
sizeof(state));
438 for (v = 0; i < 128; v++) {
445 quant_table[i] = scale *
v;
450 for (i = 1; i < 128; i++)
451 quant_table[256 - i] = -quant_table[i];
452 quant_table[128] = -quant_table[127];
463 for (i = 0; i < 5; i++) {
465 if (context_count > 32768
U) {
469 return (context_count + 1) / 2;
479 memset(state2, 128,
sizeof(state2));
480 memset(state, 128,
sizeof(state));
492 for (i = 1; i < 256; i++)
562 memset(state, 128,
sizeof(state));
573 for (i = 1; i < 256; i++)
649 "chroma subsampling not supported in this colorspace\n");
672 if (context_count < 0) {
683 int trailer = 3 + 5*!!f->
ec;
727 "quant_table_index out of range\n");
773 int buf_size = avpkt->
size;
801 "Cannot decode non-keyframe without valid keyframe\n");
816 buf_p = buf + buf_size;
819 int trailer = 3 + 5*!!f->
ec;
869 for (j = 0; j < 4; j++) {
922 memcpy(fdst, fsrc,
sizeof(*fdst));