/* ----------------------------------------------------------------------- */
-void t1_encode_cblks(
- opj_t1_t *t1,
- opj_tcd_tile_t *tile,
- opj_tcp_t *tcp)
-{
- int compno, resno, bandno, precno, cblkno;
-
- tile->distotile = 0; /* fixed_quality */
-
- for (compno = 0; compno < tile->numcomps; ++compno) {
- opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
- opj_tccp_t* tccp = &tcp->tccps[compno];
- int tile_w = tilec->x1 - tilec->x0;
-
- for (resno = 0; resno < tilec->numresolutions; ++resno) {
- opj_tcd_resolution_t *res = &tilec->resolutions[resno];
-
- for (bandno = 0; bandno < res->numbands; ++bandno) {
- opj_tcd_band_t* restrict band = &res->bands[bandno];
- int bandconst = 8192 * 8192 / ((int) floor(band->stepsize * 8192));
-
- for (precno = 0; precno < res->pw * res->ph; ++precno) {
- opj_tcd_precinct_t *prc = &band->precincts[precno];
-
- for (cblkno = 0; cblkno < prc->cw * prc->ch; ++cblkno) {
- opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
- int* restrict datap;
- int* restrict tiledp;
- int cblk_w;
- int cblk_h;
- int i, j;
-
- int x = cblk->x0 - band->x0;
- int 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;
- }
-
- if(!opj_t1_allocate_buffers(
- t1,
- cblk->x1 - cblk->x0,
- cblk->y1 - cblk->y0))
- {
- return;
- }
-
- datap=t1->data;
- cblk_w = t1->w;
- cblk_h = t1->h;
-
- tiledp=&tilec->data[(y * tile_w) + x];
- if (tccp->qmfbid == 1) {
- for (j = 0; j < cblk_h; ++j) {
- for (i = 0; i < cblk_w; ++i) {
- int tmp = tiledp[(j * tile_w) + i];
- datap[(j * cblk_w) + i] = tmp << T1_NMSEDEC_FRACBITS;
- }
- }
- } else { /* if (tccp->qmfbid == 0) */
- for (j = 0; j < cblk_h; ++j) {
- for (i = 0; i < cblk_w; ++i) {
- int tmp = tiledp[(j * tile_w) + i];
- datap[(j * cblk_w) + i] =
- fix_mul(
- tmp,
- bandconst) >> (11 - T1_NMSEDEC_FRACBITS);
- }
- }
- }
-
- t1_encode_cblk(
- t1,
- cblk,
- band->bandno,
- compno,
- tilec->numresolutions - 1 - resno,
- tccp->qmfbid,
- band->stepsize,
- tccp->cblksty,
- tile->numcomps,
- tcp->mct,
- tile);
-
- } /* cblkno */
- } /* precno */
- } /* bandno */
- } /* resno */
- } /* compno */
-}
-
-
-
-
/* ----------------------------------------------------------------------- */
/**
* Creates a new Tier 1 handle