diff mbox series

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

Message ID 20220113015101.4-32-jamrial@gmail.com
State Accepted
Commit 521cca1333852cc46682cc78d40ae51d10bc14a5
Headers show
Series New channel layout API | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

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

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

Patch

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);
     }