[FFmpeg-devel] [PATCH 017/281] ads: convert to new channel layout API

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


From: Anton Khirnov <anton at khirnov.net>

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/ads.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/ads.c b/libavformat/ads.c
index e7b419ce8d..ee329bb403 100644
--- a/libavformat/ads.c
+++ b/libavformat/ads.c
@@ -48,11 +48,12 @@ static int ads_read_header(AVFormatContext *s)
     st->codecpar->sample_rate = avio_rl32(s->pb);
     if (st->codecpar->sample_rate <= 0)
         return AVERROR_INVALIDDATA;
-    st->codecpar->channels    = avio_rl32(s->pb);
-    if (st->codecpar->channels <= 0)
+    st->codecpar->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
+    st->codecpar->ch_layout.nb_channels = avio_rl32(s->pb);
+    if (st->codecpar->ch_layout.nb_channels <= 0)
         return AVERROR_INVALIDDATA;
     align                  = avio_rl32(s->pb);
-    if (align <= 0 || align > INT_MAX / st->codecpar->channels)
+    if (align <= 0 || align > INT_MAX / st->codecpar->ch_layout.nb_channels)
         return AVERROR_INVALIDDATA;
 
     if (codec == 1)
@@ -60,11 +61,11 @@ static int ads_read_header(AVFormatContext *s)
     else
         st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
 
-    st->codecpar->block_align = st->codecpar->channels * align;
+    st->codecpar->block_align = st->codecpar->ch_layout.nb_channels * align;
     avio_skip(s->pb, 12);
     size = avio_rl32(s->pb);
     if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_PSX && size >= 0x40)
-        st->duration = (size - 0x40) / 16 / st->codecpar->channels * 28;
+        st->duration = (size - 0x40) / 16 / st->codecpar->ch_layout.nb_channels * 28;
     avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 
     return 0;
-- 
2.34.1



More information about the ffmpeg-devel mailing list