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
270068b5
Commit
270068b5
authored
Apr 14, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_acrossover: improve filter output
Makes sum always flat. Also faster.
parent
616e9b5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
39 deletions
+19
-39
af_acrossover.c
libavfilter/af_acrossover.c
+19
-39
No files found.
libavfilter/af_acrossover.c
View file @
270068b5
...
@@ -47,7 +47,6 @@ typedef struct BiquadContext {
...
@@ -47,7 +47,6 @@ typedef struct BiquadContext {
typedef
struct
CrossoverChannel
{
typedef
struct
CrossoverChannel
{
BiquadContext
lp
[
MAX_BANDS
][
4
];
BiquadContext
lp
[
MAX_BANDS
][
4
];
BiquadContext
hp
[
MAX_BANDS
][
4
];
}
CrossoverChannel
;
}
CrossoverChannel
;
typedef
struct
AudioCrossoverContext
{
typedef
struct
AudioCrossoverContext
{
...
@@ -131,30 +130,16 @@ static av_cold int init(AVFilterContext *ctx)
...
@@ -131,30 +130,16 @@ static av_cold int init(AVFilterContext *ctx)
return
ret
;
return
ret
;
}
}
static
void
set_lp
(
BiquadContext
*
b
,
float
fc
,
float
q
,
float
sr
)
static
void
set_lp
(
BiquadContext
*
b
,
double
fc
,
double
q
,
double
sr
)
{
{
double
omega
=
(
2
.
0
*
M_PI
*
fc
/
sr
)
;
double
omega
=
2
.
0
*
M_PI
*
fc
/
sr
;
double
sn
=
sin
(
omega
);
double
sn
=
sin
(
omega
);
double
cs
=
cos
(
omega
);
double
cs
=
cos
(
omega
);
double
alpha
=
(
sn
/
(
2
*
q
));
double
alpha
=
sn
/
(
2
.
*
q
);
double
inv
=
(
1
.
0
/
(
1
.
0
+
alpha
));
b
->
a2
=
b
->
a0
=
(
inv
*
(
1
.
0
-
cs
)
*
0
.
5
);
b
->
a1
=
b
->
a0
+
b
->
a0
;
b
->
b1
=
-
2
.
*
cs
*
inv
;
b
->
b2
=
(
1
.
-
alpha
)
*
inv
;
}
static
void
set_hp
(
BiquadContext
*
b
,
float
fc
,
float
q
,
float
sr
)
{
double
omega
=
2
*
M_PI
*
fc
/
sr
;
double
sn
=
sin
(
omega
);
double
cs
=
cos
(
omega
);
double
alpha
=
sn
/
(
2
*
q
);
double
inv
=
1
.
0
/
(
1
.
0
+
alpha
);
double
inv
=
1
.
0
/
(
1
.
0
+
alpha
);
b
->
a0
=
inv
*
(
1
.
+
cs
)
/
2
.
;
b
->
a0
=
(
1
.
-
cs
)
*
0
.
5
*
inv
;
b
->
a1
=
-
2
.
*
b
->
a0
;
b
->
a1
=
(
1
.
-
cs
)
*
inv
;
b
->
a2
=
b
->
a0
;
b
->
a2
=
b
->
a0
;
b
->
b1
=
-
2
.
*
cs
*
inv
;
b
->
b1
=
-
2
.
*
cs
*
inv
;
b
->
b2
=
(
1
.
-
alpha
)
*
inv
;
b
->
b2
=
(
1
.
-
alpha
)
*
inv
;
...
@@ -189,18 +174,13 @@ static int config_input(AVFilterLink *inlink)
...
@@ -189,18 +174,13 @@ static int config_input(AVFilterLink *inlink)
for
(
ch
=
0
;
ch
<
inlink
->
channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
inlink
->
channels
;
ch
++
)
{
for
(
band
=
0
;
band
<=
s
->
nb_splits
;
band
++
)
{
for
(
band
=
0
;
band
<=
s
->
nb_splits
;
band
++
)
{
set_lp
(
&
s
->
xover
[
ch
].
lp
[
band
][
0
],
s
->
splits
[
band
],
q
,
sample_rate
);
set_lp
(
&
s
->
xover
[
ch
].
lp
[
band
][
0
],
s
->
splits
[
band
],
q
,
sample_rate
);
set_hp
(
&
s
->
xover
[
ch
].
hp
[
band
][
0
],
s
->
splits
[
band
],
q
,
sample_rate
);
if
(
s
->
order
>
1
)
{
if
(
s
->
order
>
1
)
{
set_lp
(
&
s
->
xover
[
ch
].
lp
[
band
][
1
],
s
->
splits
[
band
],
1
.
34
,
sample_rate
);
set_lp
(
&
s
->
xover
[
ch
].
lp
[
band
][
1
],
s
->
splits
[
band
],
1
.
34
,
sample_rate
);
set_hp
(
&
s
->
xover
[
ch
].
hp
[
band
][
1
],
s
->
splits
[
band
],
1
.
34
,
sample_rate
);
set_lp
(
&
s
->
xover
[
ch
].
lp
[
band
][
2
],
s
->
splits
[
band
],
q
,
sample_rate
);
set_lp
(
&
s
->
xover
[
ch
].
lp
[
band
][
2
],
s
->
splits
[
band
],
q
,
sample_rate
);
set_hp
(
&
s
->
xover
[
ch
].
hp
[
band
][
2
],
s
->
splits
[
band
],
q
,
sample_rate
);
set_lp
(
&
s
->
xover
[
ch
].
lp
[
band
][
3
],
s
->
splits
[
band
],
1
.
34
,
sample_rate
);
set_lp
(
&
s
->
xover
[
ch
].
lp
[
band
][
3
],
s
->
splits
[
band
],
1
.
34
,
sample_rate
);
set_hp
(
&
s
->
xover
[
ch
].
hp
[
band
][
3
],
s
->
splits
[
band
],
1
.
34
,
sample_rate
);
}
else
{
}
else
{
set_lp
(
&
s
->
xover
[
ch
].
lp
[
band
][
1
],
s
->
splits
[
band
],
q
,
sample_rate
);
set_lp
(
&
s
->
xover
[
ch
].
lp
[
band
][
1
],
s
->
splits
[
band
],
q
,
sample_rate
);
set_hp
(
&
s
->
xover
[
ch
].
hp
[
band
][
1
],
s
->
splits
[
band
],
q
,
sample_rate
);
}
}
}
}
}
}
...
@@ -275,23 +255,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -275,23 +255,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
const
double
*
src
=
(
const
double
*
)
in
->
extended_data
[
ch
];
const
double
*
src
=
(
const
double
*
)
in
->
extended_data
[
ch
];
CrossoverChannel
*
xover
=
&
s
->
xover
[
ch
];
CrossoverChannel
*
xover
=
&
s
->
xover
[
ch
];
for
(
band
=
0
;
band
<
ctx
->
nb_outputs
;
band
++
)
{
for
(
i
=
0
;
i
<
in
->
nb_samples
;
i
++
)
{
double
*
dst
=
(
double
*
)
frames
[
band
]
->
extended_data
[
ch
];
double
sample
=
src
[
i
],
lo
,
hi
;
for
(
i
=
0
;
i
<
in
->
nb_samples
;
i
++
)
{
dst
[
i
]
=
src
[
i
];
for
(
f
=
0
;
f
<
s
->
filter_count
;
f
++
)
{
for
(
band
=
0
;
band
<
ctx
->
nb_outputs
;
band
++
)
{
if
(
band
+
1
<
ctx
->
nb_outputs
)
{
double
*
dst
=
(
double
*
)
frames
[
band
]
->
extended_data
[
ch
];
BiquadContext
*
lp
=
&
xover
->
lp
[
band
][
f
];
dst
[
i
]
=
biquad_process
(
lp
,
dst
[
i
]);
}
if
(
band
-
1
>=
0
)
{
lo
=
sample
;
BiquadContext
*
hp
=
&
xover
->
hp
[
band
-
1
][
f
];
for
(
f
=
0
;
band
+
1
<
ctx
->
nb_outputs
&&
f
<
s
->
filter_count
;
f
++
)
{
dst
[
i
]
=
biquad_process
(
hp
,
dst
[
i
])
;
BiquadContext
*
lp
=
&
xover
->
lp
[
band
][
f
]
;
}
lo
=
biquad_process
(
lp
,
lo
);
}
}
hi
=
sample
-
lo
;
dst
[
i
]
=
lo
;
sample
=
hi
;
}
}
}
}
}
}
...
...
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