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
5a39b797
Commit
5a39b797
authored
Apr 30, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/avf_showspectrum: convert some doubles to floats
parent
d0e4d042
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
34 deletions
+34
-34
avf_showspectrum.c
libavfilter/avf_showspectrum.c
+34
-34
No files found.
libavfilter/avf_showspectrum.c
View file @
5a39b797
...
@@ -392,29 +392,29 @@ static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
...
@@ -392,29 +392,29 @@ static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
}
}
if
(
s
->
stop
)
{
if
(
s
->
stop
)
{
double
theta
,
phi
,
psi
,
a
,
b
,
S
,
c
;
float
theta
,
phi
,
psi
,
a
,
b
,
S
,
c
;
FFTComplex
*
g
=
s
->
fft_data
[
ch
];
FFTComplex
*
g
=
s
->
fft_data
[
ch
];
FFTComplex
*
h
=
s
->
fft_scratch
[
ch
];
FFTComplex
*
h
=
s
->
fft_scratch
[
ch
];
int
L
=
s
->
buf_size
;
int
L
=
s
->
buf_size
;
int
N
=
s
->
win_size
;
int
N
=
s
->
win_size
;
int
M
=
s
->
win_size
/
2
;
int
M
=
s
->
win_size
/
2
;
phi
=
2
.
0
*
M_PI
*
(
s
->
stop
-
s
->
start
)
/
(
double
)
inlink
->
sample_rate
/
(
M
-
1
);
phi
=
2
.
f
*
M_PI
*
(
s
->
stop
-
s
->
start
)
/
(
float
)
inlink
->
sample_rate
/
(
M
-
1
);
theta
=
2
.
0
*
M_PI
*
s
->
start
/
(
double
)
inlink
->
sample_rate
;
theta
=
2
.
f
*
M_PI
*
s
->
start
/
(
float
)
inlink
->
sample_rate
;
for
(
int
n
=
0
;
n
<
M
;
n
++
)
{
for
(
int
n
=
0
;
n
<
M
;
n
++
)
{
h
[
n
].
re
=
cos
(
n
*
n
/
2
.
0
*
phi
);
h
[
n
].
re
=
cos
f
(
n
*
n
/
2
.
f
*
phi
);
h
[
n
].
im
=
sin
(
n
*
n
/
2
.
0
*
phi
);
h
[
n
].
im
=
sin
f
(
n
*
n
/
2
.
f
*
phi
);
}
}
for
(
int
n
=
M
;
n
<
L
;
n
++
)
{
for
(
int
n
=
M
;
n
<
L
;
n
++
)
{
h
[
n
].
re
=
0
.
0
;
h
[
n
].
re
=
0
.
f
;
h
[
n
].
im
=
0
.
0
;
h
[
n
].
im
=
0
.
f
;
}
}
for
(
int
n
=
L
-
N
;
n
<
L
;
n
++
)
{
for
(
int
n
=
L
-
N
;
n
<
L
;
n
++
)
{
h
[
n
].
re
=
cos
((
L
-
n
)
*
(
L
-
n
)
/
2
.
0
*
phi
);
h
[
n
].
re
=
cos
f
((
L
-
n
)
*
(
L
-
n
)
/
2
.
f
*
phi
);
h
[
n
].
im
=
sin
((
L
-
n
)
*
(
L
-
n
)
/
2
.
0
*
phi
);
h
[
n
].
im
=
sin
f
((
L
-
n
)
*
(
L
-
n
)
/
2
.
f
*
phi
);
}
}
for
(
int
n
=
0
;
n
<
N
;
n
++
)
{
for
(
int
n
=
0
;
n
<
N
;
n
++
)
{
...
@@ -423,14 +423,14 @@ static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
...
@@ -423,14 +423,14 @@ static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
}
}
for
(
int
n
=
N
;
n
<
L
;
n
++
)
{
for
(
int
n
=
N
;
n
<
L
;
n
++
)
{
g
[
n
].
re
=
0
.;
g
[
n
].
re
=
0
.
f
;
g
[
n
].
im
=
0
.;
g
[
n
].
im
=
0
.
f
;
}
}
for
(
int
n
=
0
;
n
<
N
;
n
++
)
{
for
(
int
n
=
0
;
n
<
N
;
n
++
)
{
psi
=
n
*
theta
+
n
*
n
/
2
.
0
*
phi
;
psi
=
n
*
theta
+
n
*
n
/
2
.
f
*
phi
;
c
=
cos
(
psi
);
c
=
cos
f
(
psi
);
S
=
-
sin
(
psi
);
S
=
-
sin
f
(
psi
);
a
=
c
*
g
[
n
].
re
-
S
*
g
[
n
].
im
;
a
=
c
*
g
[
n
].
re
-
S
*
g
[
n
].
im
;
b
=
S
*
g
[
n
].
re
+
c
*
g
[
n
].
im
;
b
=
S
*
g
[
n
].
re
+
c
*
g
[
n
].
im
;
g
[
n
].
re
=
a
;
g
[
n
].
re
=
a
;
...
@@ -457,9 +457,9 @@ static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
...
@@ -457,9 +457,9 @@ static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
av_fft_calc
(
s
->
ifft
[
ch
],
g
);
av_fft_calc
(
s
->
ifft
[
ch
],
g
);
for
(
int
k
=
0
;
k
<
M
;
k
++
)
{
for
(
int
k
=
0
;
k
<
M
;
k
++
)
{
psi
=
k
*
k
/
2
.
0
*
phi
;
psi
=
k
*
k
/
2
.
f
*
phi
;
c
=
cos
(
psi
);
c
=
cos
f
(
psi
);
S
=
-
sin
(
psi
);
S
=
-
sin
f
(
psi
);
a
=
c
*
g
[
k
].
re
-
S
*
g
[
k
].
im
;
a
=
c
*
g
[
k
].
re
-
S
*
g
[
k
].
im
;
b
=
S
*
g
[
k
].
re
+
c
*
g
[
k
].
im
;
b
=
S
*
g
[
k
].
re
+
c
*
g
[
k
].
im
;
s
->
fft_data
[
ch
][
k
].
re
=
a
;
s
->
fft_data
[
ch
][
k
].
re
=
a
;
...
@@ -555,15 +555,15 @@ static void color_range(ShowSpectrumContext *s, int ch,
...
@@ -555,15 +555,15 @@ static void color_range(ShowSpectrumContext *s, int ch,
if
(
s
->
color_mode
==
CHANNEL
)
{
if
(
s
->
color_mode
==
CHANNEL
)
{
if
(
s
->
nb_display_channels
>
1
)
{
if
(
s
->
nb_display_channels
>
1
)
{
*
uf
*=
0
.
5
*
sin
((
2
*
M_PI
*
ch
)
/
s
->
nb_display_channels
+
M_PI
*
s
->
rotation
);
*
uf
*=
0
.
5
f
*
sinf
((
2
*
M_PI
*
ch
)
/
s
->
nb_display_channels
+
M_PI
*
s
->
rotation
);
*
vf
*=
0
.
5
*
cos
((
2
*
M_PI
*
ch
)
/
s
->
nb_display_channels
+
M_PI
*
s
->
rotation
);
*
vf
*=
0
.
5
f
*
cosf
((
2
*
M_PI
*
ch
)
/
s
->
nb_display_channels
+
M_PI
*
s
->
rotation
);
}
else
{
}
else
{
*
uf
*=
0
.
5
*
sin
(
M_PI
*
s
->
rotation
);
*
uf
*=
0
.
5
f
*
sinf
(
M_PI
*
s
->
rotation
);
*
vf
*=
0
.
5
*
cos
(
M_PI
*
s
->
rotation
+
M_PI_2
);
*
vf
*=
0
.
5
f
*
cosf
(
M_PI
*
s
->
rotation
+
M_PI_2
);
}
}
}
else
{
}
else
{
*
uf
+=
*
uf
*
sin
(
M_PI
*
s
->
rotation
);
*
uf
+=
*
uf
*
sin
f
(
M_PI
*
s
->
rotation
);
*
vf
+=
*
vf
*
cos
(
M_PI
*
s
->
rotation
+
M_PI_2
);
*
vf
+=
*
vf
*
cos
f
(
M_PI
*
s
->
rotation
+
M_PI_2
);
}
}
*
uf
*=
s
->
saturation
;
*
uf
*=
s
->
saturation
;
...
@@ -854,7 +854,7 @@ static int draw_legend(AVFilterContext *ctx, int samples)
...
@@ -854,7 +854,7 @@ static int draw_legend(AVFilterContext *ctx, int samples)
}
}
for
(
y
=
0
;
ch
==
0
&&
y
<
h
;
y
+=
h
/
10
)
{
for
(
y
=
0
;
ch
==
0
&&
y
<
h
;
y
+=
h
/
10
)
{
float
value
=
120
.
0
*
log10
(
1
.
-
y
/
(
float
)
h
);
float
value
=
120
.
f
*
log10f
(
1
.
f
-
y
/
(
float
)
h
);
char
*
text
;
char
*
text
;
if
(
value
<
-
120
)
if
(
value
<
-
120
)
...
@@ -896,19 +896,19 @@ static float get_value(AVFilterContext *ctx, int ch, int y)
...
@@ -896,19 +896,19 @@ static float get_value(AVFilterContext *ctx, int ch, int y)
a
=
av_clipf
(
a
,
0
,
1
);
a
=
av_clipf
(
a
,
0
,
1
);
break
;
break
;
case
SQRT
:
case
SQRT
:
a
=
av_clipf
(
sqrt
(
a
),
0
,
1
);
a
=
av_clipf
(
sqrt
f
(
a
),
0
,
1
);
break
;
break
;
case
CBRT
:
case
CBRT
:
a
=
av_clipf
(
cbrt
(
a
),
0
,
1
);
a
=
av_clipf
(
cbrt
f
(
a
),
0
,
1
);
break
;
break
;
case
FOURTHRT
:
case
FOURTHRT
:
a
=
av_clipf
(
sqrt
(
sqrt
(
a
)),
0
,
1
);
a
=
av_clipf
(
sqrt
f
(
sqrtf
(
a
)),
0
,
1
);
break
;
break
;
case
FIFTHRT
:
case
FIFTHRT
:
a
=
av_clipf
(
pow
(
a
,
0
.
20
),
0
,
1
);
a
=
av_clipf
(
pow
f
(
a
,
0
.
20
),
0
,
1
);
break
;
break
;
case
LOG
:
case
LOG
:
a
=
1
+
log10
(
av_clipd
(
a
,
1e-6
,
1
))
/
6
;
// zero = -120dBFS
a
=
1
.
f
+
log10f
(
av_clipf
(
a
,
1e-6
,
1
))
/
6
.
f
;
// zero = -120dBFS
break
;
break
;
default:
default:
av_assert0
(
0
);
av_assert0
(
0
);
...
@@ -1128,7 +1128,7 @@ static int config_output(AVFilterLink *outlink)
...
@@ -1128,7 +1128,7 @@ static int config_output(AVFilterLink *outlink)
generate_window_func
(
s
->
window_func_lut
,
s
->
win_size
,
s
->
win_func
,
&
overlap
);
generate_window_func
(
s
->
window_func_lut
,
s
->
win_size
,
s
->
win_func
,
&
overlap
);
if
(
s
->
overlap
==
1
)
if
(
s
->
overlap
==
1
)
s
->
overlap
=
overlap
;
s
->
overlap
=
overlap
;
s
->
hop_size
=
(
1
.
-
s
->
overlap
)
*
s
->
win_size
;
s
->
hop_size
=
(
1
.
f
-
s
->
overlap
)
*
s
->
win_size
;
if
(
s
->
hop_size
<
1
)
{
if
(
s
->
hop_size
<
1
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"overlap %f too big
\n
"
,
s
->
overlap
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"overlap %f too big
\n
"
,
s
->
overlap
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
...
@@ -1137,7 +1137,7 @@ static int config_output(AVFilterLink *outlink)
...
@@ -1137,7 +1137,7 @@ static int config_output(AVFilterLink *outlink)
for
(
s
->
win_scale
=
0
,
i
=
0
;
i
<
s
->
win_size
;
i
++
)
{
for
(
s
->
win_scale
=
0
,
i
=
0
;
i
<
s
->
win_size
;
i
++
)
{
s
->
win_scale
+=
s
->
window_func_lut
[
i
]
*
s
->
window_func_lut
[
i
];
s
->
win_scale
+=
s
->
window_func_lut
[
i
]
*
s
->
window_func_lut
[
i
];
}
}
s
->
win_scale
=
1
.
/
sqrt
(
s
->
win_scale
);
s
->
win_scale
=
1
.
f
/
sqrtf
(
s
->
win_scale
);
/* prepare the initial picref buffer (black frame) */
/* prepare the initial picref buffer (black frame) */
av_frame_free
(
&
s
->
outpicref
);
av_frame_free
(
&
s
->
outpicref
);
...
@@ -1198,8 +1198,8 @@ static int config_output(AVFilterLink *outlink)
...
@@ -1198,8 +1198,8 @@ static int config_output(AVFilterLink *outlink)
#define RE(y, ch) s->fft_data[ch][y].re
#define RE(y, ch) s->fft_data[ch][y].re
#define IM(y, ch) s->fft_data[ch][y].im
#define IM(y, ch) s->fft_data[ch][y].im
#define MAGNITUDE(y, ch) hypot(RE(y, ch), IM(y, ch))
#define MAGNITUDE(y, ch) hypot
f
(RE(y, ch), IM(y, ch))
#define PHASE(y, ch) atan2(IM(y, ch), RE(y, ch))
#define PHASE(y, ch) atan2
f
(IM(y, ch), RE(y, ch))
static
int
calc_channel_magnitudes
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
static
int
calc_channel_magnitudes
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
{
...
@@ -1639,7 +1639,7 @@ static int showspectrumpic_request_frame(AVFilterLink *outlink)
...
@@ -1639,7 +1639,7 @@ static int showspectrumpic_request_frame(AVFilterLink *outlink)
if
(
consumed
>=
spb
)
{
if
(
consumed
>=
spb
)
{
int
h
=
s
->
orientation
==
VERTICAL
?
s
->
h
:
s
->
w
;
int
h
=
s
->
orientation
==
VERTICAL
?
s
->
h
:
s
->
w
;
scale_magnitudes
(
s
,
1
.
/
(
consumed
/
spf
));
scale_magnitudes
(
s
,
1
.
f
/
(
consumed
/
spf
));
plot_spectrum_column
(
inlink
,
fin
);
plot_spectrum_column
(
inlink
,
fin
);
consumed
=
0
;
consumed
=
0
;
x
++
;
x
++
;
...
...
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