Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
43226efc
Commit
43226efc
authored
Nov 04, 2023
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_adynamicequalizer: add new structure to hold filtering state
parent
3f890fbf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
22 deletions
+34
-22
adynamicequalizer_template.c
libavfilter/adynamicequalizer_template.c
+17
-18
af_adynamicequalizer.c
libavfilter/af_adynamicequalizer.c
+17
-4
No files found.
libavfilter/adynamicequalizer_template.c
View file @
43226efc
...
...
@@ -166,25 +166,25 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n
for
(
int
ch
=
start
;
ch
<
end
;
ch
++
)
{
const
ftype
*
src
=
(
const
ftype
*
)
in
->
extended_data
[
ch
];
ftype
*
dst
=
(
ftype
*
)
out
->
extended_data
[
ch
];
ftype
*
state
=
(
ftype
*
)
s
->
state
->
extended_data
[
ch
];
const
ftype
threshold
=
detection
==
0
?
state
[
5
]
:
s
->
threshold
;
ftype
fa
[
3
],
fm
[
3
];
ChannelContext
*
cc
=
&
s
->
cc
[
ch
];
const
ftype
threshold
=
detection
==
0
?
fn
(
cc
->
threshold
)
:
s
->
threshold
;
ftype
*
fa
=
fn
(
cc
->
fa
),
*
fm
=
fn
(
cc
->
fm
);
ftype
*
fstate
=
fn
(
cc
->
fstate
);
ftype
*
dstate
=
fn
(
cc
->
dstate
);
ftype
gain
=
fn
(
cc
->
gain
);
if
(
detection
<
0
)
state
[
5
]
=
threshold
;
memcpy
(
fa
,
state
+
8
,
sizeof
(
fa
));
memcpy
(
fm
,
state
+
11
,
sizeof
(
fm
));
fn
(
cc
->
threshold
)
=
threshold
;
for
(
int
n
=
0
;
n
<
out
->
nb_samples
;
n
++
)
{
ftype
detect
,
gain
,
v
,
listen
;
ftype
detect
,
v
,
listen
;
ftype
k
,
g
;
detect
=
listen
=
fn
(
get_svf
)(
src
[
n
],
dm
,
da
,
state
);
detect
=
listen
=
fn
(
get_svf
)(
src
[
n
],
dm
,
da
,
d
state
);
detect
=
FABS
(
detect
);
if
(
detection
>
0
)
state
[
5
]
=
FMAX
(
state
[
5
]
,
detect
);
fn
(
cc
->
threshold
)
=
FMAX
(
fn
(
cc
->
threshold
)
,
detect
);
if
(
mode
>=
0
)
{
if
(
direction
==
0
&&
detect
<
threshold
)
{
...
...
@@ -200,17 +200,17 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n
}
{
ftype
delta
=
detect
-
state
[
4
]
;
ftype
delta
=
detect
-
gain
;
if
(
delta
>
EPSILON
)
detect
=
state
[
4
]
+
attack
*
delta
;
detect
=
gain
+
attack
*
delta
;
else
if
(
delta
<
-
EPSILON
)
detect
=
state
[
4
]
+
release
*
delta
;
detect
=
gain
+
release
*
delta
;
}
}
if
(
state
[
4
]
!=
detect
)
{
state
[
4
]
=
gain
=
detect
;
if
(
gain
!=
detect
)
{
gain
=
detect
;
switch
(
tftype
)
{
case
0
:
...
...
@@ -251,13 +251,12 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n
}
}
v
=
fn
(
get_svf
)(
src
[
n
],
fm
,
fa
,
&
state
[
2
]
);
v
=
fn
(
get_svf
)(
src
[
n
],
fm
,
fa
,
fstate
);
v
=
mode
==
-
1
?
listen
:
v
;
dst
[
n
]
=
ctx
->
is_disabled
?
src
[
n
]
:
v
;
}
memcpy
(
state
+
8
,
fa
,
sizeof
(
fa
));
memcpy
(
state
+
11
,
fm
,
sizeof
(
fm
));
fn
(
cc
->
gain
)
=
gain
;
}
return
0
;
...
...
libavfilter/af_adynamicequalizer.c
View file @
43226efc
...
...
@@ -23,6 +23,19 @@
#include "audio.h"
#include "formats.h"
typedef
struct
ChannelContext
{
double
fa_double
[
3
],
fm_double
[
3
];
double
dstate_double
[
2
];
double
fstate_double
[
2
];
double
gain_double
;
double
threshold_double
;
float
fa_float
[
3
],
fm_float
[
3
];
float
dstate_float
[
2
];
float
fstate_float
[
2
];
float
gain_float
;
float
threshold_float
;
}
ChannelContext
;
typedef
struct
AudioDynamicEqualizerContext
{
const
AVClass
*
class
;
...
...
@@ -52,7 +65,7 @@ typedef struct AudioDynamicEqualizerContext {
double
da_double
[
3
],
dm_double
[
3
];
float
da_float
[
3
],
dm_float
[
3
];
AVFrame
*
state
;
ChannelContext
*
cc
;
}
AudioDynamicEqualizerContext
;
static
int
query_formats
(
AVFilterContext
*
ctx
)
...
...
@@ -96,8 +109,8 @@ static int config_input(AVFilterLink *inlink)
AudioDynamicEqualizerContext
*
s
=
ctx
->
priv
;
s
->
format
=
inlink
->
format
;
s
->
state
=
ff_get_audio_buffer
(
inlink
,
16
);
if
(
!
s
->
state
)
s
->
cc
=
av_calloc
(
inlink
->
ch_layout
.
nb_channels
,
sizeof
(
*
s
->
cc
)
);
if
(
!
s
->
cc
)
return
AVERROR
(
ENOMEM
);
switch
(
s
->
format
)
{
...
...
@@ -148,7 +161,7 @@ static av_cold void uninit(AVFilterContext *ctx)
{
AudioDynamicEqualizerContext
*
s
=
ctx
->
priv
;
av_fr
ame_free
(
&
s
->
state
);
av_fr
eep
(
&
s
->
cc
);
}
#define OFFSET(x) offsetof(AudioDynamicEqualizerContext, 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