Mercurial > libavcodec.hg
comparison jpeg_ls.c @ 4001:34fdffe98bd0 libavcodec
Rename ABS macro to FFABS.
author | diego |
---|---|
date | Wed, 11 Oct 2006 23:17:58 +0000 |
parents | c8c591fe26f8 |
children | 0df780a93aa8 |
comparison
equal
deleted
inserted
replaced
4000:eeab02251056 | 4001:34fdffe98bd0 |
---|---|
211 | 211 |
212 /* for NEAR=0, k=0 and 2*B[Q] <= - N[Q] mapping is reversed */ | 212 /* for NEAR=0, k=0 and 2*B[Q] <= - N[Q] mapping is reversed */ |
213 if(!state->near && !k && (2 * state->B[Q] <= -state->N[Q])) | 213 if(!state->near && !k && (2 * state->B[Q] <= -state->N[Q])) |
214 ret = -(ret + 1); | 214 ret = -(ret + 1); |
215 | 215 |
216 state->A[Q] += ABS(ret); | 216 state->A[Q] += FFABS(ret); |
217 ret *= state->twonear; | 217 ret *= state->twonear; |
218 state->B[Q] += ret; | 218 state->B[Q] += ret; |
219 | 219 |
220 if(state->N[Q] == state->reset) { | 220 if(state->N[Q] == state->reset) { |
221 state->A[Q] >>= 1; | 221 state->A[Q] >>= 1; |
272 } else { | 272 } else { |
273 ret = ret >> 1; | 273 ret = ret >> 1; |
274 } | 274 } |
275 | 275 |
276 /* update state */ | 276 /* update state */ |
277 state->A[Q] += ABS(ret) - RItype; | 277 state->A[Q] += FFABS(ret) - RItype; |
278 ret *= state->twonear; | 278 ret *= state->twonear; |
279 if(state->N[Q] == state->reset){ | 279 if(state->N[Q] == state->reset){ |
280 state->A[Q] >>=1; | 280 state->A[Q] >>=1; |
281 state->B[Q] >>=1; | 281 state->B[Q] >>=1; |
282 state->N[Q] >>=1; | 282 state->N[Q] >>=1; |
304 Rd = (x >= w - stride) ? last[x] : last[x + stride]; | 304 Rd = (x >= w - stride) ? last[x] : last[x + stride]; |
305 D0 = Rd - Rb; | 305 D0 = Rd - Rb; |
306 D1 = Rb - Rc; | 306 D1 = Rb - Rc; |
307 D2 = Rc - Ra; | 307 D2 = Rc - Ra; |
308 /* run mode */ | 308 /* run mode */ |
309 if((ABS(D0) <= state->near) && (ABS(D1) <= state->near) && (ABS(D2) <= state->near)) { | 309 if((FFABS(D0) <= state->near) && (FFABS(D1) <= state->near) && (FFABS(D2) <= state->near)) { |
310 int r; | 310 int r; |
311 int RItype; | 311 int RItype; |
312 | 312 |
313 /* decode full runs while available */ | 313 /* decode full runs while available */ |
314 while(get_bits1(&s->gb)) { | 314 while(get_bits1(&s->gb)) { |
338 x += stride; | 338 x += stride; |
339 } | 339 } |
340 | 340 |
341 /* decode run termination value */ | 341 /* decode run termination value */ |
342 Rb = last[x]; | 342 Rb = last[x]; |
343 RItype = (ABS(Ra - Rb) <= state->near) ? 1 : 0; | 343 RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0; |
344 err = ls_get_code_runterm(&s->gb, state, RItype, log2_run[state->run_index[comp]]); | 344 err = ls_get_code_runterm(&s->gb, state, RItype, log2_run[state->run_index[comp]]); |
345 if(state->run_index[comp]) | 345 if(state->run_index[comp]) |
346 state->run_index[comp]--; | 346 state->run_index[comp]--; |
347 | 347 |
348 if(state->near && RItype){ | 348 if(state->near && RItype){ |
489 | 489 |
490 if(err < 0) | 490 if(err < 0) |
491 err += state->range; | 491 err += state->range; |
492 if(err >= ((state->range + 1) >> 1)) { | 492 if(err >= ((state->range + 1) >> 1)) { |
493 err -= state->range; | 493 err -= state->range; |
494 val = 2 * ABS(err) - 1 - map; | 494 val = 2 * FFABS(err) - 1 - map; |
495 } else | 495 } else |
496 val = 2 * err + map; | 496 val = 2 * err + map; |
497 | 497 |
498 set_ur_golomb_jpegls(pb, val, k, state->limit, state->qbpp); | 498 set_ur_golomb_jpegls(pb, val, k, state->limit, state->qbpp); |
499 | 499 |
500 state->A[Q] += ABS(err); | 500 state->A[Q] += FFABS(err); |
501 state->B[Q] += err * state->twonear; | 501 state->B[Q] += err * state->twonear; |
502 | 502 |
503 if(state->N[Q] == state->reset) { | 503 if(state->N[Q] == state->reset) { |
504 state->A[Q] >>= 1; | 504 state->A[Q] >>= 1; |
505 state->B[Q] >>= 1; | 505 state->B[Q] >>= 1; |
596 D0 = Rd - Rb; | 596 D0 = Rd - Rb; |
597 D1 = Rb - Rc; | 597 D1 = Rb - Rc; |
598 D2 = Rc - Ra; | 598 D2 = Rc - Ra; |
599 | 599 |
600 /* run mode */ | 600 /* run mode */ |
601 if((ABS(D0) <= state->near) && (ABS(D1) <= state->near) && (ABS(D2) <= state->near)) { | 601 if((FFABS(D0) <= state->near) && (FFABS(D1) <= state->near) && (FFABS(D2) <= state->near)) { |
602 int RUNval, RItype, run; | 602 int RUNval, RItype, run; |
603 | 603 |
604 run = 0; | 604 run = 0; |
605 RUNval = Ra; | 605 RUNval = Ra; |
606 while(x < w && (ABS(cur[x] - RUNval) <= state->near)){ | 606 while(x < w && (FFABS(cur[x] - RUNval) <= state->near)){ |
607 run++; | 607 run++; |
608 cur[x] = Ra; | 608 cur[x] = Ra; |
609 x += stride; | 609 x += stride; |
610 } | 610 } |
611 ls_encode_run(state, pb, run, comp, x < w); | 611 ls_encode_run(state, pb, run, comp, x < w); |
612 if(x >= w) | 612 if(x >= w) |
613 return; | 613 return; |
614 Rb = last[x]; | 614 Rb = last[x]; |
615 RItype = (ABS(Ra - Rb) <= state->near); | 615 RItype = (FFABS(Ra - Rb) <= state->near); |
616 pred = RItype ? Ra : Rb; | 616 pred = RItype ? Ra : Rb; |
617 err = cur[x] - pred; | 617 err = cur[x] - pred; |
618 | 618 |
619 if(!RItype && Ra > Rb) | 619 if(!RItype && Ra > Rb) |
620 err = -err; | 620 err = -err; |