[FFmpeg-devel] [PATCH 008/244] 3dostr: convert to new channel layout API

Anton Khirnov anton at khirnov.net
Fri Dec 6 12:17:02 EET 2019


---
 libavformat/3dostr.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavformat/3dostr.c b/libavformat/3dostr.c
index 6c49f7589c..bfa52c0da5 100644
--- a/libavformat/3dostr.c
+++ b/libavformat/3dostr.c
@@ -63,15 +63,16 @@ static int threedostr_read_header(AVFormatContext *s)
 
             st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
             st->codecpar->sample_rate = avio_rb32(s->pb);
-            st->codecpar->channels    = avio_rb32(s->pb);
-            if (st->codecpar->channels <= 0)
+            st->codecpar->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
+            st->codecpar->ch_layout.nb_channels = avio_rb32(s->pb);
+            if (st->codecpar->ch_layout.nb_channels <= 0)
                 return AVERROR_INVALIDDATA;
             codec                  = avio_rl32(s->pb);
             avio_skip(s->pb, 4);
             if (ctrl_size == 20 || ctrl_size == 3 || ctrl_size == -1)
-                st->duration       = (avio_rb32(s->pb) - 1) / st->codecpar->channels;
+                st->duration       = (avio_rb32(s->pb) - 1) / st->codecpar->ch_layout.nb_channels;
             else
-                st->duration       = avio_rb32(s->pb) * 16 / st->codecpar->channels;
+                st->duration       = avio_rb32(s->pb) * 16 / st->codecpar->ch_layout.nb_channels;
             size -= 56;
             found_shdr = 1;
             break;
@@ -96,7 +97,7 @@ static int threedostr_read_header(AVFormatContext *s)
     switch (codec) {
     case MKTAG('S','D','X','2'):
         st->codecpar->codec_id    = AV_CODEC_ID_SDX2_DPCM;
-        st->codecpar->block_align = 1 * st->codecpar->channels;
+        st->codecpar->block_align = 1 * st->codecpar->ch_layout.nb_channels;
         break;
     default:
         avpriv_request_sample(s, "codec %X", codec);
@@ -142,7 +143,7 @@ static int threedostr_read_packet(AVFormatContext *s, AVPacket *pkt)
             ret = av_get_packet(s->pb, pkt, size);
             pkt->pos = pos;
             pkt->stream_index = 0;
-            pkt->duration = size / st->codecpar->channels;
+            pkt->duration = size / st->codecpar->ch_layout.nb_channels;
             size = 0;
             found_ssmp = 1;
             break;
-- 
2.24.0



More information about the ffmpeg-devel mailing list