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
53d25983
Commit
53d25983
authored
May 29, 2019
by
Anton Khirnov
Committed by
James Almer
Mar 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpegaudio: convert to new channel layout API
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
a96c94bb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
13 deletions
+26
-13
mp3_header_decompress_bsf.c
libavcodec/mp3_header_decompress_bsf.c
+1
-1
mpegaudio_parser.c
libavcodec/mpegaudio_parser.c
+2
-1
mpegaudiodec_template.c
libavcodec/mpegaudiodec_template.c
+12
-10
mpegaudioenc_fixed.c
libavcodec/mpegaudioenc_fixed.c
+5
-0
mpegaudioenc_float.c
libavcodec/mpegaudioenc_float.c
+5
-0
mpegaudioenc_template.c
libavcodec/mpegaudioenc_template.c
+1
-1
No files found.
libavcodec/mp3_header_decompress_bsf.c
View file @
53d25983
...
...
@@ -98,7 +98,7 @@ static int mp3_header_decompress(AVBSFContext *ctx, AVPacket *out)
}
memcpy
(
out
->
data
+
frame_size
-
buf_size
,
buf
,
buf_size
+
AV_INPUT_BUFFER_PADDING_SIZE
);
if
(
ctx
->
par_in
->
channels
==
2
){
if
(
ctx
->
par_in
->
ch_layout
.
nb_channels
==
2
){
uint8_t
*
p
=
out
->
data
+
frame_size
-
buf_size
;
if
(
lsf
){
FFSWAP
(
int
,
p
[
1
],
p
[
2
]);
...
...
libavcodec/mpegaudio_parser.c
View file @
53d25983
...
...
@@ -84,7 +84,8 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
if
(
s
->
header_count
>
header_threshold
)
{
avctx
->
sample_rate
=
sr
;
avctx
->
channels
=
channels
;
av_channel_layout_uninit
(
&
avctx
->
ch_layout
);
av_channel_layout_default
(
&
avctx
->
ch_layout
,
channels
);
s1
->
duration
=
frame_size
;
avctx
->
codec_id
=
codec_id
;
if
(
s
->
no_bitrate
||
!
avctx
->
bit_rate
)
{
...
...
libavcodec/mpegaudiodec_template.c
View file @
53d25983
...
...
@@ -1580,8 +1580,9 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
return
AVERROR_INVALIDDATA
;
}
/* update codec info */
avctx
->
channels
=
s
->
nb_channels
;
avctx
->
channel_layout
=
s
->
nb_channels
==
1
?
AV_CH_LAYOUT_MONO
:
AV_CH_LAYOUT_STEREO
;
av_channel_layout_uninit
(
&
avctx
->
ch_layout
);
avctx
->
ch_layout
=
s
->
nb_channels
==
1
?
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_MONO
:
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_STEREO
;
if
(
!
avctx
->
bit_rate
)
avctx
->
bit_rate
=
s
->
bit_rate
;
...
...
@@ -1661,8 +1662,9 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data,
}
/* update codec info */
avctx
->
sample_rate
=
s
->
sample_rate
;
avctx
->
channels
=
s
->
nb_channels
;
avctx
->
channel_layout
=
s
->
nb_channels
==
1
?
AV_CH_LAYOUT_MONO
:
AV_CH_LAYOUT_STEREO
;
av_channel_layout_uninit
(
&
avctx
->
ch_layout
);
avctx
->
ch_layout
=
s
->
nb_channels
==
1
?
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_MONO
:
(
AVChannelLayout
)
AV_CHANNEL_LAYOUT_STEREO
;
if
(
!
avctx
->
bit_rate
)
avctx
->
bit_rate
=
s
->
bit_rate
;
...
...
@@ -1756,8 +1758,8 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx)
}
s
->
frames
=
mp3Frames
[
cfg
.
chan_config
];
s
->
coff
=
chan_offset
[
cfg
.
chan_config
];
av
ctx
->
channels
=
ff_mpeg4audio_channels
[
cfg
.
chan_config
]
;
av
ctx
->
channel_layout
=
chan_layout
[
cfg
.
chan_config
]
;
av
_channel_layout_uninit
(
&
avctx
->
ch_layout
)
;
av
_channel_layout_from_mask
(
&
avctx
->
ch_layout
,
chan_layout
[
cfg
.
chan_config
])
;
if
(
cfg
.
sample_rate
<
16000
)
s
->
syncword
=
0xffe00000
;
...
...
@@ -1854,8 +1856,8 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
return
AVERROR_INVALIDDATA
;
}
if
(
ch
+
m
->
nb_channels
>
avctx
->
channels
||
s
->
coff
[
fr
]
+
m
->
nb_channels
>
avctx
->
channels
)
{
if
(
ch
+
m
->
nb_channels
>
avctx
->
ch
_layout
.
nb_ch
annels
||
s
->
coff
[
fr
]
+
m
->
nb_channels
>
avctx
->
ch
_layout
.
nb_ch
annels
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"frame channel count exceeds codec "
"channel count
\n
"
);
return
AVERROR_INVALIDDATA
;
...
...
@@ -1880,7 +1882,7 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
avctx
->
bit_rate
+=
m
->
bit_rate
;
}
if
(
ch
!=
avctx
->
channels
)
{
if
(
ch
!=
avctx
->
ch
_layout
.
nb_ch
annels
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"failed to decode all channels
\n
"
);
return
AVERROR_INVALIDDATA
;
}
...
...
@@ -1888,7 +1890,7 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
/* update codec info */
avctx
->
sample_rate
=
s
->
mp3decctx
[
0
]
->
sample_rate
;
frame
->
nb_samples
=
out_size
/
(
avctx
->
channels
*
sizeof
(
OUT_INT
));
frame
->
nb_samples
=
out_size
/
(
avctx
->
ch
_layout
.
nb_ch
annels
*
sizeof
(
OUT_INT
));
*
got_frame_ptr
=
1
;
return
buf_size
;
...
...
libavcodec/mpegaudioenc_fixed.c
View file @
53d25983
...
...
@@ -35,9 +35,14 @@ const AVCodec ff_mp2fixed_encoder = {
.
supported_samplerates
=
(
const
int
[]){
44100
,
48000
,
32000
,
22050
,
24000
,
16000
,
0
},
#if FF_API_OLD_CHANNEL_LAYOUT
.
channel_layouts
=
(
const
uint64_t
[]){
AV_CH_LAYOUT_MONO
,
AV_CH_LAYOUT_STEREO
,
0
},
#endif
.
ch_layouts
=
(
const
AVChannelLayout
[]){
AV_CHANNEL_LAYOUT_MONO
,
AV_CHANNEL_LAYOUT_STEREO
,
{
0
}
},
.
defaults
=
mp2_defaults
,
.
caps_internal
=
FF_CODEC_CAP_INIT_THREADSAFE
,
};
libavcodec/mpegaudioenc_float.c
View file @
53d25983
...
...
@@ -36,9 +36,14 @@ const AVCodec ff_mp2_encoder = {
.
supported_samplerates
=
(
const
int
[]){
44100
,
48000
,
32000
,
22050
,
24000
,
16000
,
0
},
#if FF_API_OLD_CHANNEL_LAYOUT
.
channel_layouts
=
(
const
uint64_t
[]){
AV_CH_LAYOUT_MONO
,
AV_CH_LAYOUT_STEREO
,
0
},
#endif
.
ch_layouts
=
(
const
AVChannelLayout
[]){
AV_CHANNEL_LAYOUT_MONO
,
AV_CHANNEL_LAYOUT_STEREO
,
{
0
}
},
.
defaults
=
mp2_defaults
,
.
caps_internal
=
FF_CODEC_CAP_INIT_THREADSAFE
,
};
libavcodec/mpegaudioenc_template.c
View file @
53d25983
...
...
@@ -79,7 +79,7 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx)
MpegAudioContext
*
s
=
avctx
->
priv_data
;
int
freq
=
avctx
->
sample_rate
;
int
bitrate
=
avctx
->
bit_rate
;
int
channels
=
avctx
->
channels
;
int
channels
=
avctx
->
ch
_layout
.
nb_ch
annels
;
int
i
,
v
,
table
;
float
a
;
...
...
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