| OLD | NEW |
| 1 /* | 1 /* |
| 2 * The copyright in this software is being made available under the 2-clauses | 2 * The copyright in this software is being made available under the 2-clauses |
| 3 * BSD License, included below. This software may be subject to other third | 3 * BSD License, included below. This software may be subject to other third |
| 4 * party and contributor rights, including patent rights, and no such rights | 4 * party and contributor rights, including patent rights, and no such rights |
| 5 * are granted under this license. | 5 * are granted under this license. |
| 6 * | 6 * |
| 7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium | 7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium |
| 8 * Copyright (c) 2002-2014, Professor Benoit Macq | 8 * Copyright (c) 2002-2014, Professor Benoit Macq |
| 9 * Copyright (c) 2001-2003, David Janssens | 9 * Copyright (c) 2001-2003, David Janssens |
| 10 * Copyright (c) 2002-2003, Yannick Verschueren | 10 * Copyright (c) 2002-2003, Yannick Verschueren |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 @param orient | 288 @param orient |
| 289 @param roishift Region of interest shifting value | 289 @param roishift Region of interest shifting value |
| 290 @param cblksty Code-block style | 290 @param cblksty Code-block style |
| 291 */ | 291 */ |
| 292 static OPJ_BOOL opj_t1_decode_cblk( opj_t1_t *t1, | 292 static OPJ_BOOL opj_t1_decode_cblk( opj_t1_t *t1, |
| 293 opj_tcd_cblk_dec_t* cblk, | 293 opj_tcd_cblk_dec_t* cblk, |
| 294 OPJ_UINT32 orient, | 294 OPJ_UINT32 orient, |
| 295 OPJ_UINT32 roishift, | 295 OPJ_UINT32 roishift, |
| 296 OPJ_UINT32 cblksty); | 296 OPJ_UINT32 cblksty); |
| 297 | 297 |
| 298 OPJ_BOOL opj_t1_allocate_buffers( opj_t1_t *t1, | 298 static OPJ_BOOL opj_t1_allocate_buffers( opj_t1_t *t1, |
| 299 OPJ_UINT32 w, | 299 OPJ_UINT32 w, |
| 300 OPJ_UINT32 h); | 300 OPJ_UINT32 h); |
| 301 | 301 |
| 302 /*@}*/ | 302 /*@}*/ |
| 303 | 303 |
| 304 /*@}*/ | 304 /*@}*/ |
| 305 | 305 |
| 306 /* ----------------------------------------------------------------------- */ | 306 /* ----------------------------------------------------------------------- */ |
| 307 | 307 |
| 308 OPJ_BYTE opj_t1_getctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient) { | 308 static OPJ_BYTE opj_t1_getctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient) { |
| 309 return lut_ctxno_zc[(orient << 8) | (f & T1_SIG_OTH)]; | 309 return lut_ctxno_zc[(orient << 8) | (f & T1_SIG_OTH)]; |
| 310 } | 310 } |
| 311 | 311 |
| 312 OPJ_BYTE opj_t1_getctxno_sc(OPJ_UINT32 f) { | 312 static OPJ_BYTE opj_t1_getctxno_sc(OPJ_UINT32 f) { |
| 313 return lut_ctxno_sc[(f & (T1_SIG_PRIM | T1_SGN)) >> 4]; | 313 return lut_ctxno_sc[(f & (T1_SIG_PRIM | T1_SGN)) >> 4]; |
| 314 } | 314 } |
| 315 | 315 |
| 316 OPJ_UINT32 opj_t1_getctxno_mag(OPJ_UINT32 f) { | 316 static OPJ_UINT32 opj_t1_getctxno_mag(OPJ_UINT32 f) { |
| 317 OPJ_UINT32 tmp1 = (f & T1_SIG_OTH) ? T1_CTXNO_MAG + 1 : T1_CTXNO_MAG; | 317 OPJ_UINT32 tmp1 = (f & T1_SIG_OTH) ? T1_CTXNO_MAG + 1 : T1_CTXNO_MAG; |
| 318 OPJ_UINT32 tmp2 = (f & T1_REFINE) ? T1_CTXNO_MAG + 2 : tmp1; | 318 OPJ_UINT32 tmp2 = (f & T1_REFINE) ? T1_CTXNO_MAG + 2 : tmp1; |
| 319 return (tmp2); | 319 return (tmp2); |
| 320 } | 320 } |
| 321 | 321 |
| 322 OPJ_BYTE opj_t1_getspb(OPJ_UINT32 f) { | 322 static OPJ_BYTE opj_t1_getspb(OPJ_UINT32 f) { |
| 323 return lut_spb[(f & (T1_SIG_PRIM | T1_SGN)) >> 4]; | 323 return lut_spb[(f & (T1_SIG_PRIM | T1_SGN)) >> 4]; |
| 324 } | 324 } |
| 325 | 325 |
| 326 OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos) { | 326 static OPJ_INT16 opj_t1_getnmsedec_sig(OPJ_UINT32 x, OPJ_UINT32 bitpos) { |
| 327 » if (bitpos > T1_NMSEDEC_FRACBITS) { | 327 » if (bitpos > 0) { |
| 328 » » return lut_nmsedec_sig[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & (
(1 << T1_NMSEDEC_BITS) - 1)]; | 328 » » return lut_nmsedec_sig[(x >> (bitpos)) & ((1 << T1_NMSEDEC_BITS)
- 1)]; |
| 329 } | 329 } |
| 330 | 330 |
| 331 return lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)]; | 331 return lut_nmsedec_sig0[x & ((1 << T1_NMSEDEC_BITS) - 1)]; |
| 332 } | 332 } |
| 333 | 333 |
| 334 OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos) { | 334 static OPJ_INT16 opj_t1_getnmsedec_ref(OPJ_UINT32 x, OPJ_UINT32 bitpos) { |
| 335 » if (bitpos > T1_NMSEDEC_FRACBITS) { | 335 » if (bitpos > 0) { |
| 336 » » return lut_nmsedec_ref[(x >> (bitpos - T1_NMSEDEC_FRACBITS)) & (
(1 << T1_NMSEDEC_BITS) - 1)]; | 336 » » return lut_nmsedec_ref[(x >> (bitpos)) & ((1 << T1_NMSEDEC_BITS)
- 1)]; |
| 337 } | 337 } |
| 338 | 338 |
| 339 return lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)]; | 339 return lut_nmsedec_ref0[x & ((1 << T1_NMSEDEC_BITS) - 1)]; |
| 340 } | 340 } |
| 341 | 341 |
| 342 void opj_t1_updateflags(opj_flag_t *flagsp, OPJ_UINT32 s, OPJ_UINT32 stride) { | 342 static void opj_t1_updateflags(opj_flag_t *flagsp, OPJ_UINT32 s, OPJ_UINT32 stri
de) { |
| 343 opj_flag_t *np = flagsp - stride; | 343 opj_flag_t *np = flagsp - stride; |
| 344 opj_flag_t *sp = flagsp + stride; | 344 opj_flag_t *sp = flagsp + stride; |
| 345 | 345 |
| 346 static const opj_flag_t mod[] = { | 346 static const opj_flag_t mod[] = { |
| 347 T1_SIG_S, T1_SIG_S|T1_SGN_S, | 347 T1_SIG_S, T1_SIG_S|T1_SGN_S, |
| 348 T1_SIG_E, T1_SIG_E|T1_SGN_E, | 348 T1_SIG_E, T1_SIG_E|T1_SGN_E, |
| 349 T1_SIG_W, T1_SIG_W|T1_SGN_W, | 349 T1_SIG_W, T1_SIG_W|T1_SGN_W, |
| 350 T1_SIG_N, T1_SIG_N|T1_SGN_N | 350 T1_SIG_N, T1_SIG_N|T1_SGN_N |
| 351 }; | 351 }; |
| 352 | 352 |
| 353 np[-1] |= T1_SIG_SE; | 353 np[-1] |= T1_SIG_SE; |
| 354 np[0] |= mod[s]; | 354 np[0] |= mod[s]; |
| 355 np[1] |= T1_SIG_SW; | 355 np[1] |= T1_SIG_SW; |
| 356 | 356 |
| 357 flagsp[-1] |= mod[s+2]; | 357 flagsp[-1] |= mod[s+2]; |
| 358 flagsp[0] |= T1_SIG; | 358 flagsp[0] |= T1_SIG; |
| 359 flagsp[1] |= mod[s+4]; | 359 flagsp[1] |= mod[s+4]; |
| 360 | 360 |
| 361 sp[-1] |= T1_SIG_NE; | 361 sp[-1] |= T1_SIG_NE; |
| 362 sp[0] |= mod[s+6]; | 362 sp[0] |= mod[s+6]; |
| 363 sp[1] |= T1_SIG_NW; | 363 sp[1] |= T1_SIG_NW; |
| 364 } | 364 } |
| 365 | 365 |
| 366 void opj_t1_enc_sigpass_step( opj_t1_t *t1, | 366 static void opj_t1_enc_sigpass_step( opj_t1_t *t1, |
| 367 opj_flag_t *flagsp, | 367 opj_flag_t *flagsp, |
| 368 OPJ_INT32 *datap, | 368 OPJ_INT32 *datap, |
| 369 OPJ_UINT32 orient, | 369 OPJ_UINT32 orient, |
| 370 OPJ_INT32 bpno, | 370 OPJ_INT32 bpno, |
| 371 OPJ_INT32 one, | 371 OPJ_INT32 one, |
| 372 OPJ_INT32 *nmsedec, | 372 OPJ_INT32 *nmsedec, |
| 373 OPJ_BYTE type, | 373 OPJ_BYTE type, |
| 374 OPJ_UINT32 vsc | 374 OPJ_UINT32 vsc |
| 375 ) | 375 ) |
| 376 { | 376 { |
| 377 OPJ_INT32 v; | 377 OPJ_INT32 v; |
| 378 OPJ_UINT32 flag; | 378 OPJ_UINT32 flag; |
| 379 | 379 |
| 380 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 380 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
| 381 | 381 |
| 382 flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_S
W | T1_SGN_S))) : (OPJ_UINT32)(*flagsp); | 382 flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_S
W | T1_SGN_S))) : (OPJ_UINT32)(*flagsp); |
| 383 if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { | 383 if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { |
| 384 v = opj_int_abs(*datap) & one ? 1 : 0; | 384 v = opj_int_abs(*datap) & one ? 1 : 0; |
| 385 opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
/* ESSAI */ | 385 opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient));
/* ESSAI */ |
| 386 if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ | 386 if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ |
| 387 opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v); | 387 opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v); |
| 388 } else { | 388 } else { |
| 389 opj_mqc_encode(mqc, (OPJ_UINT32)v); | 389 opj_mqc_encode(mqc, (OPJ_UINT32)v); |
| 390 } | 390 } |
| 391 if (v) { | 391 if (v) { |
| 392 v = *datap < 0 ? 1 : 0; | 392 v = *datap < 0 ? 1 : 0; |
| 393 » » » *nmsedec +=» opj_t1_getnmsedec_sig((OPJ_UINT32)opj_in
t_abs(*datap), (OPJ_UINT32)(bpno + T1_NMSEDEC_FRACBITS)); | 393 » » » *nmsedec +=» opj_t1_getnmsedec_sig((OPJ_UINT32)opj_in
t_abs(*datap), (OPJ_UINT32)(bpno)); |
| 394 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
/* ESSAI */ | 394 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag));
/* ESSAI */ |
| 395 if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ | 395 if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ |
| 396 opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v); | 396 opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v); |
| 397 } else { | 397 } else { |
| 398 opj_mqc_encode(mqc, (OPJ_UINT32)(v ^ opj_t1_gets
pb((OPJ_UINT32)flag))); | 398 opj_mqc_encode(mqc, (OPJ_UINT32)(v ^ opj_t1_gets
pb((OPJ_UINT32)flag))); |
| 399 } | 399 } |
| 400 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stri
de); | 400 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stri
de); |
| 401 } | 401 } |
| 402 *flagsp |= T1_VISIT; | 402 *flagsp |= T1_VISIT; |
| 403 } | 403 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 420 if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { | 420 if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { |
| 421 if (opj_raw_decode(raw)) { | 421 if (opj_raw_decode(raw)) { |
| 422 v = (OPJ_INT32)opj_raw_decode(raw); /* ESSAI
*/ | 422 v = (OPJ_INT32)opj_raw_decode(raw); /* ESSAI
*/ |
| 423 *datap = v ? -oneplushalf : oneplushalf; | 423 *datap = v ? -oneplushalf : oneplushalf; |
| 424 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->fl
ags_stride); | 424 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->fl
ags_stride); |
| 425 } | 425 } |
| 426 *flagsp |= T1_VISIT; | 426 *flagsp |= T1_VISIT; |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 INLINE void opj_t1_dec_sigpass_step_mqc( | 430 static INLINE void opj_t1_dec_sigpass_step_mqc( |
| 431 opj_t1_t *t1, | 431 opj_t1_t *t1, |
| 432 opj_flag_t *flagsp, | 432 opj_flag_t *flagsp, |
| 433 OPJ_INT32 *datap, | 433 OPJ_INT32 *datap, |
| 434 OPJ_INT32 orient, | 434 OPJ_INT32 orient, |
| 435 OPJ_INT32 oneplushalf) | 435 OPJ_INT32 oneplushalf) |
| 436 { | 436 { |
| 437 OPJ_INT32 v, flag; | 437 OPJ_INT32 v, flag; |
| 438 | 438 |
| 439 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 439 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
| 440 | 440 |
| 441 flag = *flagsp; | 441 flag = *flagsp; |
| 442 if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { | 442 if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { |
| 443 opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc((OPJ_UINT32)fl
ag, (OPJ_UINT32)orient)); | 443 opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc((OPJ_UINT32)fl
ag, (OPJ_UINT32)orient)); |
| 444 if (opj_mqc_decode(mqc)) { | 444 if (opj_mqc_decode(mqc)) { |
| 445 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_U
INT32)flag)); | 445 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_U
INT32)flag)); |
| 446 v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UIN
T32)flag); | 446 v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UIN
T32)flag); |
| 447 *datap = v ? -oneplushalf : oneplushalf; | 447 *datap = v ? -oneplushalf : oneplushalf; |
| 448 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->fl
ags_stride); | 448 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->fl
ags_stride); |
| 449 } | 449 } |
| 450 *flagsp |= T1_VISIT; | 450 *flagsp |= T1_VISIT; |
| 451 } | 451 } |
| 452 } /* VSC and BYPASS by Antonin */ | 452 } /* VSC and BYPASS by Antonin */ |
| 453 | 453 |
| 454 INLINE void opj_t1_dec_sigpass_step_mqc_vsc( | 454 static INLINE void opj_t1_dec_sigpass_step_mqc_vsc( |
| 455 opj_t1_t *t1, | 455 opj_t1_t *t1, |
| 456 opj_flag_t *flagsp, | 456 opj_flag_t *flagsp, |
| 457 OPJ_INT32 *datap, | 457 OPJ_INT32 *datap, |
| 458 OPJ_INT32 orient, | 458 OPJ_INT32 orient, |
| 459 OPJ_INT32 oneplushalf, | 459 OPJ_INT32 oneplushalf, |
| 460 OPJ_INT32 vsc) | 460 OPJ_INT32 vsc) |
| 461 { | 461 { |
| 462 OPJ_INT32 v, flag; | 462 OPJ_INT32 v, flag; |
| 463 | 463 |
| 464 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 464 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
| 465 | 465 |
| 466 flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S
))) : (*flagsp); | 466 flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S
))) : (*flagsp); |
| 467 if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { | 467 if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { |
| 468 opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc((OPJ_UINT32)flag, (OPJ
_UINT32)orient)); | 468 opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc((OPJ_UINT32)flag, (OPJ
_UINT32)orient)); |
| 469 if (opj_mqc_decode(mqc)) { | 469 if (opj_mqc_decode(mqc)) { |
| 470 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_UINT32)fl
ag)); | 470 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_UINT32)fl
ag)); |
| 471 v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UINT32)flag
); | 471 v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UINT32)flag
); |
| 472 *datap = v ? -oneplushalf : oneplushalf; | 472 *datap = v ? -oneplushalf : oneplushalf; |
| 473 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stri
de); | 473 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stri
de); |
| 474 } | 474 } |
| 475 *flagsp |= T1_VISIT; | 475 *flagsp |= T1_VISIT; |
| 476 } | 476 } |
| 477 } /* VSC and BYPASS by Antonin */ | 477 } /* VSC and BYPASS by Antonin */ |
| 478 | 478 |
| 479 | 479 |
| 480 | 480 |
| 481 void opj_t1_enc_sigpass(opj_t1_t *t1, | 481 static void opj_t1_enc_sigpass(opj_t1_t *t1, |
| 482 OPJ_INT32 bpno, | 482 OPJ_INT32 bpno, |
| 483 OPJ_UINT32 orient, | 483 OPJ_UINT32 orient, |
| 484 OPJ_INT32 *nmsedec, | 484 OPJ_INT32 *nmsedec, |
| 485 OPJ_BYTE type, | 485 OPJ_BYTE type, |
| 486 OPJ_UINT32 cblksty | 486 OPJ_UINT32 cblksty |
| 487 ) | 487 ) |
| 488 { | 488 { |
| 489 OPJ_UINT32 i, j, k, vsc; | 489 OPJ_UINT32 i, j, k, vsc; |
| 490 OPJ_INT32 one; | 490 OPJ_INT32 one; |
| 491 | 491 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 503 bpno, | 503 bpno, |
| 504 one, | 504 one, |
| 505 nmsedec, | 505 nmsedec, |
| 506 type, | 506 type, |
| 507 vsc); | 507 vsc); |
| 508 } | 508 } |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 } | 511 } |
| 512 | 512 |
| 513 void opj_t1_dec_sigpass_raw( | 513 static void opj_t1_dec_sigpass_raw( |
| 514 opj_t1_t *t1, | 514 opj_t1_t *t1, |
| 515 OPJ_INT32 bpno, | 515 OPJ_INT32 bpno, |
| 516 OPJ_INT32 orient, | 516 OPJ_INT32 orient, |
| 517 OPJ_INT32 cblksty) | 517 OPJ_INT32 cblksty) |
| 518 { | 518 { |
| 519 OPJ_INT32 one, half, oneplushalf, vsc; | 519 OPJ_INT32 one, half, oneplushalf, vsc; |
| 520 OPJ_UINT32 i, j, k; | 520 OPJ_UINT32 i, j, k; |
| 521 one = 1 << bpno; | 521 one = 1 << bpno; |
| 522 half = one >> 1; | 522 half = one >> 1; |
| 523 oneplushalf = one | half; | 523 oneplushalf = one | half; |
| 524 for (k = 0; k < t1->h; k += 4) { | 524 for (k = 0; k < t1->h; k += 4) { |
| 525 for (i = 0; i < t1->w; ++i) { | 525 for (i = 0; i < t1->w; ++i) { |
| 526 for (j = k; j < k + 4 && j < t1->h; ++j) { | 526 for (j = k; j < k + 4 && j < t1->h; ++j) { |
| 527 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; | 527 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; |
| 528 opj_t1_dec_sigpass_step_raw( | 528 opj_t1_dec_sigpass_step_raw( |
| 529 t1, | 529 t1, |
| 530 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], | 530 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], |
| 531 &t1->data[(j * t1->w) + i], | 531 &t1->data[(j * t1->w) + i], |
| 532 orient, | 532 orient, |
| 533 oneplushalf, | 533 oneplushalf, |
| 534 vsc); | 534 vsc); |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 } | 537 } |
| 538 } /* VSC and BYPASS by Antonin */ | 538 } /* VSC and BYPASS by Antonin */ |
| 539 | 539 |
| 540 void opj_t1_dec_sigpass_mqc( | 540 static void opj_t1_dec_sigpass_mqc( |
| 541 opj_t1_t *t1, | 541 opj_t1_t *t1, |
| 542 OPJ_INT32 bpno, | 542 OPJ_INT32 bpno, |
| 543 OPJ_INT32 orient) | 543 OPJ_INT32 orient) |
| 544 { | 544 { |
| 545 OPJ_INT32 one, half, oneplushalf; | 545 OPJ_INT32 one, half, oneplushalf; |
| 546 OPJ_UINT32 i, j, k; | 546 OPJ_UINT32 i, j, k; |
| 547 OPJ_INT32 *data1 = t1->data; | 547 OPJ_INT32 *data1 = t1->data; |
| 548 opj_flag_t *flags1 = &t1->flags[1]; | 548 opj_flag_t *flags1 = &t1->flags[1]; |
| 549 one = 1 << bpno; | 549 one = 1 << bpno; |
| 550 half = one >> 1; | 550 half = one >> 1; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 573 OPJ_INT32 *data2 = data1 + i; | 573 OPJ_INT32 *data2 = data1 + i; |
| 574 opj_flag_t *flags2 = flags1 + i; | 574 opj_flag_t *flags2 = flags1 + i; |
| 575 for (j = k; j < t1->h; ++j) { | 575 for (j = k; j < t1->h; ++j) { |
| 576 flags2 += t1->flags_stride; | 576 flags2 += t1->flags_stride; |
| 577 opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, o
neplushalf); | 577 opj_t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, o
neplushalf); |
| 578 data2 += t1->w; | 578 data2 += t1->w; |
| 579 } | 579 } |
| 580 } | 580 } |
| 581 } /* VSC and BYPASS by Antonin */ | 581 } /* VSC and BYPASS by Antonin */ |
| 582 | 582 |
| 583 void opj_t1_dec_sigpass_mqc_vsc( | 583 static void opj_t1_dec_sigpass_mqc_vsc( |
| 584 opj_t1_t *t1, | 584 opj_t1_t *t1, |
| 585 OPJ_INT32 bpno, | 585 OPJ_INT32 bpno, |
| 586 OPJ_INT32 orient) | 586 OPJ_INT32 orient) |
| 587 { | 587 { |
| 588 OPJ_INT32 one, half, oneplushalf, vsc; | 588 OPJ_INT32 one, half, oneplushalf, vsc; |
| 589 OPJ_UINT32 i, j, k; | 589 OPJ_UINT32 i, j, k; |
| 590 one = 1 << bpno; | 590 one = 1 << bpno; |
| 591 half = one >> 1; | 591 half = one >> 1; |
| 592 oneplushalf = one | half; | 592 oneplushalf = one | half; |
| 593 for (k = 0; k < t1->h; k += 4) { | 593 for (k = 0; k < t1->h; k += 4) { |
| 594 for (i = 0; i < t1->w; ++i) { | 594 for (i = 0; i < t1->w; ++i) { |
| 595 for (j = k; j < k + 4 && j < t1->h; ++j) { | 595 for (j = k; j < k + 4 && j < t1->h; ++j) { |
| 596 vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0; | 596 vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0; |
| 597 opj_t1_dec_sigpass_step_mqc_vsc( | 597 opj_t1_dec_sigpass_step_mqc_vsc( |
| 598 t1, | 598 t1, |
| 599 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], | 599 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], |
| 600 &t1->data[(j * t1->w) + i], | 600 &t1->data[(j * t1->w) + i], |
| 601 orient, | 601 orient, |
| 602 oneplushalf, | 602 oneplushalf, |
| 603 vsc); | 603 vsc); |
| 604 } | 604 } |
| 605 } | 605 } |
| 606 } | 606 } |
| 607 } /* VSC and BYPASS by Antonin */ | 607 } /* VSC and BYPASS by Antonin */ |
| 608 | 608 |
| 609 | 609 |
| 610 | 610 |
| 611 void opj_t1_enc_refpass_step( opj_t1_t *t1, | 611 static void opj_t1_enc_refpass_step( opj_t1_t *t1, |
| 612 opj_flag_t *flagsp, | 612 opj_flag_t *flagsp, |
| 613 OPJ_INT32 *datap, | 613 OPJ_INT32 *datap, |
| 614 OPJ_INT32 bpno, | 614 OPJ_INT32 bpno, |
| 615 OPJ_INT32 one, | 615 OPJ_INT32 one, |
| 616 OPJ_INT32 *nmsedec, | 616 OPJ_INT32 *nmsedec, |
| 617 OPJ_BYTE type, | 617 OPJ_BYTE type, |
| 618 OPJ_UINT32 vsc) | 618 OPJ_UINT32 vsc) |
| 619 { | 619 { |
| 620 OPJ_INT32 v; | 620 OPJ_INT32 v; |
| 621 OPJ_UINT32 flag; | 621 OPJ_UINT32 flag; |
| 622 | 622 |
| 623 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 623 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
| 624 | 624 |
| 625 flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_S
W | T1_SGN_S))) : (OPJ_UINT32)(*flagsp); | 625 flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_S
W | T1_SGN_S))) : (OPJ_UINT32)(*flagsp); |
| 626 if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { | 626 if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { |
| 627 » » *nmsedec += opj_t1_getnmsedec_ref((OPJ_UINT32)opj_int_abs(*datap
), (OPJ_UINT32)(bpno + T1_NMSEDEC_FRACBITS)); | 627 » » *nmsedec += opj_t1_getnmsedec_ref((OPJ_UINT32)opj_int_abs(*datap
), (OPJ_UINT32)(bpno)); |
| 628 v = opj_int_abs(*datap) & one ? 1 : 0; | 628 v = opj_int_abs(*datap) & one ? 1 : 0; |
| 629 opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag(flag)); /* ESSAI
*/ | 629 opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag(flag)); /* ESSAI
*/ |
| 630 if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ | 630 if (type == T1_TYPE_RAW) { /* BYPASS/LAZY MODE */ |
| 631 opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v); | 631 opj_mqc_bypass_enc(mqc, (OPJ_UINT32)v); |
| 632 } else { | 632 } else { |
| 633 opj_mqc_encode(mqc, (OPJ_UINT32)v); | 633 opj_mqc_encode(mqc, (OPJ_UINT32)v); |
| 634 } | 634 } |
| 635 *flagsp |= T1_REFINE; | 635 *flagsp |= T1_REFINE; |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 | 638 |
| 639 INLINE void opj_t1_dec_refpass_step_raw( | 639 static INLINE void opj_t1_dec_refpass_step_raw( |
| 640 opj_t1_t *t1, | 640 opj_t1_t *t1, |
| 641 opj_flag_t *flagsp, | 641 opj_flag_t *flagsp, |
| 642 OPJ_INT32 *datap, | 642 OPJ_INT32 *datap, |
| 643 OPJ_INT32 poshalf, | 643 OPJ_INT32 poshalf, |
| 644 OPJ_INT32 neghalf, | 644 OPJ_INT32 neghalf, |
| 645 OPJ_INT32 vsc) | 645 OPJ_INT32 vsc) |
| 646 { | 646 { |
| 647 OPJ_INT32 v, t, flag; | 647 OPJ_INT32 v, t, flag; |
| 648 | 648 |
| 649 opj_raw_t *raw = t1->raw; /* RAW component */ | 649 opj_raw_t *raw = t1->raw; /* RAW component */ |
| 650 | 650 |
| 651 flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S
))) : (*flagsp); | 651 flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S
))) : (*flagsp); |
| 652 if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { | 652 if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { |
| 653 v = (OPJ_INT32)opj_raw_decode(raw); | 653 v = (OPJ_INT32)opj_raw_decode(raw); |
| 654 t = v ? poshalf : neghalf; | 654 t = v ? poshalf : neghalf; |
| 655 *datap += *datap < 0 ? -t : t; | 655 *datap += *datap < 0 ? -t : t; |
| 656 *flagsp |= T1_REFINE; | 656 *flagsp |= T1_REFINE; |
| 657 } | 657 } |
| 658 } /* VSC and BYPASS by Antonin */ | 658 } /* VSC and BYPASS by Antonin */ |
| 659 | 659 |
| 660 INLINE void opj_t1_dec_refpass_step_mqc( | 660 static INLINE void opj_t1_dec_refpass_step_mqc( |
| 661 opj_t1_t *t1, | 661 opj_t1_t *t1, |
| 662 opj_flag_t *flagsp, | 662 opj_flag_t *flagsp, |
| 663 OPJ_INT32 *datap, | 663 OPJ_INT32 *datap, |
| 664 OPJ_INT32 poshalf, | 664 OPJ_INT32 poshalf, |
| 665 OPJ_INT32 neghalf) | 665 OPJ_INT32 neghalf) |
| 666 { | 666 { |
| 667 OPJ_INT32 v, t, flag; | 667 OPJ_INT32 v, t, flag; |
| 668 | 668 |
| 669 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 669 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
| 670 | 670 |
| 671 flag = *flagsp; | 671 flag = *flagsp; |
| 672 if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { | 672 if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { |
| 673 opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag((OPJ_UINT32)flag));
/* ESSAI */ | 673 opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag((OPJ_UINT32)flag));
/* ESSAI */ |
| 674 v = opj_mqc_decode(mqc); | 674 v = opj_mqc_decode(mqc); |
| 675 t = v ? poshalf : neghalf; | 675 t = v ? poshalf : neghalf; |
| 676 *datap += *datap < 0 ? -t : t; | 676 *datap += *datap < 0 ? -t : t; |
| 677 *flagsp |= T1_REFINE; | 677 *flagsp |= T1_REFINE; |
| 678 } | 678 } |
| 679 } /* VSC and BYPASS by Antonin */ | 679 } /* VSC and BYPASS by Antonin */ |
| 680 | 680 |
| 681 INLINE void opj_t1_dec_refpass_step_mqc_vsc( | 681 static INLINE void opj_t1_dec_refpass_step_mqc_vsc( |
| 682 opj_t1_t *t1, | 682 opj_t1_t *t1, |
| 683 opj_flag_t *flagsp, | 683 opj_flag_t *flagsp, |
| 684 OPJ_INT32 *datap, | 684 OPJ_INT32 *datap, |
| 685 OPJ_INT32 poshalf, | 685 OPJ_INT32 poshalf, |
| 686 OPJ_INT32 neghalf, | 686 OPJ_INT32 neghalf, |
| 687 OPJ_INT32 vsc) | 687 OPJ_INT32 vsc) |
| 688 { | 688 { |
| 689 OPJ_INT32 v, t, flag; | 689 OPJ_INT32 v, t, flag; |
| 690 | 690 |
| 691 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 691 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
| 692 | 692 |
| 693 flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S
))) : (*flagsp); | 693 flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S
))) : (*flagsp); |
| 694 if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { | 694 if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { |
| 695 opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag((OPJ_UINT32)flag));
/* ESSAI */ | 695 opj_mqc_setcurctx(mqc, opj_t1_getctxno_mag((OPJ_UINT32)flag));
/* ESSAI */ |
| 696 v = opj_mqc_decode(mqc); | 696 v = opj_mqc_decode(mqc); |
| 697 t = v ? poshalf : neghalf; | 697 t = v ? poshalf : neghalf; |
| 698 *datap += *datap < 0 ? -t : t; | 698 *datap += *datap < 0 ? -t : t; |
| 699 *flagsp |= T1_REFINE; | 699 *flagsp |= T1_REFINE; |
| 700 } | 700 } |
| 701 } /* VSC and BYPASS by Antonin */ | 701 } /* VSC and BYPASS by Antonin */ |
| 702 | 702 |
| 703 | 703 |
| 704 void opj_t1_enc_refpass( | 704 static void opj_t1_enc_refpass( |
| 705 opj_t1_t *t1, | 705 opj_t1_t *t1, |
| 706 OPJ_INT32 bpno, | 706 OPJ_INT32 bpno, |
| 707 OPJ_INT32 *nmsedec, | 707 OPJ_INT32 *nmsedec, |
| 708 OPJ_BYTE type, | 708 OPJ_BYTE type, |
| 709 OPJ_UINT32 cblksty) | 709 OPJ_UINT32 cblksty) |
| 710 { | 710 { |
| 711 OPJ_UINT32 i, j, k, vsc; | 711 OPJ_UINT32 i, j, k, vsc; |
| 712 OPJ_INT32 one; | 712 OPJ_INT32 one; |
| 713 | 713 |
| 714 *nmsedec = 0; | 714 *nmsedec = 0; |
| 715 one = 1 << (bpno + T1_NMSEDEC_FRACBITS); | 715 one = 1 << (bpno + T1_NMSEDEC_FRACBITS); |
| 716 for (k = 0; k < t1->h; k += 4) { | 716 for (k = 0; k < t1->h; k += 4) { |
| 717 for (i = 0; i < t1->w; ++i) { | 717 for (i = 0; i < t1->w; ++i) { |
| 718 for (j = k; j < k + 4 && j < t1->h; ++j) { | 718 for (j = k; j < k + 4 && j < t1->h; ++j) { |
| 719 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; | 719 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; |
| 720 opj_t1_enc_refpass_step( | 720 opj_t1_enc_refpass_step( |
| 721 t1, | 721 t1, |
| 722 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], | 722 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], |
| 723 &t1->data[(j * t1->data_stride)
+ i], | 723 &t1->data[(j * t1->data_stride)
+ i], |
| 724 bpno, | 724 bpno, |
| 725 one, | 725 one, |
| 726 nmsedec, | 726 nmsedec, |
| 727 type, | 727 type, |
| 728 vsc); | 728 vsc); |
| 729 } | 729 } |
| 730 } | 730 } |
| 731 } | 731 } |
| 732 } | 732 } |
| 733 | 733 |
| 734 void opj_t1_dec_refpass_raw( | 734 static void opj_t1_dec_refpass_raw( |
| 735 opj_t1_t *t1, | 735 opj_t1_t *t1, |
| 736 OPJ_INT32 bpno, | 736 OPJ_INT32 bpno, |
| 737 OPJ_INT32 cblksty) | 737 OPJ_INT32 cblksty) |
| 738 { | 738 { |
| 739 OPJ_INT32 one, poshalf, neghalf; | 739 OPJ_INT32 one, poshalf, neghalf; |
| 740 OPJ_UINT32 i, j, k; | 740 OPJ_UINT32 i, j, k; |
| 741 OPJ_INT32 vsc; | 741 OPJ_INT32 vsc; |
| 742 one = 1 << bpno; | 742 one = 1 << bpno; |
| 743 poshalf = one >> 1; | 743 poshalf = one >> 1; |
| 744 neghalf = bpno > 0 ? -poshalf : -1; | 744 neghalf = bpno > 0 ? -poshalf : -1; |
| 745 for (k = 0; k < t1->h; k += 4) { | 745 for (k = 0; k < t1->h; k += 4) { |
| 746 for (i = 0; i < t1->w; ++i) { | 746 for (i = 0; i < t1->w; ++i) { |
| 747 for (j = k; j < k + 4 && j < t1->h; ++j) { | 747 for (j = k; j < k + 4 && j < t1->h; ++j) { |
| 748 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; | 748 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; |
| 749 opj_t1_dec_refpass_step_raw( | 749 opj_t1_dec_refpass_step_raw( |
| 750 t1, | 750 t1, |
| 751 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], | 751 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], |
| 752 &t1->data[(j * t1->w) + i], | 752 &t1->data[(j * t1->w) + i], |
| 753 poshalf, | 753 poshalf, |
| 754 neghalf, | 754 neghalf, |
| 755 vsc); | 755 vsc); |
| 756 } | 756 } |
| 757 } | 757 } |
| 758 } | 758 } |
| 759 } /* VSC and BYPASS by Antonin */ | 759 } /* VSC and BYPASS by Antonin */ |
| 760 | 760 |
| 761 void opj_t1_dec_refpass_mqc( | 761 static void opj_t1_dec_refpass_mqc( |
| 762 opj_t1_t *t1, | 762 opj_t1_t *t1, |
| 763 OPJ_INT32 bpno) | 763 OPJ_INT32 bpno) |
| 764 { | 764 { |
| 765 OPJ_INT32 one, poshalf, neghalf; | 765 OPJ_INT32 one, poshalf, neghalf; |
| 766 OPJ_UINT32 i, j, k; | 766 OPJ_UINT32 i, j, k; |
| 767 OPJ_INT32 *data1 = t1->data; | 767 OPJ_INT32 *data1 = t1->data; |
| 768 opj_flag_t *flags1 = &t1->flags[1]; | 768 opj_flag_t *flags1 = &t1->flags[1]; |
| 769 one = 1 << bpno; | 769 one = 1 << bpno; |
| 770 poshalf = one >> 1; | 770 poshalf = one >> 1; |
| 771 neghalf = bpno > 0 ? -poshalf : -1; | 771 neghalf = bpno > 0 ? -poshalf : -1; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 793 OPJ_INT32 *data2 = data1 + i; | 793 OPJ_INT32 *data2 = data1 + i; |
| 794 opj_flag_t *flags2 = flags1 + i; | 794 opj_flag_t *flags2 = flags1 + i; |
| 795 for (j = k; j < t1->h; ++j) { | 795 for (j = k; j < t1->h; ++j) { |
| 796 flags2 += t1->flags_stride; | 796 flags2 += t1->flags_stride; |
| 797 opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf,
neghalf); | 797 opj_t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf,
neghalf); |
| 798 data2 += t1->w; | 798 data2 += t1->w; |
| 799 } | 799 } |
| 800 } | 800 } |
| 801 } /* VSC and BYPASS by Antonin */ | 801 } /* VSC and BYPASS by Antonin */ |
| 802 | 802 |
| 803 void opj_t1_dec_refpass_mqc_vsc( | 803 static void opj_t1_dec_refpass_mqc_vsc( |
| 804 opj_t1_t *t1, | 804 opj_t1_t *t1, |
| 805 OPJ_INT32 bpno) | 805 OPJ_INT32 bpno) |
| 806 { | 806 { |
| 807 OPJ_INT32 one, poshalf, neghalf; | 807 OPJ_INT32 one, poshalf, neghalf; |
| 808 OPJ_UINT32 i, j, k; | 808 OPJ_UINT32 i, j, k; |
| 809 OPJ_INT32 vsc; | 809 OPJ_INT32 vsc; |
| 810 one = 1 << bpno; | 810 one = 1 << bpno; |
| 811 poshalf = one >> 1; | 811 poshalf = one >> 1; |
| 812 neghalf = bpno > 0 ? -poshalf : -1; | 812 neghalf = bpno > 0 ? -poshalf : -1; |
| 813 for (k = 0; k < t1->h; k += 4) { | 813 for (k = 0; k < t1->h; k += 4) { |
| 814 for (i = 0; i < t1->w; ++i) { | 814 for (i = 0; i < t1->w; ++i) { |
| 815 for (j = k; j < k + 4 && j < t1->h; ++j) { | 815 for (j = k; j < k + 4 && j < t1->h; ++j) { |
| 816 vsc = ((j == k + 3 || j == t1->h - 1)) ? 1 : 0; | 816 vsc = ((j == k + 3 || j == t1->h - 1)) ? 1 : 0; |
| 817 opj_t1_dec_refpass_step_mqc_vsc( | 817 opj_t1_dec_refpass_step_mqc_vsc( |
| 818 t1, | 818 t1, |
| 819 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], | 819 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], |
| 820 &t1->data[(j * t1->w) + i], | 820 &t1->data[(j * t1->w) + i], |
| 821 poshalf, | 821 poshalf, |
| 822 neghalf, | 822 neghalf, |
| 823 vsc); | 823 vsc); |
| 824 } | 824 } |
| 825 } | 825 } |
| 826 } | 826 } |
| 827 } /* VSC and BYPASS by Antonin */ | 827 } /* VSC and BYPASS by Antonin */ |
| 828 | 828 |
| 829 | 829 |
| 830 void opj_t1_enc_clnpass_step( | 830 static void opj_t1_enc_clnpass_step( |
| 831 opj_t1_t *t1, | 831 opj_t1_t *t1, |
| 832 opj_flag_t *flagsp, | 832 opj_flag_t *flagsp, |
| 833 OPJ_INT32 *datap, | 833 OPJ_INT32 *datap, |
| 834 OPJ_UINT32 orient, | 834 OPJ_UINT32 orient, |
| 835 OPJ_INT32 bpno, | 835 OPJ_INT32 bpno, |
| 836 OPJ_INT32 one, | 836 OPJ_INT32 one, |
| 837 OPJ_INT32 *nmsedec, | 837 OPJ_INT32 *nmsedec, |
| 838 OPJ_UINT32 partial, | 838 OPJ_UINT32 partial, |
| 839 OPJ_UINT32 vsc) | 839 OPJ_UINT32 vsc) |
| 840 { | 840 { |
| 841 OPJ_INT32 v; | 841 OPJ_INT32 v; |
| 842 OPJ_UINT32 flag; | 842 OPJ_UINT32 flag; |
| 843 | 843 |
| 844 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 844 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
| 845 | 845 |
| 846 flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_S
W | T1_SGN_S))) : (OPJ_UINT32)(*flagsp); | 846 flag = vsc ? (OPJ_UINT32)((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_S
W | T1_SGN_S))) : (OPJ_UINT32)(*flagsp); |
| 847 if (partial) { | 847 if (partial) { |
| 848 goto LABEL_PARTIAL; | 848 goto LABEL_PARTIAL; |
| 849 } | 849 } |
| 850 if (!(*flagsp & (T1_SIG | T1_VISIT))) { | 850 if (!(*flagsp & (T1_SIG | T1_VISIT))) { |
| 851 opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient)); | 851 opj_mqc_setcurctx(mqc, opj_t1_getctxno_zc(flag, orient)); |
| 852 v = opj_int_abs(*datap) & one ? 1 : 0; | 852 v = opj_int_abs(*datap) & one ? 1 : 0; |
| 853 opj_mqc_encode(mqc, (OPJ_UINT32)v); | 853 opj_mqc_encode(mqc, (OPJ_UINT32)v); |
| 854 if (v) { | 854 if (v) { |
| 855 LABEL_PARTIAL: | 855 LABEL_PARTIAL: |
| 856 » » » *nmsedec += opj_t1_getnmsedec_sig((OPJ_UINT32)opj_int_ab
s(*datap), (OPJ_UINT32)(bpno + T1_NMSEDEC_FRACBITS)); | 856 » » » *nmsedec += opj_t1_getnmsedec_sig((OPJ_UINT32)opj_int_ab
s(*datap), (OPJ_UINT32)(bpno)); |
| 857 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag)); | 857 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag)); |
| 858 v = *datap < 0 ? 1 : 0; | 858 v = *datap < 0 ? 1 : 0; |
| 859 opj_mqc_encode(mqc, (OPJ_UINT32)(v ^ opj_t1_getspb((OPJ_
UINT32)flag))); | 859 opj_mqc_encode(mqc, (OPJ_UINT32)(v ^ opj_t1_getspb((OPJ_
UINT32)flag))); |
| 860 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stri
de); | 860 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stri
de); |
| 861 } | 861 } |
| 862 } | 862 } |
| 863 *flagsp &= ~T1_VISIT; | 863 *flagsp &= ~T1_VISIT; |
| 864 } | 864 } |
| 865 | 865 |
| 866 static void opj_t1_dec_clnpass_step_partial( | 866 static void opj_t1_dec_clnpass_step_partial( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 LABEL_PARTIAL: | 930 LABEL_PARTIAL: |
| 931 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_UINT32)fl
ag)); | 931 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc((OPJ_UINT32)fl
ag)); |
| 932 v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UINT32)flag
); | 932 v = opj_mqc_decode(mqc) ^ opj_t1_getspb((OPJ_UINT32)flag
); |
| 933 *datap = v ? -oneplushalf : oneplushalf; | 933 *datap = v ? -oneplushalf : oneplushalf; |
| 934 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stri
de); | 934 opj_t1_updateflags(flagsp, (OPJ_UINT32)v, t1->flags_stri
de); |
| 935 } | 935 } |
| 936 } | 936 } |
| 937 *flagsp &= ~T1_VISIT; | 937 *flagsp &= ~T1_VISIT; |
| 938 } | 938 } |
| 939 | 939 |
| 940 void opj_t1_enc_clnpass( | 940 static void opj_t1_enc_clnpass( |
| 941 opj_t1_t *t1, | 941 opj_t1_t *t1, |
| 942 OPJ_INT32 bpno, | 942 OPJ_INT32 bpno, |
| 943 OPJ_UINT32 orient, | 943 OPJ_UINT32 orient, |
| 944 OPJ_INT32 *nmsedec, | 944 OPJ_INT32 *nmsedec, |
| 945 OPJ_UINT32 cblksty) | 945 OPJ_UINT32 cblksty) |
| 946 { | 946 { |
| 947 OPJ_UINT32 i, j, k; | 947 OPJ_UINT32 i, j, k; |
| 948 OPJ_INT32 one; | 948 OPJ_INT32 one; |
| 949 OPJ_UINT32 agg, runlen, vsc; | 949 OPJ_UINT32 agg, runlen, vsc; |
| 950 | 950 |
| 951 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 951 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
| 952 | 952 |
| 953 *nmsedec = 0; | 953 *nmsedec = 0; |
| 954 one = 1 << (bpno + T1_NMSEDEC_FRACBITS); | 954 one = 1 << (bpno + T1_NMSEDEC_FRACBITS); |
| 955 for (k = 0; k < t1->h; k += 4) { | 955 for (k = 0; k < t1->h; k += 4) { |
| 956 for (i = 0; i < t1->w; ++i) { | 956 for (i = 0; i < t1->w; ++i) { |
| 957 if (k + 3 < t1->h) { | 957 if (k + 3 < t1->h) { |
| 958 if (cblksty & J2K_CCP_CBLKSTY_VSC) { | 958 if (cblksty & J2K_CCP_CBLKSTY_VSC) { |
| 959 agg = !(MACRO_t1_flags(1 + k,1 + i) & (T
1_SIG | T1_VISIT | T1_SIG_OTH) | 959 agg = !(MACRO_t1_flags(1 + k,1 + i) & (T
1_SIG | T1_VISIT | T1_SIG_OTH) |
| 960 || MACRO_t1_flags(1 + k + 1,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) | 960 || MACRO_t1_flags(1 + k + 1,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) |
| 961 || MACRO_t1_flags(1 + k + 2,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) | 961 || MACRO_t1_flags(1 + k + 2,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) |
| 962 || (MACRO_t1_flags(1 + k + 3,1 +
i) | 962 || (MACRO_t1_flags(1 + k + 3,1 +
i) |
| 963 & (~(T1_SIG_S | T1_SIG_SE | T1_S
IG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); | 963 & (~(T1_SIG_S | T1_SIG_SE | T1_S
IG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); |
| 964 } else { | 964 } else { |
| 965 » » » » » agg = !(MACRO_t1_flags(1 + k,1 + i) & (T
1_SIG | T1_VISIT | T1_SIG_OTH) | 965 » » » » » agg = !((MACRO_t1_flags(1 + k,1 + i) | |
| 966 » » » » » » || MACRO_t1_flags(1 + k + 1,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) | 966 » » » » » » MACRO_t1_flags(1 + k + 1,1 +
i) | |
| 967 » » » » » » || MACRO_t1_flags(1 + k + 2,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) | 967 » » » » » » MACRO_t1_flags(1 + k + 2,1 +
i) | |
| 968 » » » » » » || MACRO_t1_flags(1 + k + 3,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); | 968 » » » » » » MACRO_t1_flags(1 + k + 3,1
+ i)) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); |
| 969 } | 969 } |
| 970 } else { | 970 } else { |
| 971 agg = 0; | 971 agg = 0; |
| 972 } | 972 } |
| 973 if (agg) { | 973 if (agg) { |
| 974 for (runlen = 0; runlen < 4; ++runlen) { | 974 for (runlen = 0; runlen < 4; ++runlen) { |
| 975 if (opj_int_abs(t1->data[((k + runlen)*t
1->data_stride) + i]) & one) | 975 if (opj_int_abs(t1->data[((k + runlen)*t
1->data_stride) + i]) & one) |
| 976 break; | 976 break; |
| 977 } | 977 } |
| 978 opj_mqc_setcurctx(mqc, T1_CTXNO_AGG); | 978 opj_mqc_setcurctx(mqc, T1_CTXNO_AGG); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 } | 1054 } |
| 1055 } | 1055 } |
| 1056 } | 1056 } |
| 1057 } else { | 1057 } else { |
| 1058 OPJ_INT32 *data1 = t1->data; | 1058 OPJ_INT32 *data1 = t1->data; |
| 1059 opj_flag_t *flags1 = &t1->flags[1]; | 1059 opj_flag_t *flags1 = &t1->flags[1]; |
| 1060 for (k = 0; k < (t1->h & ~3u); k += 4) { | 1060 for (k = 0; k < (t1->h & ~3u); k += 4) { |
| 1061 for (i = 0; i < t1->w; ++i) { | 1061 for (i = 0; i < t1->w; ++i) { |
| 1062 OPJ_INT32 *data2 = data1 + i; | 1062 OPJ_INT32 *data2 = data1 + i; |
| 1063 opj_flag_t *flags2 = flags1 + i; | 1063 opj_flag_t *flags2 = flags1 + i; |
| 1064 » » » » agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG |
T1_VISIT | T1_SIG_OTH) | 1064 » » » » agg = !((MACRO_t1_flags(1 + k, 1 + i) | |
| 1065 » » » » » || MACRO_t1_flags(1 + k + 1,1 + i) & (T1
_SIG | T1_VISIT | T1_SIG_OTH) | 1065 » » » » » » » MACRO_t1_flags(1 + k + 1
, 1 + i) | |
| 1066 » » » » » || MACRO_t1_flags(1 + k + 2,1 + i) & (T1
_SIG | T1_VISIT | T1_SIG_OTH) | 1066 » » » » » » » MACRO_t1_flags(1 + k + 2
, 1 + i) | |
| 1067 » » » » » || MACRO_t1_flags(1 + k + 3,1 + i) & (T1
_SIG | T1_VISIT | T1_SIG_OTH)); | 1067 » » » » » » » MACRO_t1_flags(1 + k + 3
, 1 + i)) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); |
| 1068 if (agg) { | 1068 if (agg) { |
| 1069 opj_mqc_setcurctx(mqc, T1_CTXNO_AGG); | 1069 opj_mqc_setcurctx(mqc, T1_CTXNO_AGG); |
| 1070 if (!opj_mqc_decode(mqc)) { | 1070 if (!opj_mqc_decode(mqc)) { |
| 1071 continue; | 1071 continue; |
| 1072 } | 1072 } |
| 1073 opj_mqc_setcurctx(mqc, T1_CTXNO_UNI); | 1073 opj_mqc_setcurctx(mqc, T1_CTXNO_UNI); |
| 1074 runlen = opj_mqc_decode(mqc); | 1074 runlen = opj_mqc_decode(mqc); |
| 1075 runlen = (runlen << 1) | opj_mqc_decode(
mqc); | 1075 runlen = (runlen << 1) | opj_mqc_decode(
mqc); |
| 1076 flags2 += (OPJ_UINT32)runlen * t1->flags
_stride; | 1076 flags2 += (OPJ_UINT32)runlen * t1->flags
_stride; |
| 1077 data2 += (OPJ_UINT32)runlen * t1->w; | 1077 data2 += (OPJ_UINT32)runlen * t1->w; |
| 1078 » » » » » for (j = k + (OPJ_UINT32)runlen; j < k +
4 && j < t1->h; ++j) { | 1078 » » » » » for (j = (OPJ_UINT32)runlen; j < 4 && j
< t1->h; ++j) { |
| 1079 flags2 += t1->flags_stride; | 1079 flags2 += t1->flags_stride; |
| 1080 » » » » » » if (agg && (j == k + (OPJ_UINT32
)runlen)) { | 1080 » » » » » » if (agg && (j == (OPJ_UINT32)run
len)) { |
| 1081 opj_t1_dec_clnpass_step_
partial(t1, flags2, data2, orient, oneplushalf); | 1081 opj_t1_dec_clnpass_step_
partial(t1, flags2, data2, orient, oneplushalf); |
| 1082 } else { | 1082 } else { |
| 1083 opj_t1_dec_clnpass_step(
t1, flags2, data2, orient, oneplushalf); | 1083 opj_t1_dec_clnpass_step(
t1, flags2, data2, orient, oneplushalf); |
| 1084 } | 1084 } |
| 1085 data2 += t1->w; | 1085 data2 += t1->w; |
| 1086 } | 1086 } |
| 1087 } else { | 1087 } else { |
| 1088 flags2 += t1->flags_stride; | 1088 flags2 += t1->flags_stride; |
| 1089 opj_t1_dec_clnpass_step(t1, flags2, data
2, orient, oneplushalf); | 1089 opj_t1_dec_clnpass_step(t1, flags2, data
2, orient, oneplushalf); |
| 1090 data2 += t1->w; | 1090 data2 += t1->w; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 } else { /* if (qmfbid == 0) */ | 1154 } else { /* if (qmfbid == 0) */ |
| 1155 w2 = opj_dwt_getnorm_real(level, orient); | 1155 w2 = opj_dwt_getnorm_real(level, orient); |
| 1156 } | 1156 } |
| 1157 | 1157 |
| 1158 wmsedec = w1 * w2 * stepsize * (1 << bpno); | 1158 wmsedec = w1 * w2 * stepsize * (1 << bpno); |
| 1159 wmsedec *= wmsedec * nmsedec / 8192.0; | 1159 wmsedec *= wmsedec * nmsedec / 8192.0; |
| 1160 | 1160 |
| 1161 return wmsedec; | 1161 return wmsedec; |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 OPJ_BOOL opj_t1_allocate_buffers( | 1164 static OPJ_BOOL opj_t1_allocate_buffers( |
| 1165 opj_t1_t *t1, | 1165 opj_t1_t *t1, |
| 1166 OPJ_UINT32 w, | 1166 OPJ_UINT32 w, |
| 1167 OPJ_UINT32 h) | 1167 OPJ_UINT32 h) |
| 1168 { | 1168 { |
| 1169 OPJ_UINT32 datasize=w * h; | 1169 OPJ_UINT32 datasize=w * h; |
| 1170 OPJ_UINT32 flagssize; | 1170 OPJ_UINT32 flagssize; |
| 1171 | 1171 |
| 1172 /* encoder uses tile buffer, so no need to allocate */ | 1172 /* encoder uses tile buffer, so no need to allocate */ |
| 1173 if (!t1->encoder) { | 1173 if (!t1->encoder) { |
| 1174 if(datasize > t1->datasize){ | 1174 if(datasize > t1->datasize){ |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 | 1281 |
| 1282 for (bandno = 0; bandno < res->numbands; ++bandno) { | 1282 for (bandno = 0; bandno < res->numbands; ++bandno) { |
| 1283 opj_tcd_band_t* restrict band = &res->bands[bandno]; | 1283 opj_tcd_band_t* restrict band = &res->bands[bandno]; |
| 1284 | 1284 |
| 1285 for (precno = 0; precno < res->pw * res->ph; ++precno) { | 1285 for (precno = 0; precno < res->pw * res->ph; ++precno) { |
| 1286 opj_tcd_precinct_t* precinct = &band->precincts[
precno]; | 1286 opj_tcd_precinct_t* precinct = &band->precincts[
precno]; |
| 1287 | 1287 |
| 1288 for (cblkno = 0; cblkno < precinct->cw * precinc
t->ch; ++cblkno) { | 1288 for (cblkno = 0; cblkno < precinct->cw * precinc
t->ch; ++cblkno) { |
| 1289 opj_tcd_cblk_dec_t* cblk = &precinct->cb
lks.dec[cblkno]; | 1289 opj_tcd_cblk_dec_t* cblk = &precinct->cb
lks.dec[cblkno]; |
| 1290 OPJ_INT32* restrict datap; | 1290 OPJ_INT32* restrict datap; |
| 1291 /*void* restrict tiledp;*/ | |
| 1292 OPJ_UINT32 cblk_w, cblk_h; | 1291 OPJ_UINT32 cblk_w, cblk_h; |
| 1293 OPJ_INT32 x, y; | 1292 OPJ_INT32 x, y; |
| 1294 OPJ_UINT32 i, j; | 1293 OPJ_UINT32 i, j; |
| 1295 | 1294 |
| 1296 if (OPJ_FALSE == opj_t1_decode_cblk( | 1295 if (OPJ_FALSE == opj_t1_decode_cblk( |
| 1297 t1, | 1296 t1, |
| 1298 cblk, | 1297 cblk, |
| 1299 band->bandno, | 1298 band->bandno, |
| 1300 (OPJ_UINT32)tccp->roishift, | 1299 (OPJ_UINT32)tccp->roishift, |
| 1301 tccp->cblksty)) { | 1300 tccp->cblksty)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1323 for (i = 0; i < cblk_w;
++i) { | 1322 for (i = 0; i < cblk_w;
++i) { |
| 1324 OPJ_INT32 val =
datap[(j * cblk_w) + i]; | 1323 OPJ_INT32 val =
datap[(j * cblk_w) + i]; |
| 1325 OPJ_INT32 mag =
abs(val); | 1324 OPJ_INT32 mag =
abs(val); |
| 1326 if (mag >= thres
h) { | 1325 if (mag >= thres
h) { |
| 1327 mag >>=
tccp->roishift; | 1326 mag >>=
tccp->roishift; |
| 1328 datap[(j
* cblk_w) + i] = val < 0 ? -mag : mag; | 1327 datap[(j
* cblk_w) + i] = val < 0 ? -mag : mag; |
| 1329 } | 1328 } |
| 1330 } | 1329 } |
| 1331 } | 1330 } |
| 1332 } | 1331 } |
| 1333 | |
| 1334 /*tiledp=(void*)&tilec->data[(y * tile_w
) + x];*/ | |
| 1335 if (tccp->qmfbid == 1) { | 1332 if (tccp->qmfbid == 1) { |
| 1336 OPJ_INT32* restrict tiledp = &tilec->data[(OPJ_UINT32)y
* tile_w + (OPJ_UINT32)x]; | 1333 OPJ_INT32* restrict tiledp = &tilec->data[(OPJ_UINT32)y
* tile_w + (OPJ_UINT32)x]; |
| 1337 for (j = 0; j < cblk_h; ++j) { | 1334 for (j = 0; j < cblk_h; ++j) { |
| 1338 for (i = 0; i < cblk_w;
++i) { | 1335 for (i = 0; i < cblk_w;
++i) { |
| 1339 OPJ_INT32 tmp =
datap[(j * cblk_w) + i]; | 1336 OPJ_INT32 tmp =
datap[(j * cblk_w) + i]; |
| 1340 » » » » » » » » ((OPJ_INT32*)til
edp)[(j * tile_w) + i] = tmp / 2; | 1337 » » » » » » » » ((OPJ_INT32*)til
edp)[(j * tile_w) + i] = tmp/2; |
| 1341 } | 1338 } |
| 1342 } | 1339 } |
| 1343 } else { /* if (tccp->qmf
bid == 0) */ | 1340 } else { /* if (tccp->qmf
bid == 0) */ |
| 1344 OPJ_FLOAT32* restrict tiledp = (OPJ_FLOAT32*) &tilec->da
ta[(OPJ_UINT32)y * tile_w + (OPJ_UINT32)x]; | 1341 OPJ_FLOAT32* restrict tiledp = (OPJ_FLOAT32*) &tilec->da
ta[(OPJ_UINT32)y * tile_w + (OPJ_UINT32)x]; |
| 1345 for (j = 0; j < cblk_h; ++j) { | 1342 for (j = 0; j < cblk_h; ++j) { |
| 1346 OPJ_FLOAT32* restrict tiledp2 = tiledp; | 1343 OPJ_FLOAT32* restrict tiledp2 = tiledp; |
| 1347 for (i = 0; i < cblk_w;
++i) { | 1344 for (i = 0; i < cblk_w;
++i) { |
| 1348 OPJ_FLOAT32 tmp = (OPJ_FLOAT32)*datap * band->st
epsize; | 1345 OPJ_FLOAT32 tmp = (OPJ_FLOAT32)*datap * band->st
epsize; |
| 1349 *tiledp2 = tmp; | 1346 *tiledp2 = tmp; |
| 1350 datap++; | 1347 datap++; |
| 1351 tiledp2++; | 1348 tiledp2++; |
| 1352 /*float tmp = da
tap[(j * cblk_w) + i] * band->stepsize; | |
| 1353 ((float*)tiledp)
[(j * tile_w) + i] = tmp;*/ | |
| 1354 | |
| 1355 } | 1349 } |
| 1356 tiledp += tile_w; | 1350 tiledp += tile_w; |
| 1357 } | 1351 } |
| 1358 } | 1352 } |
| 1359 /*opj_free(cblk->data); | |
| 1360 opj_free(cblk->segs);*/ | |
| 1361 /*cblk->segs = 00;*/ | |
| 1362 } /* cblkno */ | 1353 } /* cblkno */ |
| 1363 /*opj_free(precinct->cblks.dec);*/ | |
| 1364 } /* precno */ | 1354 } /* precno */ |
| 1365 } /* bandno */ | 1355 } /* bandno */ |
| 1366 } /* resno */ | 1356 } /* resno */ |
| 1367 return OPJ_TRUE; | 1357 return OPJ_TRUE; |
| 1368 } | 1358 } |
| 1369 | 1359 |
| 1370 | 1360 |
| 1371 OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1, | 1361 static OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1, |
| 1372 opj_tcd_cblk_dec_t* cblk, | 1362 opj_tcd_cblk_dec_t* cblk, |
| 1373 OPJ_UINT32 orient, | 1363 OPJ_UINT32 orient, |
| 1374 OPJ_UINT32 roishift, | 1364 OPJ_UINT32 roishift, |
| 1375 OPJ_UINT32 cblksty) | 1365 OPJ_UINT32 cblksty) |
| 1376 { | 1366 { |
| 1377 opj_raw_t *raw = t1->raw; /* RAW component */ | 1367 opj_raw_t *raw = t1->raw; /* RAW component */ |
| 1378 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 1368 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
| 1379 | 1369 |
| 1380 » OPJ_INT32 bpno; | 1370 » OPJ_INT32 bpno_plus_one; |
| 1381 OPJ_UINT32 passtype; | 1371 OPJ_UINT32 passtype; |
| 1382 OPJ_UINT32 segno, passno; | 1372 OPJ_UINT32 segno, passno; |
| 1383 OPJ_BYTE type = T1_TYPE_MQ; /* BYPASS mode */ | 1373 OPJ_BYTE type = T1_TYPE_MQ; /* BYPASS mode */ |
| 1384 | 1374 |
| 1385 if(!opj_t1_allocate_buffers( | 1375 if(!opj_t1_allocate_buffers( |
| 1386 t1, | 1376 t1, |
| 1387 (OPJ_UINT32)(cblk->x1 - cblk->x0), | 1377 (OPJ_UINT32)(cblk->x1 - cblk->x0), |
| 1388 (OPJ_UINT32)(cblk->y1 - cblk->y0))) | 1378 (OPJ_UINT32)(cblk->y1 - cblk->y0))) |
| 1389 { | 1379 { |
| 1390 return OPJ_FALSE; | 1380 return OPJ_FALSE; |
| 1391 } | 1381 } |
| 1392 | 1382 |
| 1393 » bpno = (OPJ_INT32)(roishift + cblk->numbps - 1); | 1383 » bpno_plus_one = (OPJ_INT32)(roishift + cblk->numbps); |
| 1394 passtype = 2; | 1384 passtype = 2; |
| 1395 | 1385 |
| 1396 opj_mqc_resetstates(mqc); | 1386 opj_mqc_resetstates(mqc); |
| 1397 opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46); | 1387 opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46); |
| 1398 opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3); | 1388 opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3); |
| 1399 opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4); | 1389 opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4); |
| 1400 | 1390 |
| 1401 for (segno = 0; segno < cblk->real_num_segs; ++segno) { | 1391 for (segno = 0; segno < cblk->real_num_segs; ++segno) { |
| 1402 opj_tcd_seg_t *seg = &cblk->segs[segno]; | 1392 opj_tcd_seg_t *seg = &cblk->segs[segno]; |
| 1403 | 1393 |
| 1404 /* BYPASS mode */ | 1394 /* BYPASS mode */ |
| 1405 » » type = ((bpno <= ((OPJ_INT32) (cblk->numbps) - 1) - 4) && (passt
ype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ; | 1395 » » type = ((bpno_plus_one <= ((OPJ_INT32) (cblk->numbps)) - 4) && (
passtype < 2) && (cblksty & J2K_CCP_CBLKSTY_LAZY)) ? T1_TYPE_RAW : T1_TYPE_MQ; |
| 1406 /* FIXME: slviewer gets here with a null pointer. Why? Partially
downloaded and/or corrupt textures? */ | 1396 /* FIXME: slviewer gets here with a null pointer. Why? Partially
downloaded and/or corrupt textures? */ |
| 1407 if(seg->data == 00){ | 1397 if(seg->data == 00){ |
| 1408 continue; | 1398 continue; |
| 1409 } | 1399 } |
| 1410 if (type == T1_TYPE_RAW) { | 1400 if (type == T1_TYPE_RAW) { |
| 1411 opj_raw_init_dec(raw, (*seg->data) + seg->dataindex, seg
->len); | 1401 opj_raw_init_dec(raw, (*seg->data) + seg->dataindex, seg
->len); |
| 1412 } else { | 1402 } else { |
| 1413 if (OPJ_FALSE == opj_mqc_init_dec(mqc, (*seg->data) + seg->dataindex
, seg->len)) { | 1403 if (OPJ_FALSE == opj_mqc_init_dec(mqc, (*seg->data) + seg->dataindex
, seg->len)) { |
| 1414 return OPJ_FALSE; | 1404 return OPJ_FALSE; |
| 1415 } | 1405 } |
| 1416 } | 1406 } |
| 1417 | 1407 |
| 1418 for (passno = 0; passno < seg->real_num_passes; ++passno) { | 1408 for (passno = 0; passno < seg->real_num_passes; ++passno) { |
| 1419 switch (passtype) { | 1409 switch (passtype) { |
| 1420 case 0: | 1410 case 0: |
| 1421 if (type == T1_TYPE_RAW) { | 1411 if (type == T1_TYPE_RAW) { |
| 1422 opj_t1_dec_sigpass_raw(t1, bpno+1, (OPJ_INT32)orient, (O
PJ_INT32)cblksty); | 1412 opj_t1_dec_sigpass_raw(t1, bpno_plus_one, (OPJ_INT32)ori
ent, (OPJ_INT32)cblksty); |
| 1423 } else { | 1413 } else { |
| 1424 if (cblksty & J2K_CCP_CBLKSTY_VSC) { | 1414 if (cblksty & J2K_CCP_CBLKSTY_VSC) { |
| 1425 opj_t1_dec_sigpass_mqc_vsc(t1, bpno+1, (OPJ_INT32)or
ient); | 1415 opj_t1_dec_sigpass_mqc_vsc(t1, bpno_plus_one, (OPJ_I
NT32)orient); |
| 1426 } else { | 1416 } else { |
| 1427 opj_t1_dec_sigpass_mqc(t1, bpno+1, (OPJ_INT32)orient
); | 1417 opj_t1_dec_sigpass_mqc(t1, bpno_plus_one, (OPJ_INT32
)orient); |
| 1428 } | 1418 } |
| 1429 } | 1419 } |
| 1430 break; | 1420 break; |
| 1431 case 1: | 1421 case 1: |
| 1432 if (type == T1_TYPE_RAW) { | 1422 if (type == T1_TYPE_RAW) { |
| 1433 opj_t1_dec_refpass_raw(t1, bpno+1, (OPJ_INT32)cblkst
y); | 1423 opj_t1_dec_refpass_raw(t1, bpno_plus_one, (OPJ_INT32
)cblksty); |
| 1434 } else { | 1424 } else { |
| 1435 if (cblksty & J2K_CCP_CBLKSTY_VSC) { | 1425 if (cblksty & J2K_CCP_CBLKSTY_VSC) { |
| 1436 opj_t1_dec_refpass_mqc_vsc(t1, bpno+1); | 1426 opj_t1_dec_refpass_mqc_vsc(t1, bpno_plus_one); |
| 1437 } else { | 1427 } else { |
| 1438 opj_t1_dec_refpass_mqc(t1, bpno+1); | 1428 opj_t1_dec_refpass_mqc(t1, bpno_plus_one); |
| 1439 } | 1429 } |
| 1440 } | 1430 } |
| 1441 break; | 1431 break; |
| 1442 case 2: | 1432 case 2: |
| 1443 opj_t1_dec_clnpass(t1, bpno+1, (OPJ_INT32)orient, (OPJ_INT32
)cblksty); | 1433 opj_t1_dec_clnpass(t1, bpno_plus_one, (OPJ_INT32)orient, (OP
J_INT32)cblksty); |
| 1444 break; | 1434 break; |
| 1445 } | 1435 } |
| 1446 | 1436 |
| 1447 if ((cblksty & J2K_CCP_CBLKSTY_RESET) && type == T1_TYPE
_MQ) { | 1437 if ((cblksty & J2K_CCP_CBLKSTY_RESET) && type == T1_TYPE
_MQ) { |
| 1448 opj_mqc_resetstates(mqc); | 1438 opj_mqc_resetstates(mqc); |
| 1449 opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46); | 1439 opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46); |
| 1450 opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3); | 1440 opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3); |
| 1451 opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4); | 1441 opj_mqc_setstate(mqc, T1_CTXNO_ZC, 0, 4); |
| 1452 } | 1442 } |
| 1453 if (++passtype == 3) { | 1443 if (++passtype == 3) { |
| 1454 passtype = 0; | 1444 passtype = 0; |
| 1455 » » » » bpno--; | 1445 » » » » bpno_plus_one--; |
| 1456 } | 1446 } |
| 1457 } | 1447 } |
| 1458 } | 1448 } |
| 1459 return OPJ_TRUE; | 1449 return OPJ_TRUE; |
| 1460 } | 1450 } |
| 1461 | 1451 |
| 1462 | 1452 |
| 1463 | 1453 |
| 1464 | 1454 |
| 1465 OPJ_BOOL opj_t1_encode_cblks( opj_t1_t *t1, | 1455 OPJ_BOOL opj_t1_encode_cblks( opj_t1_t *t1, |
| 1466 opj_tcd_tile_t *tile, | 1456 opj_tcd_tile_t *tile, |
| 1467 opj_tcp_t *tcp, | 1457 opj_tcp_t *tcp, |
| 1468 const OPJ_FLOAT64 * mct_norms, | 1458 const OPJ_FLOAT64 * mct_norms, |
| 1469 OPJ_UINT32 mct_numcomps | 1459 OPJ_UINT32 mct_numcomps |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 | 1549 |
| 1560 } /* cblkno */ | 1550 } /* cblkno */ |
| 1561 } /* precno */ | 1551 } /* precno */ |
| 1562 } /* bandno */ | 1552 } /* bandno */ |
| 1563 } /* resno */ | 1553 } /* resno */ |
| 1564 } /* compno */ | 1554 } /* compno */ |
| 1565 return OPJ_TRUE; | 1555 return OPJ_TRUE; |
| 1566 } | 1556 } |
| 1567 | 1557 |
| 1568 /** mod fixed_quality */ | 1558 /** mod fixed_quality */ |
| 1569 void opj_t1_encode_cblk(opj_t1_t *t1, | 1559 static void opj_t1_encode_cblk(opj_t1_t *t1, |
| 1570 opj_tcd_cblk_enc_t* cblk, | 1560 opj_tcd_cblk_enc_t* cblk, |
| 1571 OPJ_UINT32 orient, | 1561 OPJ_UINT32 orient, |
| 1572 OPJ_UINT32 compno, | 1562 OPJ_UINT32 compno, |
| 1573 OPJ_UINT32 level, | 1563 OPJ_UINT32 level, |
| 1574 OPJ_UINT32 qmfbid, | 1564 OPJ_UINT32 qmfbid, |
| 1575 OPJ_FLOAT64 stepsize, | 1565 OPJ_FLOAT64 stepsize, |
| 1576 OPJ_UINT32 cblksty, | 1566 OPJ_UINT32 cblksty, |
| 1577 OPJ_UINT32 numcomps, | 1567 OPJ_UINT32 numcomps, |
| 1578 opj_tcd_tile_t * tile, | 1568 opj_tcd_tile_t * tile, |
| 1579 const OPJ_FLOAT64 * mct_norms, | 1569 const OPJ_FLOAT64 * mct_norms, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 pass->rate = opj_mqc_numbytes(mqc); | 1689 pass->rate = opj_mqc_numbytes(mqc); |
| 1700 /*Preventing generation of FF as last data byte of a pass*/ | 1690 /*Preventing generation of FF as last data byte of a pass*/ |
| 1701 if((pass->rate>1) && (cblk->data[pass->rate - 1] == 0xFF)){ | 1691 if((pass->rate>1) && (cblk->data[pass->rate - 1] == 0xFF)){ |
| 1702 pass->rate--; | 1692 pass->rate--; |
| 1703 } | 1693 } |
| 1704 pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno
- 1].rate); | 1694 pass->len = pass->rate - (passno == 0 ? 0 : cblk->passes[passno
- 1].rate); |
| 1705 } | 1695 } |
| 1706 } | 1696 } |
| 1707 | 1697 |
| 1708 #if 0 | 1698 #if 0 |
| 1709 void opj_t1_dec_refpass_step( opj_t1_t *t1, | 1699 static void opj_t1_dec_refpass_step( opj_t1_t *t1, |
| 1710 opj_flag_t *flagsp, | 1700 opj_flag_t *flagsp, |
| 1711 OPJ_INT32 *datap, | 1701 OPJ_INT32 *datap, |
| 1712 OPJ_INT32 poshalf, | 1702 OPJ_INT32 poshalf, |
| 1713 OPJ_INT32 neghalf, | 1703 OPJ_INT32 neghalf, |
| 1714 OPJ_BYTE type, | 1704 OPJ_BYTE type, |
| 1715 OPJ_UINT32 vsc) | 1705 OPJ_UINT32 vsc) |
| 1716 { | 1706 { |
| 1717 OPJ_INT32 t; | 1707 OPJ_INT32 t; |
| 1718 OPJ_UINT32 v,flag; | 1708 OPJ_UINT32 v,flag; |
| 1719 | 1709 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1731 t = v ? poshalf : neghalf; | 1721 t = v ? poshalf : neghalf; |
| 1732 *datap += *datap < 0 ? -t : t; | 1722 *datap += *datap < 0 ? -t : t; |
| 1733 *flagsp |= T1_REFINE; | 1723 *flagsp |= T1_REFINE; |
| 1734 } | 1724 } |
| 1735 } /* VSC and BYPASS by Antonin */ | 1725 } /* VSC and BYPASS by Antonin */ |
| 1736 #endif | 1726 #endif |
| 1737 | 1727 |
| 1738 | 1728 |
| 1739 | 1729 |
| 1740 #if 0 | 1730 #if 0 |
| 1741 void opj_t1_dec_sigpass_step( opj_t1_t *t1, | 1731 static void opj_t1_dec_sigpass_step( opj_t1_t *t1, |
| 1742 opj_flag_t *flagsp, | 1732 opj_flag_t *flagsp, |
| 1743 OPJ_INT32 *datap, | 1733 OPJ_INT32 *datap, |
| 1744 OPJ_UINT32 orient, | 1734 OPJ_UINT32 orient, |
| 1745 OPJ_INT32 oneplushalf, | 1735 OPJ_INT32 oneplushalf, |
| 1746 OPJ_BYTE type, | 1736 OPJ_BYTE type, |
| 1747 OPJ_UINT32 vsc) | 1737 OPJ_UINT32 vsc) |
| 1748 { | 1738 { |
| 1749 OPJ_UINT32 v, flag; | 1739 OPJ_UINT32 v, flag; |
| 1750 | 1740 |
| 1751 opj_raw_t *raw = t1->raw; /* RAW component */ | 1741 opj_raw_t *raw = t1->raw; /* RAW component */ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1765 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag))
; | 1755 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag))
; |
| 1766 v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag); | 1756 v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag); |
| 1767 *datap = v ? -oneplushalf : oneplushalf; | 1757 *datap = v ? -oneplushalf : oneplushalf; |
| 1768 opj_t1_updateflags(flagsp, v, t1->flags_stride); | 1758 opj_t1_updateflags(flagsp, v, t1->flags_stride); |
| 1769 } | 1759 } |
| 1770 } | 1760 } |
| 1771 *flagsp |= T1_VISIT; | 1761 *flagsp |= T1_VISIT; |
| 1772 } | 1762 } |
| 1773 } /* VSC and BYPASS by Antonin */ | 1763 } /* VSC and BYPASS by Antonin */ |
| 1774 #endif | 1764 #endif |
| OLD | NEW |