mirror of https://git.ffmpeg.org/ffmpeg.git
Merge commit 'd445c865f87e7f13230e4dac3f77f5af21da95cb'
* commit 'd445c865f87e7f13230e4dac3f77f5af21da95cb': fft-test: Reduce variable scope where sensibly possible Conflicts: libavcodec/fft-test.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
09f5b3750f
|
@ -69,16 +69,13 @@ static struct {
|
|||
|
||||
static void fft_ref_init(int nbits, int inverse)
|
||||
{
|
||||
int n, i;
|
||||
double c1, s1, alpha;
|
||||
int i, n = 1 << nbits;
|
||||
|
||||
n = 1 << nbits;
|
||||
exptab = av_malloc_array((n / 2), sizeof(*exptab));
|
||||
|
||||
for (i = 0; i < (n/2); i++) {
|
||||
alpha = 2 * M_PI * (float)i / (float)n;
|
||||
c1 = cos(alpha);
|
||||
s1 = sin(alpha);
|
||||
double alpha = 2 * M_PI * (float)i / (float)n;
|
||||
double c1 = cos(alpha), s1 = sin(alpha);
|
||||
if (!inverse)
|
||||
s1 = -s1;
|
||||
exptab[i].re = c1;
|
||||
|
@ -88,18 +85,16 @@ static void fft_ref_init(int nbits, int inverse)
|
|||
|
||||
static void fft_ref(FFTComplex *tabr, FFTComplex *tab, int nbits)
|
||||
{
|
||||
int n, i, j, k, n2;
|
||||
double tmp_re, tmp_im, s, c;
|
||||
FFTComplex *q;
|
||||
int i, j;
|
||||
int n = 1 << nbits;
|
||||
int n2 = n >> 1;
|
||||
|
||||
n = 1 << nbits;
|
||||
n2 = n >> 1;
|
||||
for (i = 0; i < n; i++) {
|
||||
tmp_re = 0;
|
||||
tmp_im = 0;
|
||||
q = tab;
|
||||
double tmp_re = 0, tmp_im = 0;
|
||||
FFTComplex *q = tab;
|
||||
for (j = 0; j < n; j++) {
|
||||
k = (i * j) & (n - 1);
|
||||
double s, c;
|
||||
int k = (i * j) & (n - 1);
|
||||
if (k >= n2) {
|
||||
c = -exptab[k - n2].re;
|
||||
s = -exptab[k - n2].im;
|
||||
|
@ -118,15 +113,13 @@ static void fft_ref(FFTComplex *tabr, FFTComplex *tab, int nbits)
|
|||
#if CONFIG_MDCT
|
||||
static void imdct_ref(FFTSample *out, FFTSample *in, int nbits)
|
||||
{
|
||||
int n = 1<<nbits;
|
||||
int k, i, a;
|
||||
double sum, f;
|
||||
int i, k, n = 1 << nbits;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
sum = 0;
|
||||
double sum = 0;
|
||||
for (k = 0; k < n/2; k++) {
|
||||
a = (2 * i + 1 + (n / 2)) * (2 * k + 1);
|
||||
f = cos(M_PI * a / (double)(2 * n));
|
||||
int a = (2 * i + 1 + (n / 2)) * (2 * k + 1);
|
||||
double f = cos(M_PI * a / (double)(2 * n));
|
||||
sum += f * in[k];
|
||||
}
|
||||
out[i] = REF_SCALE(-sum, nbits - 2);
|
||||
|
@ -136,15 +129,13 @@ static void imdct_ref(FFTSample *out, FFTSample *in, int nbits)
|
|||
/* NOTE: no normalisation by 1 / N is done */
|
||||
static void mdct_ref(FFTSample *output, FFTSample *input, int nbits)
|
||||
{
|
||||
int n = 1<<nbits;
|
||||
int k, i;
|
||||
double a, s;
|
||||
int i, k, n = 1 << nbits;
|
||||
|
||||
/* do it by hand */
|
||||
for (k = 0; k < n/2; k++) {
|
||||
s = 0;
|
||||
double s = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
a = (2*M_PI*(2*i+1+n/2)*(2*k+1) / (4 * n));
|
||||
double a = (2 * M_PI * (2 * i + 1 + n / 2) * (2 * k + 1) / (4 * n));
|
||||
s += input[i] * cos(a);
|
||||
}
|
||||
output[k] = REF_SCALE(s, nbits - 1);
|
||||
|
@ -156,15 +147,13 @@ static void mdct_ref(FFTSample *output, FFTSample *input, int nbits)
|
|||
#if CONFIG_DCT
|
||||
static void idct_ref(FFTSample *output, FFTSample *input, int nbits)
|
||||
{
|
||||
int n = 1<<nbits;
|
||||
int k, i;
|
||||
double a, s;
|
||||
int i, k, n = 1 << nbits;
|
||||
|
||||
/* do it by hand */
|
||||
for (i = 0; i < n; i++) {
|
||||
s = 0.5 * input[0];
|
||||
double s = 0.5 * input[0];
|
||||
for (k = 1; k < n; k++) {
|
||||
a = M_PI*k*(i+0.5) / n;
|
||||
double a = M_PI * k * (i + 0.5) / n;
|
||||
s += input[k] * cos(a);
|
||||
}
|
||||
output[i] = 2 * s / n;
|
||||
|
@ -172,15 +161,13 @@ static void idct_ref(FFTSample *output, FFTSample *input, int nbits)
|
|||
}
|
||||
static void dct_ref(FFTSample *output, FFTSample *input, int nbits)
|
||||
{
|
||||
int n = 1<<nbits;
|
||||
int k, i;
|
||||
double a, s;
|
||||
int i, k, n = 1 << nbits;
|
||||
|
||||
/* do it by hand */
|
||||
for (k = 0; k < n; k++) {
|
||||
s = 0;
|
||||
double s = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
a = M_PI*k*(i+0.5) / n;
|
||||
double a = M_PI * k * (i + 0.5) / n;
|
||||
s += input[i] * cos(a);
|
||||
}
|
||||
output[k] = s;
|
||||
|
@ -197,10 +184,8 @@ static FFTSample frandom(AVLFG *prng)
|
|||
|
||||
static int check_diff(FFTSample *tab1, FFTSample *tab2, int n, double scale)
|
||||
{
|
||||
int i;
|
||||
double max= 0;
|
||||
double error= 0;
|
||||
int err = 0;
|
||||
int i, err = 0;
|
||||
double error = 0, max = 0;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
double e = fabsf(tab1[i] - (tab2[i] / scale)) / RANGE;
|
||||
|
@ -246,27 +231,23 @@ int main(int argc, char **argv)
|
|||
{
|
||||
FFTComplex *tab, *tab1, *tab_ref;
|
||||
FFTSample *tab2;
|
||||
int it, i, c;
|
||||
int cpuflags;
|
||||
int do_speed = 0;
|
||||
int err = 1;
|
||||
enum tf_transform transform = TRANSFORM_FFT;
|
||||
int do_inverse = 0;
|
||||
FFTContext s1, *s = &s1;
|
||||
FFTContext m1, *m = &m1;
|
||||
#if FFT_FLOAT
|
||||
RDFTContext r1, *r = &r1;
|
||||
DCTContext d1, *d = &d1;
|
||||
int fft_size_2;
|
||||
#endif /* FFT_FLOAT */
|
||||
int fft_nbits, fft_size;
|
||||
int it, i, err = 1;
|
||||
int do_speed = 0, do_inverse = 0;
|
||||
int fft_nbits = 9, fft_size;
|
||||
double scale = 1.0;
|
||||
AVLFG prng;
|
||||
|
||||
av_lfg_init(&prng, 1);
|
||||
|
||||
fft_nbits = 9;
|
||||
for(;;) {
|
||||
c = getopt(argc, argv, "hsimrdn:f:c:");
|
||||
int c = getopt(argc, argv, "hsimrdn:f:c:");
|
||||
if (c == -1)
|
||||
break;
|
||||
switch(c) {
|
||||
|
@ -295,7 +276,8 @@ int main(int argc, char **argv)
|
|||
scale = atof(optarg);
|
||||
break;
|
||||
case 'c':
|
||||
cpuflags = av_get_cpu_flags();
|
||||
{
|
||||
int cpuflags = av_get_cpu_flags();
|
||||
|
||||
if (av_parse_cpu_caps(&cpuflags, optarg) < 0)
|
||||
return 1;
|
||||
|
@ -304,6 +286,7 @@ int main(int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fft_size = 1 << fft_nbits;
|
||||
tab = av_malloc_array(fft_size, sizeof(FFTComplex));
|
||||
|
@ -394,7 +377,8 @@ int main(int argc, char **argv)
|
|||
#if FFT_FLOAT
|
||||
#if CONFIG_RDFT
|
||||
case TRANSFORM_RDFT:
|
||||
fft_size_2 = fft_size >> 1;
|
||||
{
|
||||
int fft_size_2 = fft_size >> 1;
|
||||
if (do_inverse) {
|
||||
tab1[ 0].im = 0;
|
||||
tab1[fft_size_2].im = 0;
|
||||
|
@ -424,6 +408,7 @@ int main(int argc, char **argv)
|
|||
err = check_diff((float *)tab_ref, (float *)tab2, fft_size, 1.0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_RDFT */
|
||||
#if CONFIG_DCT
|
||||
case TRANSFORM_DCT:
|
||||
|
|
Loading…
Reference in New Issue