53 int tid, wt, maxtab, i, j;
93 else if ((5 + wt*(s->
maxval+1)) < 65535)
96 maxtab = 65530/wt - 1;
117 for (j=0; j<wt; j++) {
118 pal[i] |=
get_bits(&s->
gb, 8) << (8*(wt-j-1));
143 for (k = 0; (state->
N[Q] << k) < state->
A[Q]; k++)
154 ret = -(ret + 1 >> 1);
159 if (!state->
near && !k && (2 * state->
B[Q] <= -state->
N[Q]))
171 int RItype,
int limit_add)
174 int Q = 365 + RItype;
178 temp += state->
N[Q] >> 1;
180 for (k = 0; (state->
N[Q] << k) < temp; k++)
192 if (!k && (RItype || ret) && (2 * state->
B[Q] < state->
N[Q]))
197 ret = map - (ret + 1 >> 1);
203 if(
FFABS(ret) > 0xFFFF)
206 state->
A[Q] +=
FFABS(ret) - RItype;
217 void *last,
void *dst,
int last2,
int w,
228 Ra = x ?
R(dst, x - stride) :
R(last, x);
230 Rc = x ?
R(last, x - stride) : last2;
231 Rd = (x >= w - stride) ?
R(last, x) :
R(last, x + stride);
246 if (x + r * stride > w)
247 r = (w - x) / stride;
248 for (i = 0; i <
r; i++) {
264 if (x + r * stride > w) {
265 r = (w - x) / stride;
267 for (i = 0; i <
r; i++) {
279 RItype = (
FFABS(Ra - Rb) <= state->
near) ? 1 : 0;
285 if (state->
near && RItype) {
299 pred =
mid_pred(Ra, Ra + Rb - Rc, Rb);
309 pred = av_clip(pred - state->
C[context], 0, state->
maxval);
312 pred = av_clip(pred + state->
C[context], 0, state->
maxval);
320 if (pred < -state->near)
324 pred = av_clip(pred, 0, state->
maxval);
334 int point_transform,
int ilv)
358 shift = point_transform + (8 - s->
bits);
360 shift = point_transform + (16 - s->
bits);
364 "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
365 "RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
367 state->
T1, state->
T2, state->
T3,
381 for (i = 0; i < s->
height; i++) {
387 t = *((uint16_t *)last);
397 }
else if (ilv == 1) {
399 int Rc[3] = { 0, 0, 0 };
403 for (i = 0; i < s->
height; i++) {
404 for (j = 0; j <
stride; j++) {
406 Rc[j],
width, stride, j, 8);
417 }
else if (ilv == 2) {
431 for (i = 0; i < s->
height; i++) {
434 for (x = off; x < w; x += 3) {
435 src[x ] += src[x+1] + 128;
436 src[x+2] += src[x+1] + 128;
440 for (x = off; x < w; x += 3) {
441 src[x ] += src[x+1] + 128;
442 src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
446 for (x = off; x < w; x += 3) {
447 int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
448 src[x+0] = src[x+2] + g + 128;
449 src[x+2] = src[x+1] + g + 128;
454 for (x = off; x < w; x += 3) {
455 int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
456 int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
457 int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);
458 src[x+0] = av_clip_uint8(r);
459 src[x+1] = av_clip_uint8(g);
460 src[x+2] = av_clip_uint8(b);
478 for (i = 0; i < s->
height; i++) {
479 for (x = off; x < w; x +=
stride)
487 for (x = 0; x < w; x++)