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
7aef5686
Commit
7aef5686
authored
Jan 09, 2017
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_sofalizer: speed and clean up fast convolution a little
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
cd09e3b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
af_sofalizer.c
libavfilter/af_sofalizer.c
+9
-5
No files found.
libavfilter/af_sofalizer.c
View file @
7aef5686
...
...
@@ -703,6 +703,8 @@ static int sofalizer_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
FFTContext
*
fft
=
s
->
fft
[
jobnr
];
const
int
n_conv
=
s
->
n_conv
;
const
int
n_fft
=
s
->
n_fft
;
const
float
fft_scale
=
1
.
0
f
/
s
->
n_fft
;
FFTComplex
*
hrtf_offset
;
int
wr
=
*
write
;
int
n_read
;
int
i
,
j
;
...
...
@@ -736,6 +738,7 @@ static int sofalizer_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
/* outer loop: go through all input channels to be convolved */
offset
=
i
*
n_fft
;
/* no. samples already processed */
hrtf_offset
=
hrtf
+
offset
;
/* fill FFT input with 0 (we want to zero-pad) */
memset
(
fft_in
,
0
,
sizeof
(
FFTComplex
)
*
n_fft
);
...
...
@@ -750,14 +753,15 @@ static int sofalizer_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
av_fft_permute
(
fft
,
fft_in
);
av_fft_calc
(
fft
,
fft_in
);
for
(
j
=
0
;
j
<
n_fft
;
j
++
)
{
const
FFTComplex
*
hcomplex
=
hrtf_offset
+
j
;
const
float
re
=
fft_in
[
j
].
re
;
const
float
im
=
fft_in
[
j
].
im
;
/* complex multiplication of input signal and HRTFs */
/* output channel (real): */
fft_in
[
j
].
re
=
re
*
(
hrtf
+
offset
+
j
)
->
re
-
im
*
(
hrtf
+
offset
+
j
)
->
im
;
fft_in
[
j
].
re
=
re
*
hcomplex
->
re
-
im
*
hcomplex
->
im
;
/* output channel (imag): */
fft_in
[
j
].
im
=
re
*
(
hrtf
+
offset
+
j
)
->
im
+
im
*
(
hrtf
+
offset
+
j
)
->
re
;
fft_in
[
j
].
im
=
re
*
hcomplex
->
im
+
im
*
hcomplex
->
re
;
}
/* transform output signal of current channel back to time domain */
...
...
@@ -766,14 +770,14 @@ static int sofalizer_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
for
(
j
=
0
;
j
<
in
->
nb_samples
;
j
++
)
{
/* write output signal of current channel to output buffer */
dst
[
2
*
j
]
+=
fft_in
[
j
].
re
/
(
float
)
n_fft
;
dst
[
2
*
j
]
+=
fft_in
[
j
].
re
*
fft_scale
;
}
for
(
j
=
0
;
j
<
n_samples
-
1
;
j
++
)
{
/* overflow length is IR length - 1 */
/* write the rest of output signal to overflow buffer */
int
write_pos
=
(
wr
+
j
)
&
modulo
;
*
(
ringbuffer
+
write_pos
)
+=
fft_in
[
in
->
nb_samples
+
j
].
re
/
(
float
)
n_fft
;
*
(
ringbuffer
+
write_pos
)
+=
fft_in
[
in
->
nb_samples
+
j
].
re
*
fft_scale
;
}
}
...
...
@@ -781,7 +785,7 @@ static int sofalizer_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
for
(
i
=
0
;
i
<
out
->
nb_samples
;
i
++
)
{
/* clippings counter */
if
(
fabs
(
*
dst
)
>
1
)
{
/* if current output sample > 1 */
*
n_clippings
=
*
n_clippings
+
1
;
n_clippings
[
0
]
++
;
}
/* move output buffer pointer by +2 to get to next sample of processed channel: */
...
...
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