jas_seq_t *jpc_seq_conv(jas_seq_t *x, jas_seq_t *y) { int i; int j; int k; jas_seq_t *z; jpc_fix_t s; jpc_fix_t v; z = jas_seq_create(jas_seq_start(x) + jas_seq_start(y), jas_seq_end(x) + jas_seq_end(y) - 1); assert(z); for (i = jas_seq_start(z); i < jas_seq_end(z); i++) { s = jpc_inttofix(0); for (j = jas_seq_start(y); j < jas_seq_end(y); j++) { k = i - j; if (k < jas_seq_start(x) || k >= jas_seq_end(x)) { v = JPC_FIX_ZERO; } else { v = jas_seq_get(x, k); } s = jpc_fix_add(s, jpc_fix_mul(jas_seq_get(y, j), v)); } *jas_seq_getref(z, i) = s; } return z; }
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))); }
static void jpc_tsfbnode_getbandstree(jpc_tsfbnode_t *node, uint_fast32_t posxstart, uint_fast32_t posystart, uint_fast32_t xstart, uint_fast32_t ystart, uint_fast32_t xend, uint_fast32_t yend, jpc_tsfb_band_t **bands) { jpc_tsfbnodeband_t nodebands[JPC_TSFB_MAXBANDSPERNODE]; jpc_tsfbnodeband_t *nodeband; int nodebandno; int numnodebands; jpc_tsfb_band_t *band; jas_seq_t *hfilter; jas_seq_t *vfilter; qmfb2d_getbands(node->hqmfb, node->vqmfb, xstart, ystart, xend, yend, JPC_TSFB_MAXBANDSPERNODE, &numnodebands, nodebands); if (node->numchildren > 0) { for (nodebandno = 0, nodeband = nodebands; nodebandno < numnodebands; ++nodebandno, ++nodeband) { if (node->children[nodebandno]) { jpc_tsfbnode_getbandstree(node->children[ nodebandno], posxstart + nodeband->locxstart - xstart, posystart + nodeband->locystart - ystart, nodeband->xstart, nodeband->ystart, nodeband->xend, nodeband->yend, bands); } } } assert(numnodebands == 4 || numnodebands == 3); for (nodebandno = 0, nodeband = nodebands; nodebandno < numnodebands; ++nodebandno, ++nodeband) { if (!node->children[nodebandno]) { band = *bands; band->xstart = nodeband->xstart; band->ystart = nodeband->ystart; band->xend = nodeband->xend; band->yend = nodeband->yend; band->locxstart = posxstart + nodeband->locxstart - xstart; band->locystart = posystart + nodeband->locystart - ystart; band->locxend = band->locxstart + band->xend - band->xstart; band->locyend = band->locystart + band->yend - band->ystart; if (numnodebands == 4) { switch (nodebandno) { case 0: band->orient = JPC_TSFB_LL; break; case 1: band->orient = JPC_TSFB_HL; break; case 2: band->orient = JPC_TSFB_LH; break; case 3: band->orient = JPC_TSFB_HH; break; default: abort(); break; } } else { switch (nodebandno) { case 0: band->orient = JPC_TSFB_HL; break; case 1: band->orient = JPC_TSFB_LH; break; case 2: band->orient = JPC_TSFB_HH; break; default: abort(); break; } } jpc_tsfbnode_getequivfilters(node, nodebandno, band->xend - band->xstart, band->yend - band->ystart, &hfilter, &vfilter); band->synenergywt = jpc_fix_mul(jpc_seq_norm(hfilter), jpc_seq_norm(vfilter)); jas_seq_destroy(hfilter); jas_seq_destroy(vfilter); ++(*bands); } } }