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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 258 |
259 static OPJ_FLOAT64 opj_t1_getwmsedec( | 259 static OPJ_FLOAT64 opj_t1_getwmsedec( |
260 OPJ_INT32 nmsedec, | 260 OPJ_INT32 nmsedec, |
261 OPJ_UINT32 compno, | 261 OPJ_UINT32 compno, |
262 OPJ_UINT32 level, | 262 OPJ_UINT32 level, |
263 OPJ_UINT32 orient, | 263 OPJ_UINT32 orient, |
264 OPJ_INT32 bpno, | 264 OPJ_INT32 bpno, |
265 OPJ_UINT32 qmfbid, | 265 OPJ_UINT32 qmfbid, |
266 OPJ_FLOAT64 stepsize, | 266 OPJ_FLOAT64 stepsize, |
267 OPJ_UINT32 numcomps, | 267 OPJ_UINT32 numcomps, |
268 » » const OPJ_FLOAT64 * mct_norms); | 268 » » const OPJ_FLOAT64 * mct_norms, |
| 269 » » OPJ_UINT32 mct_numcomps); |
269 | 270 |
270 static void opj_t1_encode_cblk( opj_t1_t *t1, | 271 static void opj_t1_encode_cblk( opj_t1_t *t1, |
271 opj_tcd_cblk_enc_t* cblk, | 272 opj_tcd_cblk_enc_t* cblk, |
272 OPJ_UINT32 orient, | 273 OPJ_UINT32 orient, |
273 OPJ_UINT32 compno, | 274 OPJ_UINT32 compno, |
274 OPJ_UINT32 level, | 275 OPJ_UINT32 level, |
275 OPJ_UINT32 qmfbid, | 276 OPJ_UINT32 qmfbid, |
276 OPJ_FLOAT64 stepsize, | 277 OPJ_FLOAT64 stepsize, |
277 OPJ_UINT32 cblksty, | 278 OPJ_UINT32 cblksty, |
278 OPJ_UINT32 numcomps, | 279 OPJ_UINT32 numcomps, |
279 opj_tcd_tile_t * tile, | 280 opj_tcd_tile_t * tile, |
280 const OPJ_FLOAT64 * mct_norms); | 281 const OPJ_FLOAT64 * mct_norms, |
| 282 OPJ_UINT32 mct_numcomps); |
281 | 283 |
282 /** | 284 /** |
283 Decode 1 code-block | 285 Decode 1 code-block |
284 @param t1 T1 handle | 286 @param t1 T1 handle |
285 @param cblk Code-block coding parameters | 287 @param cblk Code-block coding parameters |
286 @param orient | 288 @param orient |
287 @param roishift Region of interest shifting value | 289 @param roishift Region of interest shifting value |
288 @param cblksty Code-block style | 290 @param cblksty Code-block style |
289 */ | 291 */ |
290 static OPJ_BOOL opj_t1_decode_cblk( opj_t1_t *t1, | 292 static OPJ_BOOL opj_t1_decode_cblk( opj_t1_t *t1, |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 /** mod fixed_quality */ | 1132 /** mod fixed_quality */ |
1131 static OPJ_FLOAT64 opj_t1_getwmsedec( | 1133 static OPJ_FLOAT64 opj_t1_getwmsedec( |
1132 OPJ_INT32 nmsedec, | 1134 OPJ_INT32 nmsedec, |
1133 OPJ_UINT32 compno, | 1135 OPJ_UINT32 compno, |
1134 OPJ_UINT32 level, | 1136 OPJ_UINT32 level, |
1135 OPJ_UINT32 orient, | 1137 OPJ_UINT32 orient, |
1136 OPJ_INT32 bpno, | 1138 OPJ_INT32 bpno, |
1137 OPJ_UINT32 qmfbid, | 1139 OPJ_UINT32 qmfbid, |
1138 OPJ_FLOAT64 stepsize, | 1140 OPJ_FLOAT64 stepsize, |
1139 OPJ_UINT32 numcomps, | 1141 OPJ_UINT32 numcomps, |
1140 » » const OPJ_FLOAT64 * mct_norms) | 1142 » » const OPJ_FLOAT64 * mct_norms, |
| 1143 » » OPJ_UINT32 mct_numcomps) |
1141 { | 1144 { |
1142 OPJ_FLOAT64 w1 = 1, w2, wmsedec; | 1145 OPJ_FLOAT64 w1 = 1, w2, wmsedec; |
1143 OPJ_ARG_NOT_USED(numcomps); | 1146 » OPJ_ARG_NOT_USED(numcomps); |
1144 | 1147 |
1145 » if (mct_norms) { | 1148 » if (mct_norms && (compno < mct_numcomps)) { |
1146 w1 = mct_norms[compno]; | 1149 w1 = mct_norms[compno]; |
1147 } | 1150 } |
1148 | 1151 |
1149 if (qmfbid == 1) { | 1152 if (qmfbid == 1) { |
1150 w2 = opj_dwt_getnorm(level, orient); | 1153 w2 = opj_dwt_getnorm(level, orient); |
1151 } else { /* if (qmfbid == 0) */ | 1154 } else { /* if (qmfbid == 0) */ |
1152 w2 = opj_dwt_getnorm_real(level, orient); | 1155 w2 = opj_dwt_getnorm_real(level, orient); |
1153 } | 1156 } |
1154 | 1157 |
1155 wmsedec = w1 * w2 * stepsize * (1 << bpno); | 1158 wmsedec = w1 * w2 * stepsize * (1 << bpno); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 } | 1458 } |
1456 return OPJ_TRUE; | 1459 return OPJ_TRUE; |
1457 } | 1460 } |
1458 | 1461 |
1459 | 1462 |
1460 | 1463 |
1461 | 1464 |
1462 OPJ_BOOL opj_t1_encode_cblks( opj_t1_t *t1, | 1465 OPJ_BOOL opj_t1_encode_cblks( opj_t1_t *t1, |
1463 opj_tcd_tile_t *tile, | 1466 opj_tcd_tile_t *tile, |
1464 opj_tcp_t *tcp, | 1467 opj_tcp_t *tcp, |
1465 const OPJ_FLOAT64 * mct_norms | 1468 const OPJ_FLOAT64 * mct_norms, |
| 1469 OPJ_UINT32 mct_numcomps |
1466 ) | 1470 ) |
1467 { | 1471 { |
1468 OPJ_UINT32 compno, resno, bandno, precno, cblkno; | 1472 OPJ_UINT32 compno, resno, bandno, precno, cblkno; |
1469 | 1473 |
1470 tile->distotile = 0; /* fixed_quality */ | 1474 tile->distotile = 0; /* fixed_quality */ |
1471 | 1475 |
1472 for (compno = 0; compno < tile->numcomps; ++compno) { | 1476 for (compno = 0; compno < tile->numcomps; ++compno) { |
1473 opj_tcd_tilecomp_t* tilec = &tile->comps[compno]; | 1477 opj_tcd_tilecomp_t* tilec = &tile->comps[compno]; |
1474 opj_tccp_t* tccp = &tcp->tccps[compno]; | 1478 opj_tccp_t* tccp = &tcp->tccps[compno]; |
1475 OPJ_UINT32 tile_w = (OPJ_UINT32)(tilec->x1 - tilec->x0); | 1479 OPJ_UINT32 tile_w = (OPJ_UINT32)(tilec->x1 - tilec->x0); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 tiledp[t
ileIndex] <<= T1_NMSEDEC_FRACBITS; | 1527 tiledp[t
ileIndex] <<= T1_NMSEDEC_FRACBITS; |
1524 tileInde
x++; | 1528 tileInde
x++; |
1525 } | 1529 } |
1526 tileIndex += til
eLineAdvance; | 1530 tileIndex += til
eLineAdvance; |
1527 } | 1531 } |
1528 } else { /* if (t
ccp->qmfbid == 0) */ | 1532 } else { /* if (t
ccp->qmfbid == 0) */ |
1529 for (j = 0; j < cblk_h;
++j) { | 1533 for (j = 0; j < cblk_h;
++j) { |
1530 for (i = 0; i <
cblk_w; ++i) { | 1534 for (i = 0; i <
cblk_w; ++i) { |
1531 OPJ_INT3
2 tmp = tiledp[tileIndex]; | 1535 OPJ_INT3
2 tmp = tiledp[tileIndex]; |
1532 tiledp[t
ileIndex] = | 1536 tiledp[t
ileIndex] = |
1533 » » » » » » » » » »
opj_int_fix_mul( | 1537 » » » » » » » » » »
opj_int_fix_mul_t1( |
1534
tmp, | 1538
tmp, |
1535 » » » » » » » » » »
bandconst) >> (11 - T1_NMSEDEC_FRACBITS); | 1539 » » » » » » » » » »
bandconst); |
1536 tileInde
x++; | 1540 tileInde
x++; |
1537 } | 1541 } |
1538 tileIndex += til
eLineAdvance; | 1542 tileIndex += til
eLineAdvance; |
1539 } | 1543 } |
1540 } | 1544 } |
1541 | 1545 |
1542 opj_t1_encode_cblk( | 1546 opj_t1_encode_cblk( |
1543 t1, | 1547 t1, |
1544 cblk, | 1548 cblk, |
1545 band->bandno, | 1549 band->bandno, |
1546 compno, | 1550 compno, |
1547 tilec->numresolu
tions - 1 - resno, | 1551 tilec->numresolu
tions - 1 - resno, |
1548 tccp->qmfbid, | 1552 tccp->qmfbid, |
1549 band->stepsize, | 1553 band->stepsize, |
1550 tccp->cblksty, | 1554 tccp->cblksty, |
1551 tile->numcomps, | 1555 tile->numcomps, |
1552 tile, | 1556 tile, |
1553 » » » » » » » » mct_norms); | 1557 » » » » » » » » mct_norms, |
| 1558 » » » » » » » » mct_numcomps); |
1554 | 1559 |
1555 } /* cblkno */ | 1560 } /* cblkno */ |
1556 } /* precno */ | 1561 } /* precno */ |
1557 } /* bandno */ | 1562 } /* bandno */ |
1558 } /* resno */ | 1563 } /* resno */ |
1559 } /* compno */ | 1564 } /* compno */ |
1560 return OPJ_TRUE; | 1565 return OPJ_TRUE; |
1561 } | 1566 } |
1562 | 1567 |
1563 /** mod fixed_quality */ | 1568 /** mod fixed_quality */ |
1564 void opj_t1_encode_cblk(opj_t1_t *t1, | 1569 void opj_t1_encode_cblk(opj_t1_t *t1, |
1565 opj_tcd_cblk_enc_t* cblk, | 1570 opj_tcd_cblk_enc_t* cblk, |
1566 OPJ_UINT32 orient, | 1571 OPJ_UINT32 orient, |
1567 OPJ_UINT32 compno, | 1572 OPJ_UINT32 compno, |
1568 OPJ_UINT32 level, | 1573 OPJ_UINT32 level, |
1569 OPJ_UINT32 qmfbid, | 1574 OPJ_UINT32 qmfbid, |
1570 OPJ_FLOAT64 stepsize, | 1575 OPJ_FLOAT64 stepsize, |
1571 OPJ_UINT32 cblksty, | 1576 OPJ_UINT32 cblksty, |
1572 OPJ_UINT32 numcomps, | 1577 OPJ_UINT32 numcomps, |
1573 opj_tcd_tile_t * tile, | 1578 opj_tcd_tile_t * tile, |
1574 const OPJ_FLOAT64 * mct_norms) | 1579 const OPJ_FLOAT64 * mct_norms, |
| 1580 OPJ_UINT32 mct_numcomps) |
1575 { | 1581 { |
1576 OPJ_FLOAT64 cumwmsedec = 0.0; | 1582 OPJ_FLOAT64 cumwmsedec = 0.0; |
1577 | 1583 |
1578 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 1584 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
1579 | 1585 |
1580 OPJ_UINT32 passno; | 1586 OPJ_UINT32 passno; |
1581 OPJ_INT32 bpno; | 1587 OPJ_INT32 bpno; |
1582 OPJ_UINT32 passtype; | 1588 OPJ_UINT32 passtype; |
1583 OPJ_INT32 nmsedec = 0; | 1589 OPJ_INT32 nmsedec = 0; |
1584 OPJ_INT32 max; | 1590 OPJ_INT32 max; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 break; | 1625 break; |
1620 case 2: | 1626 case 2: |
1621 opj_t1_enc_clnpass(t1, bpno, orient, &nmsedec, c
blksty); | 1627 opj_t1_enc_clnpass(t1, bpno, orient, &nmsedec, c
blksty); |
1622 /* code switch SEGMARK (i.e. SEGSYM) */ | 1628 /* code switch SEGMARK (i.e. SEGSYM) */ |
1623 if (cblksty & J2K_CCP_CBLKSTY_SEGSYM) | 1629 if (cblksty & J2K_CCP_CBLKSTY_SEGSYM) |
1624 opj_mqc_segmark_enc(mqc); | 1630 opj_mqc_segmark_enc(mqc); |
1625 break; | 1631 break; |
1626 } | 1632 } |
1627 | 1633 |
1628 /* fixed_quality */ | 1634 /* fixed_quality */ |
1629 » » tempwmsedec = opj_t1_getwmsedec(nmsedec, compno, level, orient,
bpno, qmfbid, stepsize, numcomps,mct_norms) ; | 1635 » » tempwmsedec = opj_t1_getwmsedec(nmsedec, compno, level, orient,
bpno, qmfbid, stepsize, numcomps,mct_norms, mct_numcomps) ; |
1630 cumwmsedec += tempwmsedec; | 1636 cumwmsedec += tempwmsedec; |
1631 tile->distotile += tempwmsedec; | 1637 tile->distotile += tempwmsedec; |
1632 | 1638 |
1633 /* Code switch "RESTART" (i.e. TERMALL) */ | 1639 /* Code switch "RESTART" (i.e. TERMALL) */ |
1634 if ((cblksty & J2K_CCP_CBLKSTY_TERMALL) && !((passtype == 2) &&
(bpno - 1 < 0))) { | 1640 if ((cblksty & J2K_CCP_CBLKSTY_TERMALL) && !((passtype == 2) &&
(bpno - 1 < 0))) { |
1635 if (type == T1_TYPE_RAW) { | 1641 if (type == T1_TYPE_RAW) { |
1636 opj_mqc_flush(mqc); | 1642 opj_mqc_flush(mqc); |
1637 correction = 1; | 1643 correction = 1; |
1638 /* correction = mqc_bypass_flush_enc(); */ | 1644 /* correction = mqc_bypass_flush_enc(); */ |
1639 } else { /* correction = mqc_rest
art_enc(); */ | 1645 } else { /* correction = mqc_rest
art_enc(); */ |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag))
; | 1765 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag))
; |
1760 v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag); | 1766 v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag); |
1761 *datap = v ? -oneplushalf : oneplushalf; | 1767 *datap = v ? -oneplushalf : oneplushalf; |
1762 opj_t1_updateflags(flagsp, v, t1->flags_stride); | 1768 opj_t1_updateflags(flagsp, v, t1->flags_stride); |
1763 } | 1769 } |
1764 } | 1770 } |
1765 *flagsp |= T1_VISIT; | 1771 *flagsp |= T1_VISIT; |
1766 } | 1772 } |
1767 } /* VSC and BYPASS by Antonin */ | 1773 } /* VSC and BYPASS by Antonin */ |
1768 #endif | 1774 #endif |
OLD | NEW |