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
e1e0f94d
Commit
e1e0f94d
authored
Apr 24, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_surround: add angle option
parent
e1cfb01b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
filters.texi
doc/filters.texi
+4
-0
af_surround.c
libavfilter/af_surround.c
+25
-0
No files found.
doc/filters.texi
View file @
e1e0f94d
...
@@ -4877,6 +4877,10 @@ In @var{add} mode, LFE channel is created from input audio and added to output.
...
@@ -4877,6 +4877,10 @@ In @var{add} mode, LFE channel is created from input audio and added to output.
In @var{sub} mode, LFE channel is created from input audio and added to output but
In @var{sub} mode, LFE channel is created from input audio and added to output but
also all non-LFE output channels are subtracted with output LFE channel.
also all non-LFE output channels are subtracted with output LFE channel.
@item angle
Set angle of stereo surround transform, Allowed range is from @var{0} to @var{360}.
Default is @var{90}.
@item fc_in
@item fc_in
Set front center input volume. By default, this is @var{1}.
Set front center input volume. By default, this is @var{1}.
...
...
libavfilter/af_surround.c
View file @
e1e0f94d
...
@@ -56,6 +56,7 @@ typedef struct AudioSurroundContext {
...
@@ -56,6 +56,7 @@ typedef struct AudioSurroundContext {
float
lfe_in
;
float
lfe_in
;
float
lfe_out
;
float
lfe_out
;
int
lfe_mode
;
int
lfe_mode
;
float
angle
;
int
win_size
;
int
win_size
;
int
win_func
;
int
win_func
;
float
overlap
;
float
overlap
;
...
@@ -312,6 +313,26 @@ static int config_output(AVFilterLink *outlink)
...
@@ -312,6 +313,26 @@ static int config_output(AVFilterLink *outlink)
return
0
;
return
0
;
}
}
static
void
stereo_transform
(
float
*
x
,
float
*
y
,
float
angle
)
{
float
reference
,
r
,
a
;
if
(
angle
==
90
.
f
)
return
;
reference
=
angle
*
M_PI
/
180
.
f
;
r
=
hypotf
(
*
x
,
*
y
);
a
=
atan2f
(
*
x
,
*
y
);
if
(
fabsf
(
a
)
<=
M_PI_4
)
a
*=
reference
/
M_PI_2
;
else
a
=
M_PI
+
2
*
(
-
2
*
M_PI
+
reference
)
*
(
M_PI
-
fabsf
(
a
))
*
FFDIFFSIGN
(
a
,
0
)
/
(
3
*
M_PI
);
*
x
=
av_clipf
(
sinf
(
a
)
*
r
,
-
1
,
1
);
*
y
=
av_clipf
(
cosf
(
a
)
*
r
,
-
1
,
1
);
}
static
void
stereo_position
(
float
a
,
float
p
,
float
*
x
,
float
*
y
)
static
void
stereo_position
(
float
a
,
float
p
,
float
*
x
,
float
*
y
)
{
{
*
x
=
av_clipf
(
a
+
FFMAX
(
0
,
sinf
(
p
-
M_PI_2
))
*
FFDIFFSIGN
(
a
,
0
),
-
1
,
1
);
*
x
=
av_clipf
(
a
+
FFMAX
(
0
,
sinf
(
p
-
M_PI_2
))
*
FFDIFFSIGN
(
a
,
0
),
-
1
,
1
);
...
@@ -1096,6 +1117,7 @@ static void filter_stereo(AVFilterContext *ctx)
...
@@ -1096,6 +1117,7 @@ static void filter_stereo(AVFilterContext *ctx)
phase_dif
=
2
*
M_PI
-
phase_dif
;
phase_dif
=
2
*
M_PI
-
phase_dif
;
stereo_position
(
mag_dif
,
phase_dif
,
&
x
,
&
y
);
stereo_position
(
mag_dif
,
phase_dif
,
&
x
,
&
y
);
stereo_transform
(
&
x
,
&
y
,
s
->
angle
);
s
->
upmix_stereo
(
ctx
,
l_phase
,
r_phase
,
c_phase
,
mag_total
,
x
,
y
,
n
);
s
->
upmix_stereo
(
ctx
,
l_phase
,
r_phase
,
c_phase
,
mag_total
,
x
,
y
,
n
);
}
}
...
@@ -1131,6 +1153,7 @@ static void filter_surround(AVFilterContext *ctx)
...
@@ -1131,6 +1153,7 @@ static void filter_surround(AVFilterContext *ctx)
phase_dif
=
2
*
M_PI
-
phase_dif
;
phase_dif
=
2
*
M_PI
-
phase_dif
;
stereo_position
(
mag_dif
,
phase_dif
,
&
x
,
&
y
);
stereo_position
(
mag_dif
,
phase_dif
,
&
x
,
&
y
);
stereo_transform
(
&
x
,
&
y
,
s
->
angle
);
s
->
upmix_3_0
(
ctx
,
l_phase
,
r_phase
,
c_phase
,
c_mag
,
mag_total
,
x
,
y
,
n
);
s
->
upmix_3_0
(
ctx
,
l_phase
,
r_phase
,
c_phase
,
c_mag
,
mag_total
,
x
,
y
,
n
);
}
}
...
@@ -1165,6 +1188,7 @@ static void filter_2_1(AVFilterContext *ctx)
...
@@ -1165,6 +1188,7 @@ static void filter_2_1(AVFilterContext *ctx)
phase_dif
=
2
*
M_PI
-
phase_dif
;
phase_dif
=
2
*
M_PI
-
phase_dif
;
stereo_position
(
mag_dif
,
phase_dif
,
&
x
,
&
y
);
stereo_position
(
mag_dif
,
phase_dif
,
&
x
,
&
y
);
stereo_transform
(
&
x
,
&
y
,
s
->
angle
);
s
->
upmix_2_1
(
ctx
,
l_phase
,
r_phase
,
c_phase
,
mag_total
,
lfe_re
,
lfe_im
,
x
,
y
,
n
);
s
->
upmix_2_1
(
ctx
,
l_phase
,
r_phase
,
c_phase
,
mag_total
,
lfe_re
,
lfe_im
,
x
,
y
,
n
);
}
}
...
@@ -1674,6 +1698,7 @@ static const AVOption surround_options[] = {
...
@@ -1674,6 +1698,7 @@ static const AVOption surround_options[] = {
{
"lfe_mode"
,
"set LFE channel mode"
,
OFFSET
(
lfe_mode
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
FLAGS
,
"lfe_mode"
},
{
"lfe_mode"
,
"set LFE channel mode"
,
OFFSET
(
lfe_mode
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1
,
FLAGS
,
"lfe_mode"
},
{
"add"
,
"just add LFE channel"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
1
,
FLAGS
,
"lfe_mode"
},
{
"add"
,
"just add LFE channel"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
0
},
0
,
1
,
FLAGS
,
"lfe_mode"
},
{
"sub"
,
"substract LFE channel with others"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
1
,
FLAGS
,
"lfe_mode"
},
{
"sub"
,
"substract LFE channel with others"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
1
},
0
,
1
,
FLAGS
,
"lfe_mode"
},
{
"angle"
,
"set soundfield transform angle"
,
OFFSET
(
angle
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
90
},
0
,
360
,
FLAGS
},
{
"fc_in"
,
"set front center channel input level"
,
OFFSET
(
fc_in
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
1
},
0
,
10
,
FLAGS
},
{
"fc_in"
,
"set front center channel input level"
,
OFFSET
(
fc_in
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
1
},
0
,
10
,
FLAGS
},
{
"fc_out"
,
"set front center channel output level"
,
OFFSET
(
fc_out
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
1
},
0
,
10
,
FLAGS
},
{
"fc_out"
,
"set front center channel output level"
,
OFFSET
(
fc_out
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
1
},
0
,
10
,
FLAGS
},
{
"fl_in"
,
"set front left channel input level"
,
OFFSET
(
fl_in
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
1
},
0
,
10
,
FLAGS
},
{
"fl_in"
,
"set front left channel input level"
,
OFFSET
(
fl_in
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
1
},
0
,
10
,
FLAGS
},
...
...
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