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
1a9513bf
Commit
1a9513bf
authored
Oct 16, 2016
by
Muhammad Faiz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/firequalizer: add scale option
Signed-off-by:
Muhammad Faiz
<
mfcc64@gmail.com
>
parent
ad2d2ebd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
filters.texi
doc/filters.texi
+13
-0
af_firequalizer.c
libavfilter/af_firequalizer.c
+30
-3
No files found.
doc/filters.texi
View file @
1a9513bf
...
@@ -2563,6 +2563,19 @@ Enable multichannels evaluation on gain. Default is disabled.
...
@@ -2563,6 +2563,19 @@ Enable multichannels evaluation on gain. Default is disabled.
@item zero_phase
@item zero_phase
Enable zero phase mode by subtracting timestamp to compensate delay.
Enable zero phase mode by subtracting timestamp to compensate delay.
Default is disabled.
Default is disabled.
@item scale
Set scale used by gain. Acceptable values are:
@table @option
@item linlin
linear frequency, linear gain
@item linlog
linear frequency, logarithmic (in dB) gain (default)
@item loglin
logarithmic (in octave scale where 20 Hz is 0) frequency, linear gain
@item loglog
logarithmic frequency, logarithmic gain
@end table
@end table
@end table
@subsection Examples
@subsection Examples
...
...
libavfilter/af_firequalizer.c
View file @
1a9513bf
...
@@ -43,6 +43,14 @@ enum WindowFunc {
...
@@ -43,6 +43,14 @@ enum WindowFunc {
NB_WFUNC
NB_WFUNC
};
};
enum
Scale
{
SCALE_LINLIN
,
SCALE_LINLOG
,
SCALE_LOGLIN
,
SCALE_LOGLOG
,
NB_SCALE
};
#define NB_GAIN_ENTRY_MAX 4096
#define NB_GAIN_ENTRY_MAX 4096
typedef
struct
{
typedef
struct
{
double
freq
;
double
freq
;
...
@@ -84,6 +92,7 @@ typedef struct {
...
@@ -84,6 +92,7 @@ typedef struct {
int
fixed
;
int
fixed
;
int
multi
;
int
multi
;
int
zero_phase
;
int
zero_phase
;
int
scale
;
int
nb_gain_entry
;
int
nb_gain_entry
;
int
gain_entry_err
;
int
gain_entry_err
;
...
@@ -112,6 +121,11 @@ static const AVOption firequalizer_options[] = {
...
@@ -112,6 +121,11 @@ static const AVOption firequalizer_options[] = {
{
"fixed"
,
"set fixed frame samples"
,
OFFSET
(
fixed
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
0
},
0
,
1
,
FLAGS
},
{
"fixed"
,
"set fixed frame samples"
,
OFFSET
(
fixed
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
0
},
0
,
1
,
FLAGS
},
{
"multi"
,
"set multi channels mode"
,
OFFSET
(
multi
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
0
},
0
,
1
,
FLAGS
},
{
"multi"
,
"set multi channels mode"
,
OFFSET
(
multi
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
0
},
0
,
1
,
FLAGS
},
{
"zero_phase"
,
"set zero phase mode"
,
OFFSET
(
zero_phase
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
0
},
0
,
1
,
FLAGS
},
{
"zero_phase"
,
"set zero phase mode"
,
OFFSET
(
zero_phase
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
0
},
0
,
1
,
FLAGS
},
{
"scale"
,
"set gain scale"
,
OFFSET
(
scale
),
AV_OPT_TYPE_INT
,
{
.
i64
=
SCALE_LINLOG
},
0
,
NB_SCALE
-
1
,
FLAGS
,
"scale"
},
{
"linlin"
,
"linear-freq linear-gain"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
SCALE_LINLIN
},
0
,
0
,
FLAGS
,
"scale"
},
{
"linlog"
,
"linear-freq logarithmic-gain"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
SCALE_LINLOG
},
0
,
0
,
FLAGS
,
"scale"
},
{
"loglin"
,
"logarithmic-freq linear-gain"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
SCALE_LOGLIN
},
0
,
0
,
FLAGS
,
"scale"
},
{
"loglog"
,
"logarithmic-freq logarithmic-gain"
,
0
,
AV_OPT_TYPE_CONST
,
{
.
i64
=
SCALE_LOGLOG
},
0
,
0
,
FLAGS
,
"scale"
},
{
NULL
}
{
NULL
}
};
};
...
@@ -316,6 +330,8 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g
...
@@ -316,6 +330,8 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g
double
vars
[
VAR_NB
];
double
vars
[
VAR_NB
];
AVExpr
*
gain_expr
;
AVExpr
*
gain_expr
;
int
ret
,
k
,
center
,
ch
;
int
ret
,
k
,
center
,
ch
;
int
xlog
=
s
->
scale
==
SCALE_LOGLIN
||
s
->
scale
==
SCALE_LOGLOG
;
int
ylog
=
s
->
scale
==
SCALE_LINLOG
||
s
->
scale
==
SCALE_LOGLOG
;
s
->
nb_gain_entry
=
0
;
s
->
nb_gain_entry
=
0
;
s
->
gain_entry_err
=
0
;
s
->
gain_entry_err
=
0
;
...
@@ -340,16 +356,27 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g
...
@@ -340,16 +356,27 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g
vars
[
VAR_CHLAYOUT
]
=
inlink
->
channel_layout
;
vars
[
VAR_CHLAYOUT
]
=
inlink
->
channel_layout
;
vars
[
VAR_SR
]
=
inlink
->
sample_rate
;
vars
[
VAR_SR
]
=
inlink
->
sample_rate
;
for
(
ch
=
0
;
ch
<
inlink
->
channels
;
ch
++
)
{
for
(
ch
=
0
;
ch
<
inlink
->
channels
;
ch
++
)
{
double
result
;
vars
[
VAR_CH
]
=
ch
;
vars
[
VAR_CH
]
=
ch
;
vars
[
VAR_CHID
]
=
av_channel_layout_extract_channel
(
inlink
->
channel_layout
,
ch
);
vars
[
VAR_CHID
]
=
av_channel_layout_extract_channel
(
inlink
->
channel_layout
,
ch
);
vars
[
VAR_F
]
=
0
.
0
;
vars
[
VAR_F
]
=
0
.
0
;
s
->
analysis_buf
[
0
]
=
pow
(
10
.
0
,
0
.
05
*
av_expr_eval
(
gain_expr
,
vars
,
ctx
));
if
(
xlog
)
vars
[
VAR_F
]
=
log2
(
0
.
05
*
vars
[
VAR_F
]);
result
=
av_expr_eval
(
gain_expr
,
vars
,
ctx
);
s
->
analysis_buf
[
0
]
=
ylog
?
pow
(
10
.
0
,
0
.
05
*
result
)
:
result
;
vars
[
VAR_F
]
=
0
.
5
*
inlink
->
sample_rate
;
vars
[
VAR_F
]
=
0
.
5
*
inlink
->
sample_rate
;
s
->
analysis_buf
[
1
]
=
pow
(
10
.
0
,
0
.
05
*
av_expr_eval
(
gain_expr
,
vars
,
ctx
));
if
(
xlog
)
vars
[
VAR_F
]
=
log2
(
0
.
05
*
vars
[
VAR_F
]);
result
=
av_expr_eval
(
gain_expr
,
vars
,
ctx
);
s
->
analysis_buf
[
1
]
=
ylog
?
pow
(
10
.
0
,
0
.
05
*
result
)
:
result
;
for
(
k
=
1
;
k
<
s
->
analysis_rdft_len
/
2
;
k
++
)
{
for
(
k
=
1
;
k
<
s
->
analysis_rdft_len
/
2
;
k
++
)
{
vars
[
VAR_F
]
=
k
*
((
double
)
inlink
->
sample_rate
/
(
double
)
s
->
analysis_rdft_len
);
vars
[
VAR_F
]
=
k
*
((
double
)
inlink
->
sample_rate
/
(
double
)
s
->
analysis_rdft_len
);
s
->
analysis_buf
[
2
*
k
]
=
pow
(
10
.
0
,
0
.
05
*
av_expr_eval
(
gain_expr
,
vars
,
ctx
));
if
(
xlog
)
vars
[
VAR_F
]
=
log2
(
0
.
05
*
vars
[
VAR_F
]);
result
=
av_expr_eval
(
gain_expr
,
vars
,
ctx
);
s
->
analysis_buf
[
2
*
k
]
=
ylog
?
pow
(
10
.
0
,
0
.
05
*
result
)
:
result
;
s
->
analysis_buf
[
2
*
k
+
1
]
=
0
.
0
;
s
->
analysis_buf
[
2
*
k
+
1
]
=
0
.
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