Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
4k
Issue boards
Milestones
Code
Merge requests
453
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC
Commits
496f0f2a
Commit
496f0f2a
authored
1 year ago
by
Ilkka Ollakka
Committed by
Jean-Baptiste Kempf
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
avcodec: audio decoder to use ch_layout
parent
bddf5ba1
No related branches found
Branches containing commit
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/codec/avcodec/audio.c
+34
-8
34 additions, 8 deletions
modules/codec/avcodec/audio.c
with
34 additions
and
8 deletions
modules/codec/avcodec/audio.c
+
34
−
8
View file @
496f0f2a
...
@@ -138,7 +138,11 @@ static int OpenAudioCodec( decoder_t *p_dec )
...
@@ -138,7 +138,11 @@ static int OpenAudioCodec( decoder_t *p_dec )
}
}
ctx
->
sample_rate
=
p_dec
->
fmt_in
->
audio
.
i_rate
;
ctx
->
sample_rate
=
p_dec
->
fmt_in
->
audio
.
i_rate
;
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
av_channel_layout_default
(
&
ctx
->
ch_layout
,
p_dec
->
fmt_in
->
audio
.
i_channels
);
#else
ctx
->
channels
=
p_dec
->
fmt_in
->
audio
.
i_channels
;
ctx
->
channels
=
p_dec
->
fmt_in
->
audio
.
i_channels
;
#endif
ctx
->
block_align
=
p_dec
->
fmt_in
->
audio
.
i_blockalign
;
ctx
->
block_align
=
p_dec
->
fmt_in
->
audio
.
i_blockalign
;
ctx
->
bit_rate
=
p_dec
->
fmt_in
->
i_bitrate
;
ctx
->
bit_rate
=
p_dec
->
fmt_in
->
i_bitrate
;
ctx
->
bits_per_coded_sample
=
p_dec
->
fmt_in
->
audio
.
i_bitspersample
;
ctx
->
bits_per_coded_sample
=
p_dec
->
fmt_in
->
audio
.
i_bitspersample
;
...
@@ -403,12 +407,17 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
...
@@ -403,12 +407,17 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
ret
=
avcodec_receive_frame
(
ctx
,
frame
);
ret
=
avcodec_receive_frame
(
ctx
,
frame
);
if
(
ret
==
0
)
if
(
ret
==
0
)
{
{
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
int
channels
=
frame
->
ch_layout
.
nb_channels
;
#else
int
channels
=
ctx
->
channels
;
#endif
/* checks and init from first decoded frame */
/* checks and init from first decoded frame */
if
(
ctx
->
channels
<=
0
||
ctx
->
channels
>
INPUT_CHAN_MAX
if
(
channels
<=
0
||
channels
>
INPUT_CHAN_MAX
||
ctx
->
sample_rate
<=
0
)
||
ctx
->
sample_rate
<=
0
)
{
{
msg_Warn
(
p_dec
,
"invalid audio properties channels count %d, sample rate %d"
,
msg_Warn
(
p_dec
,
"invalid audio properties channels count %d, sample rate %d"
,
ctx
->
channels
,
ctx
->
sample_rate
);
channels
,
ctx
->
sample_rate
);
goto
drop
;
goto
drop
;
}
}
else
if
(
p_dec
->
fmt_out
.
audio
.
i_rate
!=
(
unsigned
int
)
ctx
->
sample_rate
)
else
if
(
p_dec
->
fmt_out
.
audio
.
i_rate
!=
(
unsigned
int
)
ctx
->
sample_rate
)
...
@@ -588,6 +597,16 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
...
@@ -588,6 +597,16 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
p_dec
->
fmt_out
.
audio
.
i_rate
=
p_sys
->
p_context
->
sample_rate
;
p_dec
->
fmt_out
.
audio
.
i_rate
=
p_sys
->
p_context
->
sample_rate
;
/* */
/* */
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
if
(
p_sys
->
i_previous_channels
==
p_sys
->
p_context
->
ch_layout
.
nb_channels
&&
p_sys
->
i_previous_layout
==
p_sys
->
p_context
->
ch_layout
.
u
.
mask
)
return
;
if
(
b_trust
)
{
p_sys
->
i_previous_channels
=
p_sys
->
p_context
->
ch_layout
.
nb_channels
;
p_sys
->
i_previous_layout
=
p_sys
->
p_context
->
ch_layout
.
u
.
mask
;
}
#else
if
(
p_sys
->
i_previous_channels
==
p_sys
->
p_context
->
channels
&&
if
(
p_sys
->
i_previous_channels
==
p_sys
->
p_context
->
channels
&&
p_sys
->
i_previous_layout
==
p_sys
->
p_context
->
channel_layout
)
p_sys
->
i_previous_layout
==
p_sys
->
p_context
->
channel_layout
)
return
;
return
;
...
@@ -596,25 +615,32 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
...
@@ -596,25 +615,32 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
p_sys
->
i_previous_channels
=
p_sys
->
p_context
->
channels
;
p_sys
->
i_previous_channels
=
p_sys
->
p_context
->
channels
;
p_sys
->
i_previous_layout
=
p_sys
->
p_context
->
channel_layout
;
p_sys
->
i_previous_layout
=
p_sys
->
p_context
->
channel_layout
;
}
}
#endif
const
unsigned
i_order_max
=
sizeof
(
pi_channels_map
)
/
sizeof
(
*
pi_channels_map
);
const
unsigned
i_order_max
=
sizeof
(
pi_channels_map
)
/
sizeof
(
*
pi_channels_map
);
uint32_t
pi_order_src
[
i_order_max
];
uint32_t
pi_order_src
[
i_order_max
];
int
i_channels_src
=
0
;
int
i_channels_src
=
0
;
uint64_t
channel_layout
=
#if LIBAVCODEC_VERSION_CHECK(59, 24, 100)
uint64_t
channel_layout_mask
=
p_sys
->
p_context
->
ch_layout
.
u
.
mask
;
int
channel_count
=
p_sys
->
p_context
->
ch_layout
.
nb_channels
;
#else
uint64_t
channel_layout_mask
=
p_sys
->
p_context
->
channel_layout
?
p_sys
->
p_context
->
channel_layout
:
p_sys
->
p_context
->
channel_layout
?
p_sys
->
p_context
->
channel_layout
:
(
uint64_t
)
av_get_default_channel_layout
(
p_sys
->
p_context
->
channels
);
(
uint64_t
)
av_get_default_channel_layout
(
p_sys
->
p_context
->
channels
);
int
channel_count
=
p_sys
->
p_context
->
channels
;
#endif
if
(
channel_layout
)
if
(
channel_layout
_mask
)
{
{
for
(
unsigned
i
=
0
;
i
<
i_order_max
for
(
unsigned
i
=
0
;
i
<
i_order_max
&&
i_channels_src
<
p_dec
->
fmt_out
.
audio
.
i_
channel
s
;
i
++
)
&&
i_channels_src
<
channel
_count
;
i
++
)
{
{
if
(
channel_layout
&
pi_channels_map
[
i
][
0
]
)
if
(
channel_layout
_mask
&
pi_channels_map
[
i
][
0
]
)
pi_order_src
[
i_channels_src
++
]
=
pi_channels_map
[
i
][
1
];
pi_order_src
[
i_channels_src
++
]
=
pi_channels_map
[
i
][
1
];
}
}
if
(
i_channels_src
!=
p_dec
->
fmt_out
.
audio
.
i_
channel
s
&&
b_trust
)
if
(
i_channels_src
!=
channel
_count
&&
b_trust
)
msg_Err
(
p_dec
,
"Channel layout not understood"
);
msg_Err
(
p_dec
,
"Channel layout not understood"
);
/* Detect special dual mono case */
/* Detect special dual mono case */
...
@@ -646,7 +672,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
...
@@ -646,7 +672,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
{
{
msg_Warn
(
p_dec
,
"no channel layout found"
);
msg_Warn
(
p_dec
,
"no channel layout found"
);
p_dec
->
fmt_out
.
audio
.
i_physical_channels
=
0
;
p_dec
->
fmt_out
.
audio
.
i_physical_channels
=
0
;
p_dec
->
fmt_out
.
audio
.
i_channels
=
p_sys
->
p_context
->
channel
s
;
p_dec
->
fmt_out
.
audio
.
i_channels
=
channel
_count
;
}
}
aout_FormatPrepare
(
&
p_dec
->
fmt_out
.
audio
);
aout_FormatPrepare
(
&
p_dec
->
fmt_out
.
audio
);
...
...
This diff is collapsed.
Click to expand it.
Robert-André Mauchin
@eclipseo
mentioned in issue
#28605 (closed)
·
10 months ago
mentioned in issue
#28605 (closed)
mentioned in issue #28605
Toggle commit list
Steve Lhomme
@robUx4
mentioned in merge request
!5574 (merged)
·
9 months ago
mentioned in merge request
!5574 (merged)
mentioned in merge request !5574
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment