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++) {
274 RItype = (
FFABS(Ra - Rb) <= state->
near) ? 1 : 0;
280 if (state->
near && RItype) {
294 pred =
mid_pred(Ra, Ra + Rb - Rc, Rb);
304 pred = av_clip(pred - state->
C[context], 0, state->
maxval);
307 pred = av_clip(pred + state->
C[context], 0, state->
maxval);
315 if (pred < -state->near)
319 pred = av_clip(pred, 0, state->
maxval);
329 int point_transform,
int ilv)
353 shift = point_transform + (8 - s->
bits);
355 shift = point_transform + (16 - s->
bits);
359 "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
360 "RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
362 state->
T1, state->
T2, state->
T3,
376 for (i = 0; i < s->
height; i++) {
382 t = *((uint16_t *)last);
392 }
else if (ilv == 1) {
394 int Rc[3] = { 0, 0, 0 };
398 for (i = 0; i < s->
height; i++) {
399 for (j = 0; j <
stride; j++) {
401 Rc[j],
width, stride, j, 8);
412 }
else if (ilv == 2) {
426 for (i = 0; i < s->
height; i++) {
429 for (x = off; x < w; x += 3) {
430 src[x ] += src[x+1] + 128;
431 src[x+2] += src[x+1] + 128;
435 for (x = off; x < w; x += 3) {
436 src[x ] += src[x+1] + 128;
437 src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
441 for (x = off; x < w; x += 3) {
442 int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
443 src[x+0] = src[x+2] + g + 128;
444 src[x+2] = src[x+1] + g + 128;
449 for (x = off; x < w; x += 3) {
450 int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
451 int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
452 int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);
453 src[x+0] = av_clip_uint8(r);
454 src[x+1] = av_clip_uint8(g);
455 src[x+2] = av_clip_uint8(b);
473 for (i = 0; i < s->
height; i++) {
474 for (x = off; x < w; x +=
stride)
482 for (x = 0; x < w; x++)