diff mbox series

[FFmpeg-devel,046/281] dcstr: convert to new channel layout API

Message ID 20220113015101.4-47-jamrial@gmail.com
State New
Headers show
Series New channel layout API | expand

Commit Message

James Almer Jan. 13, 2022, 1:50 a.m. UTC
From: Anton Khirnov <anton@khirnov.net>

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/dcstr.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/dcstr.c b/libavformat/dcstr.c
index 71dce08bf7..10f41ebf4e 100644
--- a/libavformat/dcstr.c
+++ b/libavformat/dcstr.c
@@ -41,7 +41,8 @@  static int dcstr_read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
 
     st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codecpar->channels    = avio_rl32(s->pb);
+    st->codecpar->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
+    st->codecpar->ch_layout.nb_channels = avio_rl32(s->pb);
     st->codecpar->sample_rate = avio_rl32(s->pb);
     if (st->codecpar->sample_rate <= 0)
         return AVERROR_INVALIDDATA;
@@ -50,14 +51,16 @@  static int dcstr_read_header(AVFormatContext *s)
     avio_skip(s->pb, 4);
     st->duration           = avio_rl32(s->pb);
     mult                   = avio_rl32(s->pb);
-    if (st->codecpar->channels <= 0 || mult <= 0 || mult > INT_MAX / st->codecpar->channels) {
-        av_log(s, AV_LOG_ERROR, "invalid number of channels %d x %d\n", st->codecpar->channels, mult);
+    if (st->codecpar->ch_layout.nb_channels <= 0 || mult <= 0 ||
+        mult > INT_MAX / st->codecpar->ch_layout.nb_channels) {
+        av_log(s, AV_LOG_ERROR, "invalid number of channels %d x %d\n",
+               st->codecpar->ch_layout.nb_channels, mult);
         return AVERROR_INVALIDDATA;
     }
-    st->codecpar->channels *= mult;
-    if (!align || align > INT_MAX / st->codecpar->channels)
+    st->codecpar->ch_layout.nb_channels *= mult;
+    if (!align || align > INT_MAX / st->codecpar->ch_layout.nb_channels)
         return AVERROR_INVALIDDATA;
-    st->codecpar->block_align = align * st->codecpar->channels;
+    st->codecpar->block_align = align * st->codecpar->ch_layout.nb_channels;
 
     switch (codec) {
     case  4: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_AICA;       break;