[FFmpeg-devel] [PATCH 025/281] amr: convert to new channel layout API

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


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

Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
Signed-off-by: Anton Khirnov <anton at khirnov.net>
Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/amr.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/libavformat/amr.c b/libavformat/amr.c
index bc22c2f84f..91322976ec 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -100,33 +100,33 @@ static int amr_read_header(AVFormatContext *s)
         st->codecpar->codec_tag   = MKTAG('s', 'a', 'm', 'r');
         st->codecpar->codec_id    = AV_CODEC_ID_AMR_NB;
         st->codecpar->sample_rate = 8000;
-        st->codecpar->channels = 1;
-        st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+        st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
         back = read - sizeof(AMR_header);
     } else if (!memcmp(header, AMRWB_header, sizeof(AMRWB_header))) {
         st->codecpar->codec_tag   = MKTAG('s', 'a', 'w', 'b');
         st->codecpar->codec_id    = AV_CODEC_ID_AMR_WB;
         st->codecpar->sample_rate = 16000;
-        st->codecpar->channels = 1;
-        st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+        st->codecpar->ch_layout      = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
         back = read - sizeof(AMRWB_header);
     } else if (!memcmp(header, AMRMC_header, sizeof(AMRMC_header))) {
         st->codecpar->codec_tag   = MKTAG('s', 'a', 'm', 'r');
         st->codecpar->codec_id    = AV_CODEC_ID_AMR_NB;
         st->codecpar->sample_rate = 8000;
-        st->codecpar->channels    = AV_RL32(header + 12);
+        st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
+        st->codecpar->ch_layout.nb_channels = AV_RL32(header + 12);
         back = read - 4 - sizeof(AMRMC_header);
     } else if (!memcmp(header, AMRWBMC_header, sizeof(AMRWBMC_header))) {
         st->codecpar->codec_tag   = MKTAG('s', 'a', 'w', 'b');
         st->codecpar->codec_id    = AV_CODEC_ID_AMR_WB;
         st->codecpar->sample_rate = 16000;
-        st->codecpar->channels    = AV_RL32(header + 15);
+        st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
+        st->codecpar->ch_layout.nb_channels = AV_RL32(header + 15);
         back = read - 4 - sizeof(AMRWBMC_header);
     } else {
         return AVERROR_INVALIDDATA;
     }
 
-    if (st->codecpar->channels < 1)
+    if (st->codecpar->ch_layout.nb_channels < 1)
         return AVERROR_INVALIDDATA;
 
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -188,8 +188,7 @@ static int amrnb_read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
     st->codecpar->codec_id       = AV_CODEC_ID_AMR_NB;
     st->codecpar->sample_rate    = 8000;
-    st->codecpar->channels       = 1;
-    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+    st->codecpar->ch_layout      = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
     st->codecpar->codec_type     = AVMEDIA_TYPE_AUDIO;
     ffstream(st)->need_parsing   = AVSTREAM_PARSE_FULL_RAW;
     avpriv_set_pts_info(st, 64, 1, 8000);
@@ -246,8 +245,7 @@ static int amrwb_read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
     st->codecpar->codec_id       = AV_CODEC_ID_AMR_WB;
     st->codecpar->sample_rate    = 16000;
-    st->codecpar->channels       = 1;
-    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+    st->codecpar->ch_layout      = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
     st->codecpar->codec_type     = AVMEDIA_TYPE_AUDIO;
     ffstream(st)->need_parsing   = AVSTREAM_PARSE_FULL_RAW;
     avpriv_set_pts_info(st, 64, 1, 16000);
-- 
2.34.1



More information about the ffmpeg-devel mailing list