- if (band->bandno == 0) {
- x = cblk->x0 - band->x0;
- y = cblk->y0 - band->y0;
- } else if (band->bandno == 1) {
- opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
- x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
- y = cblk->y0 - band->y0;
- } else if (band->bandno == 2) {
- opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
- x = cblk->x0 - band->x0;
- y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
- } else { /* if (band->bandno == 3) */
- opj_tcd_resolution_t *pres = &tilec->resolutions[resno - 1];
- x = pres->x1 - pres->x0 + cblk->x0 - band->x0;
- y = pres->y1 - pres->y0 + cblk->y0 - band->y0;
- }
-
- if (tcp->tccps[compno].roishift) {
- int thresh, val, mag;
- thresh = 1 << tcp->tccps[compno].roishift;
- for (j = 0; j < cblk->y1 - cblk->y0; j++) {
- for (i = 0; i < cblk->x1 - cblk->x0; i++) {
- val = t1->data[j][i];
- mag = int_abs(val);
- if (mag >= thresh) {
- mag >>= tcp->tccps[compno].roishift;
- t1->data[j][i] = val < 0 ? -mag : mag;
- }
+ t1_decode_cblk(
+ t1,
+ cblk,
+ band->bandno,
+ tccp->roishift,
+ tccp->cblksty);
+
+ x = cblk->x0 - band->x0;
+ y = cblk->y0 - band->y0;
+ if (band->bandno & 1) {
+ opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
+ x += pres->x1 - pres->x0;
+ }
+ if (band->bandno & 2) {
+ opj_tcd_resolution_t* pres = &tilec->resolutions[resno - 1];
+ y += pres->y1 - pres->y0;
+ }
+
+ datap=t1->data;
+ cblk_w = t1->w;
+ cblk_h = t1->h;
+
+ if (tccp->roishift) {
+ OPJ_INT32 thresh = 1 << tccp->roishift;
+ for (j = 0; j < cblk_h; ++j) {
+ for (i = 0; i < cblk_w; ++i) {
+ OPJ_INT32 val = datap[(j * cblk_w) + i];
+ OPJ_INT32 mag = abs(val);
+ if (mag >= thresh) {
+ mag >>= tccp->roishift;
+ datap[(j * cblk_w) + i] = val < 0 ? -mag : mag;