[FFmpeg-devel] [PATCH 031/281] argo: convert to new channel layout API

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


From: Anton Khirnov <anton at khirnov.net>

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/argo_asf.c | 18 ++++++++----------
 libavformat/argo_cvg.c |  5 ++---
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index 2b3569ebc3..cb598b3e04 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -96,11 +96,9 @@ int ff_argo_asf_fill_stream(AVFormatContext *s, AVStream *st, const ArgoASFFileH
     st->codecpar->format                    = AV_SAMPLE_FMT_S16P;
 
     if (ckhdr->flags & ASF_CF_STEREO) {
-        st->codecpar->channel_layout        = AV_CH_LAYOUT_STEREO;
-        st->codecpar->channels              = 2;
+        st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
     } else {
-        st->codecpar->channel_layout        = AV_CH_LAYOUT_MONO;
-        st->codecpar->channels              = 1;
+        st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
     }
 
     /* v1.1 files (FX Fighter) are all marked as 44100, but are actually 22050. */
@@ -121,11 +119,11 @@ int ff_argo_asf_fill_stream(AVFormatContext *s, AVStream *st, const ArgoASFFileH
      * (nchannel control bytes) + ((bytes_per_channel) * nchannel)
      * For mono, this is 17. For stereo, this is 34.
      */
-    st->codecpar->block_align           = st->codecpar->channels +
+    st->codecpar->block_align           = st->codecpar->ch_layout.nb_channels +
                                           (ckhdr->num_samples / 2) *
-                                          st->codecpar->channels;
+                                          st->codecpar->ch_layout.nb_channels;
 
-    st->codecpar->bit_rate              = st->codecpar->channels *
+    st->codecpar->bit_rate              = st->codecpar->ch_layout.nb_channels *
                                           st->codecpar->sample_rate *
                                           st->codecpar->bits_per_coded_sample;
 
@@ -305,12 +303,12 @@ static int argo_asf_write_init(AVFormatContext *s)
         return AVERROR(EINVAL);
     }
 
-    if (par->channels > 2) {
+    if (par->ch_layout.nb_channels > 2) {
         av_log(s, AV_LOG_ERROR, "ASF files only support up to 2 channels\n");
         return AVERROR(EINVAL);
     }
 
-    if (par->block_align != 17 * par->channels)
+    if (par->block_align != 17 * par->ch_layout.nb_channels)
         return AVERROR(EINVAL);
 
     if (par->sample_rate > UINT16_MAX) {
@@ -392,7 +390,7 @@ static int argo_asf_write_header(AVFormatContext *s)
     chdr.unk2          = ~0;
     chdr.flags         = ASF_CF_BITS_PER_SAMPLE | ASF_CF_ALWAYS1;
 
-    if (par->channels == 2)
+    if (par->ch_layout.nb_channels == 2)
         chdr.flags |= ASF_CF_STEREO;
 
     argo_asf_write_file_header(&fhdr, s->pb);
diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
index e1854b4493..cdf13016a8 100644
--- a/libavformat/argo_cvg.c
+++ b/libavformat/argo_cvg.c
@@ -182,8 +182,7 @@ static int argo_cvg_read_header(AVFormatContext *s)
         break;
     }
 
-    par->channels               = 1;
-    par->channel_layout         = AV_CH_LAYOUT_MONO;
+    par->ch_layout              = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
 
     par->bits_per_coded_sample  = 4;
     par->block_align            = ARGO_CVG_BLOCK_ALIGN;
@@ -275,7 +274,7 @@ static int argo_cvg_write_init(AVFormatContext *s)
         return AVERROR(EINVAL);
     }
 
-    if (par->channels != 1) {
+    if (par->ch_layout.nb_channels != 1) {
         av_log(s, AV_LOG_ERROR, "CVG files only support 1 channel\n");
         return AVERROR(EINVAL);
     }
-- 
2.34.1



More information about the ffmpeg-devel mailing list