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
c439c6b1
Commit
c439c6b1
authored
Feb 19, 2022
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_headphone: improve stereo hrir support
Until now, in some cases produced output would be wrong.
parent
1372b30d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
af_headphone.c
libavfilter/af_headphone.c
+13
-6
No files found.
libavfilter/af_headphone.c
View file @
c439c6b1
...
...
@@ -82,7 +82,9 @@ typedef struct HeadphoneContext {
int
ir_len
;
int
eof
;
}
hrir_in
[
64
];
uint64_t
map_channel_layout
;
uint64_t
mapping
[
64
];
uint8_t
hrir_map
[
64
];
}
HeadphoneContext
;
static
int
parse_channel_name
(
const
char
*
arg
,
uint64_t
*
rchannel
)
...
...
@@ -118,6 +120,7 @@ static void parse_map(AVFilterContext *ctx)
s
->
mapping
[
s
->
nb_irs
]
=
out_channel
;
s
->
nb_irs
++
;
}
s
->
map_channel_layout
=
used_channels
;
if
(
s
->
hrir_fmt
==
HRIR_MULTI
)
s
->
nb_hrir_inputs
=
1
;
...
...
@@ -262,7 +265,7 @@ static int headphone_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
}
offset
=
i
*
n_fft
;
hrtf_offset
=
hrtf
+
offse
t
;
hrtf_offset
=
hrtf
+
s
->
hrir_map
[
i
]
*
n_ff
t
;
memset
(
fft_in
,
0
,
sizeof
(
AVComplexFloat
)
*
n_fft
);
...
...
@@ -361,6 +364,7 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
struct
HeadphoneContext
*
s
=
ctx
->
priv
;
const
int
ir_len
=
s
->
ir_len
;
int
nb_input_channels
=
ctx
->
inputs
[
0
]
->
channels
;
const
int
nb_hrir_channels
=
s
->
nb_hrir_inputs
==
1
?
ctx
->
inputs
[
1
]
->
channels
:
s
->
nb_hrir_inputs
*
2
;
float
gain_lin
=
expf
((
s
->
gain
-
3
*
nb_input_channels
)
/
20
*
M_LN10
);
AVFrame
*
frame
;
int
ret
=
0
;
...
...
@@ -426,15 +430,15 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
s
->
temp_src
[
0
]
=
av_calloc
(
s
->
air_len
,
sizeof
(
float
));
s
->
temp_src
[
1
]
=
av_calloc
(
s
->
air_len
,
sizeof
(
float
));
s
->
data_ir
[
0
]
=
av_calloc
(
nb_
input
_channels
*
s
->
air_len
,
sizeof
(
*
s
->
data_ir
[
0
]));
s
->
data_ir
[
1
]
=
av_calloc
(
nb_
input
_channels
*
s
->
air_len
,
sizeof
(
*
s
->
data_ir
[
1
]));
s
->
data_ir
[
0
]
=
av_calloc
(
nb_
hrir
_channels
*
s
->
air_len
,
sizeof
(
*
s
->
data_ir
[
0
]));
s
->
data_ir
[
1
]
=
av_calloc
(
nb_
hrir
_channels
*
s
->
air_len
,
sizeof
(
*
s
->
data_ir
[
1
]));
if
(
!
s
->
data_ir
[
0
]
||
!
s
->
data_ir
[
1
]
||
!
s
->
temp_src
[
0
]
||
!
s
->
temp_src
[
1
])
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
}
}
else
{
s
->
data_hrtf
[
0
]
=
av_calloc
(
n_fft
,
sizeof
(
*
s
->
data_hrtf
[
0
])
*
nb_
input
_channels
);
s
->
data_hrtf
[
1
]
=
av_calloc
(
n_fft
,
sizeof
(
*
s
->
data_hrtf
[
1
])
*
nb_
input
_channels
);
s
->
data_hrtf
[
0
]
=
av_calloc
(
n_fft
,
sizeof
(
*
s
->
data_hrtf
[
0
])
*
nb_
hrir
_channels
);
s
->
data_hrtf
[
1
]
=
av_calloc
(
n_fft
,
sizeof
(
*
s
->
data_hrtf
[
1
])
*
nb_
hrir
_channels
);
if
(
!
s
->
data_hrtf
[
0
]
||
!
s
->
data_hrtf
[
1
])
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
...
...
@@ -451,10 +455,12 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
ptr
=
(
float
*
)
frame
->
extended_data
[
0
];
if
(
s
->
hrir_fmt
==
HRIR_STEREO
)
{
int
idx
=
av_get_channel_layout_channel_index
(
inlink
->
channel_layout
,
int
idx
=
av_get_channel_layout_channel_index
(
s
->
map_
channel_layout
,
s
->
mapping
[
i
]);
if
(
idx
<
0
)
continue
;
s
->
hrir_map
[
i
]
=
idx
;
if
(
s
->
type
==
TIME_DOMAIN
)
{
float
*
data_ir_l
=
s
->
data_ir
[
0
]
+
idx
*
s
->
air_len
;
float
*
data_ir_r
=
s
->
data_ir
[
1
]
+
idx
*
s
->
air_len
;
...
...
@@ -486,6 +492,7 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
if
(
idx
<
0
)
continue
;
s
->
hrir_map
[
k
]
=
idx
;
I
=
k
*
2
;
if
(
s
->
type
==
TIME_DOMAIN
)
{
float
*
data_ir_l
=
s
->
data_ir
[
0
]
+
idx
*
s
->
air_len
;
...
...
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