[FFmpeg-devel] [PATCH 102/281] mpegenc: convert to new channel layout API

James Almer jamrial at gmail.com
Thu Jan 13 03:55:55 EET 2022


From: Vittorio Giovara <vittorio.giovara at gmail.com>

Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/mpegenc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index b1d8bf9c38..3b5aefeb30 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -380,14 +380,14 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
                     av_log(ctx, AV_LOG_INFO, "\n");
                     return AVERROR(EINVAL);
                 }
-                if (st->codecpar->channels > 8) {
+                if (st->codecpar->ch_layout.nb_channels > 8) {
                     av_log(ctx, AV_LOG_ERROR, "At most 8 channels allowed for LPCM streams.\n");
                     return AVERROR(EINVAL);
                 }
                 stream->lpcm_header[0] = 0x0c;
-                stream->lpcm_header[1] = (st->codecpar->channels - 1) | (j << 4);
+                stream->lpcm_header[1] = (st->codecpar->ch_layout.nb_channels - 1) | (j << 4);
                 stream->lpcm_header[2] = 0x80;
-                stream->lpcm_align     = st->codecpar->channels * 2;
+                stream->lpcm_align     = st->codecpar->ch_layout.nb_channels * 2;
             } else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD) {
                 int freq;
 
@@ -404,10 +404,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
                 stream->lpcm_header[0] = 0x0c;
                 stream->lpcm_header[1] = (freq << 4) |
                                          (((st->codecpar->bits_per_coded_sample - 16) / 4) << 6) |
-                                         st->codecpar->channels - 1;
+                                         st->codecpar->ch_layout.nb_channels - 1;
                 stream->lpcm_header[2] = 0x80;
                 stream->id = lpcm_id++;
-                stream->lpcm_align = st->codecpar->channels * st->codecpar->bits_per_coded_sample / 8;
+                stream->lpcm_align = st->codecpar->ch_layout.nb_channels * st->codecpar->bits_per_coded_sample / 8;
             } else if (st->codecpar->codec_id == AV_CODEC_ID_MLP ||
                        st->codecpar->codec_id == AV_CODEC_ID_TRUEHD) {
                        av_log(ctx, AV_LOG_ERROR, "Support for muxing audio codec %s not implemented.\n",
-- 
2.34.1



More information about the ffmpeg-devel mailing list