Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
6133d658
Commit
6133d658
authored
Jul 18, 2014
by
Diego Biurrun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fft-test: K&R formatting cosmetics
Also rearrange #includes into canonical order.
parent
c3c96deb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
77 deletions
+82
-77
fft-test.c
libavcodec/fft-test.c
+82
-77
No files found.
libavcodec/fft-test.c
View file @
6133d658
...
@@ -23,14 +23,8 @@
...
@@ -23,14 +23,8 @@
* FFT and MDCT tests.
* FFT and MDCT tests.
*/
*/
#include "libavutil/cpu.h"
#include "config.h"
#include "libavutil/mathematics.h"
#include "libavutil/lfg.h"
#include "libavutil/log.h"
#include "libavutil/time.h"
#include "fft.h"
#include "dct.h"
#include "rdft.h"
#include <math.h>
#include <math.h>
#if HAVE_UNISTD_H
#if HAVE_UNISTD_H
#include <unistd.h>
#include <unistd.h>
...
@@ -39,24 +33,34 @@
...
@@ -39,24 +33,34 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include "libavutil/cpu.h"
#include "libavutil/lfg.h"
#include "libavutil/log.h"
#include "libavutil/mathematics.h"
#include "libavutil/time.h"
#include "dct.h"
#include "fft.h"
#include "rdft.h"
/* reference fft */
/* reference fft */
#define MUL16(a,b) ((a) * (b))
#define MUL16(a,
b) ((a) * (b))
#define CMAC(pre, pim, are, aim, bre, bim) \
#define CMAC(pre, pim, are, aim, bre, bim)
\
{
\
{
\
pre += (MUL16(are, bre) - MUL16(aim, bim));
\
pre += (MUL16(are, bre) - MUL16(aim, bim));
\
pim += (MUL16(are, bim) + MUL16(bre, aim));
\
pim += (MUL16(are, bim) + MUL16(bre, aim));
\
}
}
#if FFT_FLOAT
#if FFT_FLOAT
#
define RANGE 1.0
#define RANGE 1.0
#
define REF_SCALE(x, bits) (x)
#define REF_SCALE(x, bits) (x)
#
define FMT "%10.6f"
#define FMT "%10.6f"
#else
#else
#
define RANGE 16384
#define RANGE 16384
#
define REF_SCALE(x, bits) ((x) / (1<<
(bits)))
#
define REF_SCALE(x, bits) ((x) / (1 <<
(bits)))
#
define FMT "%6d"
#define FMT "%6d"
#endif
#endif
static
struct
{
static
struct
{
...
@@ -71,8 +75,8 @@ static int fft_ref_init(int nbits, int inverse)
...
@@ -71,8 +75,8 @@ static int fft_ref_init(int nbits, int inverse)
if
(
!
exptab
)
if
(
!
exptab
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
for
(
i
=
0
;
i
<
(
n
/
2
);
i
++
)
{
for
(
i
=
0
;
i
<
(
n
/
2
);
i
++
)
{
double
alpha
=
2
*
M_PI
*
(
float
)
i
/
(
float
)
n
;
double
alpha
=
2
*
M_PI
*
(
float
)
i
/
(
float
)
n
;
double
c1
=
cos
(
alpha
),
s1
=
sin
(
alpha
);
double
c1
=
cos
(
alpha
),
s1
=
sin
(
alpha
);
if
(
!
inverse
)
if
(
!
inverse
)
s1
=
-
s1
;
s1
=
-
s1
;
...
@@ -116,9 +120,9 @@ static void imdct_ref(FFTSample *out, FFTSample *in, int nbits)
...
@@ -116,9 +120,9 @@ static void imdct_ref(FFTSample *out, FFTSample *in, int nbits)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
double
sum
=
0
;
double
sum
=
0
;
for
(
k
=
0
;
k
<
n
/
2
;
k
++
)
{
for
(
k
=
0
;
k
<
n
/
2
;
k
++
)
{
int
a
=
(
2
*
i
+
1
+
(
n
/
2
))
*
(
2
*
k
+
1
);
int
a
=
(
2
*
i
+
1
+
(
n
/
2
))
*
(
2
*
k
+
1
);
double
f
=
cos
(
M_PI
*
a
/
(
double
)(
2
*
n
));
double
f
=
cos
(
M_PI
*
a
/
(
double
)
(
2
*
n
));
sum
+=
f
*
in
[
k
];
sum
+=
f
*
in
[
k
];
}
}
out
[
i
]
=
REF_SCALE
(
-
sum
,
nbits
-
2
);
out
[
i
]
=
REF_SCALE
(
-
sum
,
nbits
-
2
);
...
@@ -131,7 +135,7 @@ static void mdct_ref(FFTSample *output, FFTSample *input, int nbits)
...
@@ -131,7 +135,7 @@ static void mdct_ref(FFTSample *output, FFTSample *input, int nbits)
int
i
,
k
,
n
=
1
<<
nbits
;
int
i
,
k
,
n
=
1
<<
nbits
;
/* do it by hand */
/* do it by hand */
for
(
k
=
0
;
k
<
n
/
2
;
k
++
)
{
for
(
k
=
0
;
k
<
n
/
2
;
k
++
)
{
double
s
=
0
;
double
s
=
0
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
double
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
));
...
@@ -158,6 +162,7 @@ static void idct_ref(float *output, float *input, int nbits)
...
@@ -158,6 +162,7 @@ static void idct_ref(float *output, float *input, int nbits)
output
[
i
]
=
2
*
s
/
n
;
output
[
i
]
=
2
*
s
/
n
;
}
}
}
}
static
void
dct_ref
(
float
*
output
,
float
*
input
,
int
nbits
)
static
void
dct_ref
(
float
*
output
,
float
*
input
,
int
nbits
)
{
{
int
i
,
k
,
n
=
1
<<
nbits
;
int
i
,
k
,
n
=
1
<<
nbits
;
...
@@ -175,10 +180,9 @@ static void dct_ref(float *output, float *input, int nbits)
...
@@ -175,10 +180,9 @@ static void dct_ref(float *output, float *input, int nbits)
#endif
/* CONFIG_DCT */
#endif
/* CONFIG_DCT */
#endif
/* FFT_FLOAT */
#endif
/* FFT_FLOAT */
static
FFTSample
frandom
(
AVLFG
*
prng
)
static
FFTSample
frandom
(
AVLFG
*
prng
)
{
{
return
(
int16_t
)
av_lfg_get
(
prng
)
/
32768
.
0
*
RANGE
;
return
(
int16_t
)
av_lfg_get
(
prng
)
/
32768
.
0
*
RANGE
;
}
}
static
int
check_diff
(
FFTSample
*
tab1
,
FFTSample
*
tab2
,
int
n
,
double
scale
)
static
int
check_diff
(
FFTSample
*
tab1
,
FFTSample
*
tab2
,
int
n
,
double
scale
)
...
@@ -193,17 +197,18 @@ static int check_diff(FFTSample *tab1, FFTSample *tab2, int n, double scale)
...
@@ -193,17 +197,18 @@ static int check_diff(FFTSample *tab1, FFTSample *tab2, int n, double scale)
i
,
tab1
[
i
],
tab2
[
i
]);
i
,
tab1
[
i
],
tab2
[
i
]);
err
=
1
;
err
=
1
;
}
}
error
+=
e
*
e
;
error
+=
e
*
e
;
if
(
e
>
max
)
max
=
e
;
if
(
e
>
max
)
max
=
e
;
}
}
av_log
(
NULL
,
AV_LOG_INFO
,
"max:%f e:%g
\n
"
,
max
,
sqrt
(
error
)
/
n
);
av_log
(
NULL
,
AV_LOG_INFO
,
"max:%f e:%g
\n
"
,
max
,
sqrt
(
error
)
/
n
);
return
err
;
return
err
;
}
}
static
void
help
(
void
)
static
void
help
(
void
)
{
{
av_log
(
NULL
,
AV_LOG_INFO
,
"usage: fft-test [-h] [-s] [-i] [-n b]
\n
"
av_log
(
NULL
,
AV_LOG_INFO
,
"usage: fft-test [-h] [-s] [-i] [-n b]
\n
"
"-h print this help
\n
"
"-h print this help
\n
"
"-s speed test
\n
"
"-s speed test
\n
"
"-m (I)MDCT test
\n
"
"-m (I)MDCT test
\n
"
...
@@ -211,8 +216,7 @@ static void help(void)
...
@@ -211,8 +216,7 @@ static void help(void)
"-r (I)RDFT test
\n
"
"-r (I)RDFT test
\n
"
"-i inverse transform test
\n
"
"-i inverse transform test
\n
"
"-n b set the transform size to 2^b
\n
"
"-n b set the transform size to 2^b
\n
"
"-f x set scale factor for output data of (I)MDCT to x
\n
"
"-f x set scale factor for output data of (I)MDCT to x
\n
"
);
);
}
}
enum
tf_transform
{
enum
tf_transform
{
...
@@ -244,11 +248,11 @@ int main(int argc, char **argv)
...
@@ -244,11 +248,11 @@ int main(int argc, char **argv)
av_lfg_init
(
&
prng
,
1
);
av_lfg_init
(
&
prng
,
1
);
for
(;;)
{
for
(;;)
{
int
c
=
getopt
(
argc
,
argv
,
"hsimrdn:f:c:"
);
int
c
=
getopt
(
argc
,
argv
,
"hsimrdn:f:c:"
);
if
(
c
==
-
1
)
if
(
c
==
-
1
)
break
;
break
;
switch
(
c
)
{
switch
(
c
)
{
case
'h'
:
case
'h'
:
help
();
help
();
return
1
;
return
1
;
...
@@ -285,10 +289,10 @@ int main(int argc, char **argv)
...
@@ -285,10 +289,10 @@ int main(int argc, char **argv)
}
}
fft_size
=
1
<<
fft_nbits
;
fft_size
=
1
<<
fft_nbits
;
tab
=
av_malloc
(
fft_size
*
sizeof
(
FFTComplex
));
tab
=
av_malloc
(
fft_size
*
sizeof
(
FFTComplex
));
tab1
=
av_malloc
(
fft_size
*
sizeof
(
FFTComplex
));
tab1
=
av_malloc
(
fft_size
*
sizeof
(
FFTComplex
));
tab_ref
=
av_malloc
(
fft_size
*
sizeof
(
FFTComplex
));
tab_ref
=
av_malloc
(
fft_size
*
sizeof
(
FFTComplex
));
tab2
=
av_malloc
(
fft_size
*
sizeof
(
FFTSample
));
tab2
=
av_malloc
(
fft_size
*
sizeof
(
FFTSample
));
if
(
!
(
tab
&&
tab1
&&
tab_ref
&&
tab2
))
if
(
!
(
tab
&&
tab1
&&
tab_ref
&&
tab2
))
goto
cleanup
;
goto
cleanup
;
...
@@ -296,19 +300,19 @@ int main(int argc, char **argv)
...
@@ -296,19 +300,19 @@ int main(int argc, char **argv)
switch
(
transform
)
{
switch
(
transform
)
{
#if CONFIG_MDCT
#if CONFIG_MDCT
case
TRANSFORM_MDCT
:
case
TRANSFORM_MDCT
:
av_log
(
NULL
,
AV_LOG_INFO
,
"Scale factor is set to %f
\n
"
,
scale
);
av_log
(
NULL
,
AV_LOG_INFO
,
"Scale factor is set to %f
\n
"
,
scale
);
if
(
do_inverse
)
if
(
do_inverse
)
av_log
(
NULL
,
AV_LOG_INFO
,
"IMDCT"
);
av_log
(
NULL
,
AV_LOG_INFO
,
"IMDCT"
);
else
else
av_log
(
NULL
,
AV_LOG_INFO
,
"MDCT"
);
av_log
(
NULL
,
AV_LOG_INFO
,
"MDCT"
);
ff_mdct_init
(
&
m
,
fft_nbits
,
do_inverse
,
scale
);
ff_mdct_init
(
&
m
,
fft_nbits
,
do_inverse
,
scale
);
break
;
break
;
#endif
/* CONFIG_MDCT */
#endif
/* CONFIG_MDCT */
case
TRANSFORM_FFT
:
case
TRANSFORM_FFT
:
if
(
do_inverse
)
if
(
do_inverse
)
av_log
(
NULL
,
AV_LOG_INFO
,
"IFFT"
);
av_log
(
NULL
,
AV_LOG_INFO
,
"IFFT"
);
else
else
av_log
(
NULL
,
AV_LOG_INFO
,
"FFT"
);
av_log
(
NULL
,
AV_LOG_INFO
,
"FFT"
);
ff_fft_init
(
&
s
,
fft_nbits
,
do_inverse
);
ff_fft_init
(
&
s
,
fft_nbits
,
do_inverse
);
if
(
err
=
fft_ref_init
(
fft_nbits
,
do_inverse
)
<
0
)
if
(
err
=
fft_ref_init
(
fft_nbits
,
do_inverse
)
<
0
)
goto
cleanup
;
goto
cleanup
;
...
@@ -317,9 +321,9 @@ int main(int argc, char **argv)
...
@@ -317,9 +321,9 @@ int main(int argc, char **argv)
#if CONFIG_RDFT
#if CONFIG_RDFT
case
TRANSFORM_RDFT
:
case
TRANSFORM_RDFT
:
if
(
do_inverse
)
if
(
do_inverse
)
av_log
(
NULL
,
AV_LOG_INFO
,
"IDFT_C2R"
);
av_log
(
NULL
,
AV_LOG_INFO
,
"IDFT_C2R"
);
else
else
av_log
(
NULL
,
AV_LOG_INFO
,
"DFT_R2C"
);
av_log
(
NULL
,
AV_LOG_INFO
,
"DFT_R2C"
);
ff_rdft_init
(
&
r
,
fft_nbits
,
do_inverse
?
IDFT_C2R
:
DFT_R2C
);
ff_rdft_init
(
&
r
,
fft_nbits
,
do_inverse
?
IDFT_C2R
:
DFT_R2C
);
if
(
err
=
fft_ref_init
(
fft_nbits
,
do_inverse
)
<
0
)
if
(
err
=
fft_ref_init
(
fft_nbits
,
do_inverse
)
<
0
)
goto
cleanup
;
goto
cleanup
;
...
@@ -328,9 +332,9 @@ int main(int argc, char **argv)
...
@@ -328,9 +332,9 @@ int main(int argc, char **argv)
#if CONFIG_DCT
#if CONFIG_DCT
case
TRANSFORM_DCT
:
case
TRANSFORM_DCT
:
if
(
do_inverse
)
if
(
do_inverse
)
av_log
(
NULL
,
AV_LOG_INFO
,
"DCT_III"
);
av_log
(
NULL
,
AV_LOG_INFO
,
"DCT_III"
);
else
else
av_log
(
NULL
,
AV_LOG_INFO
,
"DCT_II"
);
av_log
(
NULL
,
AV_LOG_INFO
,
"DCT_II"
);
ff_dct_init
(
&
d
,
fft_nbits
,
do_inverse
?
DCT_III
:
DCT_II
);
ff_dct_init
(
&
d
,
fft_nbits
,
do_inverse
?
DCT_III
:
DCT_II
);
break
;
break
;
#endif
/* CONFIG_DCT */
#endif
/* CONFIG_DCT */
...
@@ -339,7 +343,7 @@ int main(int argc, char **argv)
...
@@ -339,7 +343,7 @@ int main(int argc, char **argv)
av_log
(
NULL
,
AV_LOG_ERROR
,
"Requested transform not supported
\n
"
);
av_log
(
NULL
,
AV_LOG_ERROR
,
"Requested transform not supported
\n
"
);
goto
cleanup
;
goto
cleanup
;
}
}
av_log
(
NULL
,
AV_LOG_INFO
,
" %d test
\n
"
,
fft_size
);
av_log
(
NULL
,
AV_LOG_INFO
,
" %d test
\n
"
,
fft_size
);
/* generate random data */
/* generate random data */
...
@@ -349,21 +353,21 @@ int main(int argc, char **argv)
...
@@ -349,21 +353,21 @@ int main(int argc, char **argv)
}
}
/* checking result */
/* checking result */
av_log
(
NULL
,
AV_LOG_INFO
,
"Checking...
\n
"
);
av_log
(
NULL
,
AV_LOG_INFO
,
"Checking...
\n
"
);
switch
(
transform
)
{
switch
(
transform
)
{
#if CONFIG_MDCT
#if CONFIG_MDCT
case
TRANSFORM_MDCT
:
case
TRANSFORM_MDCT
:
if
(
do_inverse
)
{
if
(
do_inverse
)
{
imdct_ref
((
FFTSample
*
)
tab_ref
,
(
FFTSample
*
)
tab1
,
fft_nbits
);
imdct_ref
((
FFTSample
*
)
tab_ref
,
(
FFTSample
*
)
tab1
,
fft_nbits
);
m
.
imdct_calc
(
&
m
,
tab2
,
(
FFTSample
*
)
tab1
);
m
.
imdct_calc
(
&
m
,
tab2
,
(
FFTSample
*
)
tab1
);
err
=
check_diff
((
FFTSample
*
)
tab_ref
,
tab2
,
fft_size
,
scale
);
err
=
check_diff
((
FFTSample
*
)
tab_ref
,
tab2
,
fft_size
,
scale
);
}
else
{
}
else
{
mdct_ref
((
FFTSample
*
)
tab_ref
,
(
FFTSample
*
)
tab1
,
fft_nbits
);
mdct_ref
((
FFTSample
*
)
tab_ref
,
(
FFTSample
*
)
tab1
,
fft_nbits
);
m
.
mdct_calc
(
&
m
,
tab2
,
(
FFTSample
*
)
tab1
);
m
.
mdct_calc
(
&
m
,
tab2
,
(
FFTSample
*
)
tab1
);
err
=
check_diff
((
FFTSample
*
)
tab_ref
,
tab2
,
fft_size
/
2
,
scale
);
err
=
check_diff
((
FFTSample
*
)
tab_ref
,
tab2
,
fft_size
/
2
,
scale
);
}
}
break
;
break
;
#endif
/* CONFIG_MDCT */
#endif
/* CONFIG_MDCT */
...
@@ -373,7 +377,8 @@ int main(int argc, char **argv)
...
@@ -373,7 +377,8 @@ int main(int argc, char **argv)
s
.
fft_calc
(
&
s
,
tab
);
s
.
fft_calc
(
&
s
,
tab
);
fft_ref
(
tab_ref
,
tab1
,
fft_nbits
);
fft_ref
(
tab_ref
,
tab1
,
fft_nbits
);
err
=
check_diff
((
FFTSample
*
)
tab_ref
,
(
FFTSample
*
)
tab
,
fft_size
*
2
,
1
.
0
);
err
=
check_diff
((
FFTSample
*
)
tab_ref
,
(
FFTSample
*
)
tab
,
fft_size
*
2
,
1
.
0
);
break
;
break
;
#if FFT_FLOAT
#if FFT_FLOAT
#if CONFIG_RDFT
#if CONFIG_RDFT
...
@@ -381,11 +386,11 @@ int main(int argc, char **argv)
...
@@ -381,11 +386,11 @@ int main(int argc, char **argv)
{
{
int
fft_size_2
=
fft_size
>>
1
;
int
fft_size_2
=
fft_size
>>
1
;
if
(
do_inverse
)
{
if
(
do_inverse
)
{
tab1
[
0
].
im
=
0
;
tab1
[
0
].
im
=
0
;
tab1
[
fft_size_2
].
im
=
0
;
tab1
[
fft_size_2
].
im
=
0
;
for
(
i
=
1
;
i
<
fft_size_2
;
i
++
)
{
for
(
i
=
1
;
i
<
fft_size_2
;
i
++
)
{
tab1
[
fft_size_2
+
i
].
re
=
tab1
[
fft_size_2
-
i
].
re
;
tab1
[
fft_size_2
+
i
].
re
=
tab1
[
fft_size_2
-
i
].
re
;
tab1
[
fft_size_2
+
i
].
im
=
-
tab1
[
fft_size_2
-
i
].
im
;
tab1
[
fft_size_2
+
i
].
im
=
-
tab1
[
fft_size_2
-
i
].
im
;
}
}
memcpy
(
tab2
,
tab1
,
fft_size
*
sizeof
(
FFTSample
));
memcpy
(
tab2
,
tab1
,
fft_size
*
sizeof
(
FFTSample
));
...
@@ -397,7 +402,8 @@ int main(int argc, char **argv)
...
@@ -397,7 +402,8 @@ int main(int argc, char **argv)
tab
[
i
].
re
=
tab2
[
i
];
tab
[
i
].
re
=
tab2
[
i
];
tab
[
i
].
im
=
0
;
tab
[
i
].
im
=
0
;
}
}
err
=
check_diff
((
float
*
)
tab_ref
,
(
float
*
)
tab
,
fft_size
*
2
,
0
.
5
);
err
=
check_diff
((
float
*
)
tab_ref
,
(
float
*
)
tab
,
fft_size
*
2
,
0
.
5
);
}
else
{
}
else
{
for
(
i
=
0
;
i
<
fft_size
;
i
++
)
{
for
(
i
=
0
;
i
<
fft_size
;
i
++
)
{
tab2
[
i
]
=
tab1
[
i
].
re
;
tab2
[
i
]
=
tab1
[
i
].
re
;
...
@@ -406,7 +412,7 @@ int main(int argc, char **argv)
...
@@ -406,7 +412,7 @@ int main(int argc, char **argv)
r
.
rdft_calc
(
&
r
,
tab2
);
r
.
rdft_calc
(
&
r
,
tab2
);
fft_ref
(
tab_ref
,
tab1
,
fft_nbits
);
fft_ref
(
tab_ref
,
tab1
,
fft_nbits
);
tab_ref
[
0
].
im
=
tab_ref
[
fft_size_2
].
re
;
tab_ref
[
0
].
im
=
tab_ref
[
fft_size_2
].
re
;
err
=
check_diff
((
float
*
)
tab_ref
,
(
float
*
)
tab2
,
fft_size
,
1
.
0
);
err
=
check_diff
((
float
*
)
tab_ref
,
(
float
*
)
tab2
,
fft_size
,
1
.
0
);
}
}
break
;
break
;
}
}
...
@@ -415,12 +421,11 @@ int main(int argc, char **argv)
...
@@ -415,12 +421,11 @@ int main(int argc, char **argv)
case
TRANSFORM_DCT
:
case
TRANSFORM_DCT
:
memcpy
(
tab
,
tab1
,
fft_size
*
sizeof
(
FFTComplex
));
memcpy
(
tab
,
tab1
,
fft_size
*
sizeof
(
FFTComplex
));
d
.
dct_calc
(
&
d
,
tab
);
d
.
dct_calc
(
&
d
,
tab
);
if
(
do_inverse
)
{
if
(
do_inverse
)
idct_ref
(
tab_ref
,
tab1
,
fft_nbits
);
idct_ref
(
tab_ref
,
tab1
,
fft_nbits
);
}
else
{
else
dct_ref
(
tab_ref
,
tab1
,
fft_nbits
);
dct_ref
(
tab_ref
,
tab1
,
fft_nbits
);
}
err
=
check_diff
((
float
*
)
tab_ref
,
(
float
*
)
tab
,
fft_size
,
1
.
0
);
err
=
check_diff
((
float
*
)
tab_ref
,
(
float
*
)
tab
,
fft_size
,
1
.
0
);
break
;
break
;
#endif
/* CONFIG_DCT */
#endif
/* CONFIG_DCT */
#endif
/* FFT_FLOAT */
#endif
/* FFT_FLOAT */
...
@@ -432,19 +437,18 @@ int main(int argc, char **argv)
...
@@ -432,19 +437,18 @@ int main(int argc, char **argv)
int64_t
time_start
,
duration
;
int64_t
time_start
,
duration
;
int
nb_its
;
int
nb_its
;
av_log
(
NULL
,
AV_LOG_INFO
,
"Speed test...
\n
"
);
av_log
(
NULL
,
AV_LOG_INFO
,
"Speed test...
\n
"
);
/* we measure during about 1 seconds */
/* we measure during about 1 seconds */
nb_its
=
1
;
nb_its
=
1
;
for
(;;)
{
for
(;;)
{
time_start
=
av_gettime
();
time_start
=
av_gettime
();
for
(
it
=
0
;
it
<
nb_its
;
it
++
)
{
for
(
it
=
0
;
it
<
nb_its
;
it
++
)
{
switch
(
transform
)
{
switch
(
transform
)
{
case
TRANSFORM_MDCT
:
case
TRANSFORM_MDCT
:
if
(
do_inverse
)
{
if
(
do_inverse
)
m
.
imdct_calc
(
&
m
,
(
FFTSample
*
)
tab
,
(
FFTSample
*
)
tab1
);
m
.
imdct_calc
(
&
m
,
(
FFTSample
*
)
tab
,
(
FFTSample
*
)
tab1
);
}
else
{
else
m
.
mdct_calc
(
&
m
,
(
FFTSample
*
)
tab
,
(
FFTSample
*
)
tab1
);
m
.
mdct_calc
(
&
m
,
(
FFTSample
*
)
tab
,
(
FFTSample
*
)
tab1
);
}
break
;
break
;
case
TRANSFORM_FFT
:
case
TRANSFORM_FFT
:
memcpy
(
tab
,
tab1
,
fft_size
*
sizeof
(
FFTComplex
));
memcpy
(
tab
,
tab1
,
fft_size
*
sizeof
(
FFTComplex
));
...
@@ -467,9 +471,10 @@ int main(int argc, char **argv)
...
@@ -467,9 +471,10 @@ int main(int argc, char **argv)
break
;
break
;
nb_its
*=
2
;
nb_its
*=
2
;
}
}
av_log
(
NULL
,
AV_LOG_INFO
,
"time: %0.1f us/transform [total time=%0.2f s its=%d]
\n
"
,
av_log
(
NULL
,
AV_LOG_INFO
,
(
double
)
duration
/
nb_its
,
"time: %0.1f us/transform [total time=%0.2f s its=%d]
\n
"
,
(
double
)
duration
/
1000000
.
0
,
(
double
)
duration
/
nb_its
,
(
double
)
duration
/
1000000
.
0
,
nb_its
);
nb_its
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment