static void jpc_qmfb1d_setup(jpc_fix_t *startptr, int startind, int endind, int intrastep, jpc_fix_t **lstartptr, int *lstartind, int *lendind, jpc_fix_t **hstartptr, int *hstartind, int *hendind) { *lstartind = JPC_CEILDIVPOW2(startind, 1); *lendind = JPC_CEILDIVPOW2(endind, 1); *hstartind = JPC_FLOORDIVPOW2(startind, 1); *hendind = JPC_FLOORDIVPOW2(endind, 1); *lstartptr = startptr; *hstartptr = &startptr[(*lendind - *lstartind) * intrastep]; }
int jpc_tsfb_analyze2(jpc_tsfb_t *tsfb, int *a, int xstart, int ystart, int width, int height, int stride, int numlvls) { if (width > 0 && height > 0) { if ((*tsfb->qmfb->analyze)(a, xstart, ystart, width, height, stride)) return -1; if (numlvls > 0) { if (jpc_tsfb_analyze2(tsfb, a, JPC_CEILDIVPOW2(xstart, 1), JPC_CEILDIVPOW2(ystart, 1), JPC_CEILDIVPOW2( xstart + width, 1) - JPC_CEILDIVPOW2(xstart, 1), JPC_CEILDIVPOW2(ystart + height, 1) - JPC_CEILDIVPOW2(ystart, 1), stride, numlvls - 1)) { return -1; } } } return 0; }
int jpc_tsfb_synthesize2(jpc_tsfb_t *tsfb, int_fast32_t *a, int_fast32_t xstart, int_fast32_t ystart, int_fast32_t width, int_fast32_t height, int_fast32_t stride, int numlvls) { if (numlvls > 0) { if (jpc_tsfb_synthesize2(tsfb, a, JPC_CEILDIVPOW2(xstart, 1), JPC_CEILDIVPOW2(ystart, 1), JPC_CEILDIVPOW2(xstart + width, 1) - JPC_CEILDIVPOW2(xstart, 1), JPC_CEILDIVPOW2(ystart + height, 1) - JPC_CEILDIVPOW2(ystart, 1), stride, numlvls - 1)) { return -1; } } if (width > 0 && height > 0) { if ((*tsfb->qmfb->synthesize)(a, xstart, ystart, width, height, stride)) { return -1; } } return 0; }
static void jpc_qmfb1d_split(jpc_fix_t *startptr, int startind, int endind, register int step, jpc_fix_t *lstartptr, int lstartind, int lendind, jpc_fix_t *hstartptr, int hstartind, int hendind) { int bufsize = JPC_CEILDIVPOW2(endind - startind, 2); #if !defined(HAVE_VLA) #define QMFB_SPLITBUFSIZE 4096 jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE]; #else jpc_fix_t splitbuf[bufsize]; #endif jpc_fix_t *buf = splitbuf; int llen; int hlen; int twostep; jpc_fix_t *tmpptr; register jpc_fix_t *ptr; register jpc_fix_t *hptr; register jpc_fix_t *lptr; register int n; int state; twostep = step << 1; llen = lendind - lstartind; hlen = hendind - hstartind; #if !defined(HAVE_VLA) /* Get a buffer. */ if (bufsize > QMFB_SPLITBUFSIZE) { if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) { /* We have no choice but to commit suicide in this case. */ abort(); } } #endif if (hstartind < lstartind) { /* The first sample in the input signal is to appear in the highpass subband signal. */ /* Copy the appropriate samples into the lowpass subband signal, saving any samples destined for the highpass subband signal as they are overwritten. */ tmpptr = buf; ptr = &startptr[step]; lptr = lstartptr; n = llen; state = 1; while (n-- > 0) { if (state) { *tmpptr = *lptr; ++tmpptr; } *lptr = *ptr; ptr += twostep; lptr += step; state ^= 1; } /* Copy the appropriate samples into the highpass subband signal. */ /* Handle the nonoverwritten samples. */ hptr = &hstartptr[(hlen - 1) * step]; ptr = &startptr[(((llen + hlen - 1) >> 1) << 1) * step]; n = hlen - (tmpptr - buf); while (n-- > 0) { *hptr = *ptr; hptr -= step; ptr -= twostep; } /* Handle the overwritten samples. */ n = tmpptr - buf; while (n-- > 0) { --tmpptr; *hptr = *tmpptr; hptr -= step; } } else {
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); } }