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
57df71ea
Commit
57df71ea
authored
Jan 10, 2016
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/avf_showspectrum: reduce number of operations
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
2009d922
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
avf_showspectrum.c
libavfilter/avf_showspectrum.c
+8
-6
No files found.
libavfilter/avf_showspectrum.c
View file @
57df71ea
...
@@ -451,13 +451,15 @@ static void run_fft(ShowSpectrumContext *s, AVFrame *fin)
...
@@ -451,13 +451,15 @@ static void run_fft(ShowSpectrumContext *s, AVFrame *fin)
static
void
calc_magnitudes
(
ShowSpectrumContext
*
s
)
static
void
calc_magnitudes
(
ShowSpectrumContext
*
s
)
{
{
const
double
w
=
s
->
win_scale
*
(
s
->
scale
==
LOG
?
s
->
win_scale
:
1
);
int
ch
,
y
,
h
=
s
->
orientation
==
VERTICAL
?
s
->
h
:
s
->
w
;
int
ch
,
y
,
h
=
s
->
orientation
==
VERTICAL
?
s
->
h
:
s
->
w
;
const
float
f
=
s
->
gain
*
w
;
for
(
ch
=
0
;
ch
<
s
->
nb_display_channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
s
->
nb_display_channels
;
ch
++
)
{
float
*
magnitudes
=
s
->
magnitudes
[
ch
];
float
*
magnitudes
=
s
->
magnitudes
[
ch
];
for
(
y
=
0
;
y
<
h
;
y
++
)
for
(
y
=
0
;
y
<
h
;
y
++
)
magnitudes
[
y
]
=
MAGNITUDE
(
y
,
ch
);
magnitudes
[
y
]
=
MAGNITUDE
(
y
,
ch
)
*
f
;
}
}
}
}
...
@@ -475,13 +477,15 @@ static void calc_phases(ShowSpectrumContext *s)
...
@@ -475,13 +477,15 @@ static void calc_phases(ShowSpectrumContext *s)
static
void
acalc_magnitudes
(
ShowSpectrumContext
*
s
)
static
void
acalc_magnitudes
(
ShowSpectrumContext
*
s
)
{
{
const
double
w
=
s
->
win_scale
*
(
s
->
scale
==
LOG
?
s
->
win_scale
:
1
);
int
ch
,
y
,
h
=
s
->
orientation
==
VERTICAL
?
s
->
h
:
s
->
w
;
int
ch
,
y
,
h
=
s
->
orientation
==
VERTICAL
?
s
->
h
:
s
->
w
;
const
float
f
=
s
->
gain
*
w
;
for
(
ch
=
0
;
ch
<
s
->
nb_display_channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
s
->
nb_display_channels
;
ch
++
)
{
float
*
magnitudes
=
s
->
magnitudes
[
ch
];
float
*
magnitudes
=
s
->
magnitudes
[
ch
];
for
(
y
=
0
;
y
<
h
;
y
++
)
for
(
y
=
0
;
y
<
h
;
y
++
)
magnitudes
[
y
]
+=
MAGNITUDE
(
y
,
ch
);
magnitudes
[
y
]
+=
MAGNITUDE
(
y
,
ch
)
*
f
;
}
}
}
}
...
@@ -611,8 +615,6 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
...
@@ -611,8 +615,6 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
ShowSpectrumContext
*
s
=
ctx
->
priv
;
ShowSpectrumContext
*
s
=
ctx
->
priv
;
AVFrame
*
outpicref
=
s
->
outpicref
;
AVFrame
*
outpicref
=
s
->
outpicref
;
const
double
w
=
s
->
data
==
D_PHASE
?
1
:
s
->
win_scale
;
const
float
g
=
s
->
gain
;
int
h
=
s
->
orientation
==
VERTICAL
?
s
->
channel_height
:
s
->
channel_width
;
int
h
=
s
->
orientation
==
VERTICAL
?
s
->
channel_height
:
s
->
channel_width
;
int
ch
,
plane
,
x
,
y
;
int
ch
,
plane
,
x
,
y
;
...
@@ -638,7 +640,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
...
@@ -638,7 +640,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
switch
(
s
->
data
)
{
switch
(
s
->
data
)
{
case
D_MAGNITUDE
:
case
D_MAGNITUDE
:
/* get magnitude */
/* get magnitude */
a
=
g
*
w
*
magnitudes
[
y
];
a
=
magnitudes
[
y
];
break
;
break
;
case
D_PHASE
:
case
D_PHASE
:
/* get phase */
/* get phase */
...
@@ -666,7 +668,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
...
@@ -666,7 +668,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
a
=
av_clipf
(
pow
(
a
,
0
.
20
),
0
,
1
);
a
=
av_clipf
(
pow
(
a
,
0
.
20
),
0
,
1
);
break
;
break
;
case
LOG
:
case
LOG
:
a
=
1
+
log10
(
av_clipd
(
a
*
w
,
1e-6
,
1
))
/
6
;
// zero = -120dBFS
a
=
1
+
log10
(
av_clipd
(
a
,
1e-6
,
1
))
/
6
;
// zero = -120dBFS
break
;
break
;
default:
default:
av_assert0
(
0
);
av_assert0
(
0
);
...
...
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