91 for (k = 0; (state->
N[Q] << k) < state->
A[Q]; k++)
102 ret = -(ret + 1 >> 1);
107 if (!state->
near && !k && (2 * state->
B[Q] <= -state->
N[Q]))
119 int RItype,
int limit_add)
122 int Q = 365 + RItype;
126 temp += state->
N[Q] >> 1;
128 for (k = 0; (state->
N[Q] << k) < temp; k++)
140 if (!k && (RItype || ret) && (2 * state->
B[Q] < state->
N[Q]))
145 ret = map - (ret + 1 >> 1);
151 if(
FFABS(ret) > 0xFFFF)
154 state->
A[Q] +=
FFABS(ret) - RItype;
165 void *last,
void *dst,
int last2,
int w,
176 Ra = x ?
R(dst, x - stride) :
R(last, x);
178 Rc = x ?
R(last, x - stride) : last2;
179 Rd = (x >= w - stride) ?
R(last, x) :
R(last, x + stride);
194 if (x + r * stride > w)
195 r = (w - x) / stride;
196 for (i = 0; i <
r; i++) {
212 if (x + r * stride > w) {
213 r = (w - x) / stride;
215 for (i = 0; i <
r; i++) {
222 RItype = (
FFABS(Ra - Rb) <= state->
near) ? 1 : 0;
228 if (state->
near && RItype) {
242 pred =
mid_pred(Ra, Ra + Rb - Rc, Rb);
252 pred = av_clip(pred - state->
C[context], 0, state->
maxval);
255 pred = av_clip(pred + state->
C[context], 0, state->
maxval);
263 if (pred < -state->near)
267 pred = av_clip(pred, 0, state->
maxval);
277 int point_transform,
int ilv)
301 shift = point_transform + (8 - s->
bits);
303 shift = point_transform + (16 - s->
bits);
307 "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
308 "RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
310 state->
T1, state->
T2, state->
T3,
324 for (i = 0; i < s->
height; i++) {
330 t = *((uint16_t *)last);
340 }
else if (ilv == 1) {
342 int Rc[3] = { 0, 0, 0 };
346 for (i = 0; i < s->
height; i++) {
347 for (j = 0; j <
stride; j++) {
349 Rc[j],
width, stride, j, 8);
360 }
else if (ilv == 2) {
374 for (i = 0; i < s->
height; i++) {
377 for (x = off; x < w; x += 3) {
378 src[x ] += src[x+1] + 128;
379 src[x+2] += src[x+1] + 128;
383 for (x = off; x < w; x += 3) {
384 src[x ] += src[x+1] + 128;
385 src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
389 for (x = off; x < w; x += 3) {
390 int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
391 src[x+0] = src[x+2] + g + 128;
392 src[x+2] = src[x+1] + g + 128;
397 for (x = off; x < w; x += 3) {
398 int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
399 int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
400 int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);
401 src[x+0] = av_clip_uint8(r);
402 src[x+1] = av_clip_uint8(g);
403 src[x+2] = av_clip_uint8(b);
421 for (i = 0; i < s->
height; i++) {
422 for (x = off; x < w; x +=
stride)
430 for (x = 0; x < w; x++)