void jpc_initluts() { int i; int orient; int refine; float u; float v; float t; /* XXX - hack */ jpc_initmqctxs(); for (orient = 0; orient < 4; ++orient) { for (i = 0; i < 256; ++i) { jpc_zcctxnolut[(orient << 8) | i] = jpc_getzcctxno(i, orient); } } for (i = 0; i < 256; ++i) { jpc_spblut[i] = jpc_getspb(i << 4); } for (i = 0; i < 256; ++i) { jpc_scctxnolut[i] = jpc_getscctxno(i << 4); } for (refine = 0; refine < 2; ++refine) { for (i = 0; i < 2048; ++i) { jpc_magctxnolut[(refine << 11) + i] = jpc_getmagctxno((refine ? JPC_REFINE : 0) | i); } } for (i = 0; i < (1 << JPC_NMSEDEC_BITS); ++i) { t = i * jpc_pow2i(-JPC_NMSEDEC_FRACBITS); u = t; v = t - 1.5; jpc_signmsedec[i] = jpc_dbltofix(floor((u * u - v * v) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); /* XXX - this calc is not correct */ jpc_signmsedec0[i] = jpc_dbltofix(floor((u * u) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); u = t - 1.0; if (i & (1 << (JPC_NMSEDEC_BITS - 1))) { v = t - 1.5; } else { v = t - 0.5; } jpc_refnmsedec[i] = jpc_dbltofix(floor((u * u - v * v) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); /* XXX - this calc is not correct */ jpc_refnmsedec0[i] = jpc_dbltofix(floor((u * u) * jpc_pow2i(JPC_NMSEDEC_FRACBITS) + 0.5) / jpc_pow2i(JPC_NMSEDEC_FRACBITS)); } }
jpc_fix_t jpc_seq_norm(jas_seq_t *x) { jpc_fix_t s; int i; s = jpc_inttofix(0); for (i = jas_seq_start(x); i < jas_seq_end(x); i++) { s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(x, i), jas_seq_get(x, i))); } return jpc_dbltofix(sqrt(jpc_fixtodbl(s))); }
void jpc_tsfb_getbands2(jpc_tsfb_t *tsfb, int locxstart, int locystart, int xstart, int ystart, int xend, int yend, jpc_tsfb_band_t **bands, int numlvls) { int newxstart; int newystart; int newxend; int newyend; jpc_tsfb_band_t *band; newxstart = JPC_CEILDIVPOW2(xstart, 1); newystart = JPC_CEILDIVPOW2(ystart, 1); newxend = JPC_CEILDIVPOW2(xend, 1); newyend = JPC_CEILDIVPOW2(yend, 1); if (numlvls > 0) { jpc_tsfb_getbands2(tsfb, locxstart, locystart, newxstart, newystart, newxend, newyend, bands, numlvls - 1); band = *bands; band->xstart = JPC_FLOORDIVPOW2(xstart, 1); band->ystart = newystart; band->xend = JPC_FLOORDIVPOW2(xend, 1); band->yend = newyend; band->locxstart = locxstart + newxend - newxstart; band->locystart = locystart; band->locxend = band->locxstart + band->xend - band->xstart; band->locyend = band->locystart + band->yend - band->ystart; band->orient = JPC_TSFB_HL; band->synenergywt = jpc_dbltofix(tsfb->qmfb->hpenergywts[ tsfb->numlvls - numlvls] * tsfb->qmfb->lpenergywts[ tsfb->numlvls - numlvls]); ++(*bands); band = *bands; band->xstart = newxstart; band->ystart = JPC_FLOORDIVPOW2(ystart, 1); band->xend = newxend; band->yend = JPC_FLOORDIVPOW2(yend, 1); band->locxstart = locxstart; band->locystart = locystart + newyend - newystart; band->locxend = band->locxstart + band->xend - band->xstart; band->locyend = band->locystart + band->yend - band->ystart; band->orient = JPC_TSFB_LH; band->synenergywt = jpc_dbltofix(tsfb->qmfb->lpenergywts[ tsfb->numlvls - numlvls] * tsfb->qmfb->hpenergywts[ tsfb->numlvls - numlvls]); ++(*bands); band = *bands; band->xstart = JPC_FLOORDIVPOW2(xstart, 1); band->ystart = JPC_FLOORDIVPOW2(ystart, 1); band->xend = JPC_FLOORDIVPOW2(xend, 1); band->yend = JPC_FLOORDIVPOW2(yend, 1); band->locxstart = locxstart + newxend - newxstart; band->locystart = locystart + newyend - newystart; band->locxend = band->locxstart + band->xend - band->xstart; band->locyend = band->locystart + band->yend - band->ystart; band->orient = JPC_TSFB_HH; band->synenergywt = jpc_dbltofix(tsfb->qmfb->hpenergywts[ tsfb->numlvls - numlvls] * tsfb->qmfb->hpenergywts[ tsfb->numlvls - numlvls]); ++(*bands); } else { band = *bands; band->xstart = xstart; band->ystart = ystart; band->xend = xend; band->yend = yend; band->locxstart = locxstart; band->locystart = locystart; band->locxend = band->locxstart + band->xend - band->xstart; band->locyend = band->locystart + band->yend - band->ystart; band->orient = JPC_TSFB_LL; band->synenergywt = jpc_dbltofix(tsfb->qmfb->lpenergywts[ tsfb->numlvls - numlvls - 1] * tsfb->qmfb->lpenergywts[ tsfb->numlvls - numlvls - 1]); ++(*bands); } }