summaryrefslogtreecommitdiff
path: root/libavcodec/libmp3lame.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-06-03 17:54:20 +0200
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:42 -0300
commit9b3130c88639fa63e8efc8edf57a7efaa368a86d (patch)
tree939cd139d19ec2459724559ea91f5eb533fbd6c1 /libavcodec/libmp3lame.c
parent5359381864b57967341774cbaea896b20b946c84 (diff)
downloadffmpeg-9b3130c88639fa63e8efc8edf57a7efaa368a86d.tar.gz
libmp3lame: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/libmp3lame.c')
-rw-r--r--libavcodec/libmp3lame.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
index e8082fade3..8d296d7ea4 100644
--- a/libavcodec/libmp3lame.c
+++ b/libavcodec/libmp3lame.c
@@ -101,8 +101,9 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
- lame_set_num_channels(s->gfp, avctx->channels);
- lame_set_mode(s->gfp, avctx->channels > 1 ? s->joint_stereo ? JOINT_STEREO : STEREO : MONO);
+ lame_set_num_channels(s->gfp, avctx->ch_layout.nb_channels);
+ lame_set_mode(s->gfp, avctx->ch_layout.nb_channels > 1 ?
+ s->joint_stereo ? JOINT_STEREO : STEREO : MONO);
/* sample rate */
lame_set_in_samplerate (s->gfp, avctx->sample_rate);
@@ -151,7 +152,7 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
/* allocate float sample buffers */
if (avctx->sample_fmt == AV_SAMPLE_FMT_FLTP) {
int ch;
- for (ch = 0; ch < avctx->channels; ch++) {
+ for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
s->samples_flt[ch] = av_malloc_array(avctx->frame_size,
sizeof(*s->samples_flt[ch]));
if (!s->samples_flt[ch]) {
@@ -208,7 +209,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
av_log(avctx, AV_LOG_ERROR, "inadequate AVFrame plane padding\n");
return AVERROR(EINVAL);
}
- for (ch = 0; ch < avctx->channels; ch++) {
+ for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
s->fdsp->vector_fmul_scalar(s->samples_flt[ch],
(const float *)frame->data[ch],
32768.0f,
@@ -343,9 +344,15 @@ const AVCodec ff_libmp3lame_encoder = {
AV_SAMPLE_FMT_S16P,
AV_SAMPLE_FMT_NONE },
.supported_samplerates = libmp3lame_sample_rates,
+#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 },
+ },
.priv_class = &libmp3lame_class,
.defaults = libmp3lame_defaults,
.wrapper_name = "libmp3lame",