/************************************************************************************** * Function: DCT4 * * Description: type-IV DCT * * Inputs: table index (for transform size) * buffer of nmdct samples * number of guard bits in the input buffer * * Outputs: processed samples in same buffer * * Return: none * * Notes: operates in-place * if number of guard bits in input is < GBITS_IN_DCT4, the input is * scaled (>>) before the DCT4 and rescaled (<<, with clipping) after * the DCT4 (rare) * the output has FBITS_LOST_DCT4 fewer fraction bits than the input * the output will always have at least 1 guard bit (GBITS_IN_DCT4 >= 4) * int bits gained per stage (PreMul + FFT + PostMul) * short blocks = (-5 + 4 + 2) = 1 total * long blocks = (-8 + 7 + 2) = 1 total **************************************************************************************/ void DCT4(int tabidx, int *coef, int gb) { int es; /* fast in-place DCT-IV - adds guard bits if necessary */ if (gb < GBITS_IN_DCT4) { es = GBITS_IN_DCT4 - gb; PreMultiplyRescale(tabidx, coef, es); R4FFT(tabidx, coef); PostMultiplyRescale(tabidx, coef, es); } else { PreMultiply(tabidx, coef); R4FFT(tabidx, coef); PostMultiply(tabidx, coef); } }
/************************************************************************************** * Function: IMLTNoWindow * * Description: inverse MLT without window or overlap-add * * Inputs: table index (for transform size) * buffer of nmlt samples * number of guard bits in the input buffer * * Outputs: processed samples in same buffer * * Return: none * * Notes: operates in-place, and generates nmlt output samples from nmlt input * samples (doesn't do synthesis window which expands to 2*nmlt samples) * if number of guard bits in input is < GBITS_IN_IMLT, the input is * scaled (>>) before the IMLT and rescaled (<<, with clipping) after * the IMLT (rare) * the output has FBITS_LOST_IMLT fewer fraction bits than the input * the output will always have at least 1 guard bit **************************************************************************************/ void IMLTNoWindow(int tabidx, int *mlt, int gb) { int es; /* fast in-place DCT-IV - adds guard bits if necessary */ if (gb < GBITS_IN_IMLT) { es = GBITS_IN_IMLT - gb; PreMultiplyRescale(tabidx, mlt, es); R4FFT(tabidx, mlt); PostMultiplyRescale(tabidx, mlt, es); } else { PreMultiply(tabidx, mlt); R4FFT(tabidx, mlt); PostMultiply(tabidx, mlt); } return; }
void doit(int iter, struct problem *p) { bench_complex *in = p->in; int isig = p->sign; int i; if (p->kind == PROBLEM_COMPLEX) { switch (p->rank) { case 2: for (i = 0; i < iter; ++i) C2FFT(in, &ldn1, &n1, &n2, w1, w2, &isig, &iord, iwork, &ierr); break; case 3: for (i = 0; i < iter; ++i) C3FFT(in, &ldn1, &n1, &n2, &n3, w1, w2, w3, &iopt, &isig, &iord, iwork, &ierr); break; case 4: for (i = 0; i < iter; ++i) C4FFT(in, &ldn1, &n2, &n1, &n2, &n3, &n4, w1, w2, w3, w4, &isig, &iord, iwork, &ierr); break; } } else /* PROBLEM_REAL */ { switch (p->rank) { case 2: for (i = 0; i < iter; ++i) R2FFT(in, &ldn1, &n1, &n2, w1, w2, &isig, &iord, iwork, &ierr); break; case 3: for (i = 0; i < iter; ++i) R3FFT(in, &ldn1, &n1, &n2, &n3, w1, w2, w3, &iopt, &isig, &iord, iwork, &ierr); break; case 4: for (i = 0; i < iter; ++i) R4FFT(in, &ldn1, &n2, &n1, &n2, &n3, &n4, w1, w2, w3, w4, &isig, &iord, iwork, &ierr); break; } } }
void setup(struct problem *p) { int isig = 0; /* indicates initialization call */ BENCH_ASSERT(can_do(p)); switch (p->rank) { case 2: n2 = p->n[0]; n1 = p->n[1]; break; case 3: n3 = p->n[0]; n2 = p->n[1]; n1 = p->n[2]; break; case 4: n4 = p->n[0]; n3 = p->n[1]; n2 = p->n[2]; n1 = p->n[3]; break; } if (p->kind == PROBLEM_COMPLEX) ldn1 = n1; else ldn1 = n1 + 2; w1 = (int *) bench_malloc(sizeof(int) * ((p->kind == PROBLEM_REAL ? 6 : 4) * n1 + 14)); if (iopt == 1 && p->rank == 3) w2 = (int *) bench_malloc(sizeof(int) * (4*n2*(n1+1) + 14)); else w2 = (int *) bench_malloc(sizeof(int) * (4*n2 + 14)); w3 = (int *) bench_malloc(sizeof(int) * (4*n3 + 14)); w4 = (int *) bench_malloc(sizeof(int) * (4*n4 + 14)); iwork = (int *) bench_malloc(sizeof(int) * MAX2(n1,MAX2(n2,MAX2(n3,n4)))); if (p->kind == PROBLEM_COMPLEX) { switch (p->rank) { case 2: C2FFT((bench_complex*) p->in, &ldn1, &n1, &n2, w1, w2, &isig, &iord, iwork, &ierr); break; case 3: C3FFT((bench_complex*) p->in, &ldn1, &n1, &n2, &n3, w1, w2, w3, &iopt, &isig, &iord, iwork, &ierr); break; case 4: C4FFT((bench_complex*) p->in, &ldn1, &n2, &n1, &n2, &n3, &n4, w1, w2, w3, w4, &isig, &iord, iwork, &ierr); break; } } else /* PROBLEM_REAL */ { switch (p->rank) { case 2: R2FFT((bench_complex*) p->in, &ldn1, &n1, &n2, w1, w2, &isig, &iord, iwork, &ierr); break; case 3: R3FFT((bench_complex*) p->in, &ldn1, &n1, &n2, &n3, w1, w2, w3, &iopt, &isig, &iord, iwork, &ierr); break; case 4: R4FFT((bench_complex*) p->in, &ldn1, &n2, &n1, &n2, &n3, &n4, w1, w2, w3, w4, &isig, &iord, iwork, &ierr); break; } } BENCH_ASSERT(ierr == 0); }