diff mbox series

[FFmpeg-devel,021/281] aiff: convert to new channel layout API

Message ID 20220113015101.4-22-jamrial@gmail.com
State New
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_ppc success Make finished
andriy/make_fate_ppc success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson 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: Vittorio Giovara <vittorio.giovara@gmail.com>

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/aiffdec.c | 13 ++++++++-----
 libavformat/aiffenc.c |  8 ++++----
 2 files changed, 12 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 7afadeb085..c56949bef9 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -99,6 +99,7 @@  static int get_aiff_header(AVFormatContext *s, int size,
     uint64_t val;
     int sample_rate;
     unsigned int num_frames;
+    int channels;
 
     if (size == INT_MAX)
         return AVERROR_INVALIDDATA;
@@ -106,7 +107,9 @@  static int get_aiff_header(AVFormatContext *s, int size,
     if (size & 1)
         size++;
     par->codec_type = AVMEDIA_TYPE_AUDIO;
-    par->channels = avio_rb16(pb);
+    channels = avio_rb16(pb);
+    par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
+    par->ch_layout.nb_channels = channels;
     num_frames = avio_rb32(pb);
     par->bits_per_coded_sample = avio_rb16(pb);
 
@@ -154,10 +157,10 @@  static int get_aiff_header(AVFormatContext *s, int size,
             aiff->block_duration = 1;
             break;
         case AV_CODEC_ID_ADPCM_IMA_QT:
-            par->block_align = 34 * par->channels;
+            par->block_align = 34 * channels;
             break;
         case AV_CODEC_ID_MACE3:
-            par->block_align = 2 * par->channels;
+            par->block_align = 2 * channels;
             break;
         case AV_CODEC_ID_ADPCM_G726LE:
             par->bits_per_coded_sample = 5;
@@ -165,7 +168,7 @@  static int get_aiff_header(AVFormatContext *s, int size,
         case AV_CODEC_ID_ADPCM_G722:
         case AV_CODEC_ID_MACE6:
         case AV_CODEC_ID_SDX2_DPCM:
-            par->block_align = 1 * par->channels;
+            par->block_align = 1 * channels;
             break;
         case AV_CODEC_ID_GSM:
             par->block_align = 33;
@@ -182,7 +185,7 @@  static int get_aiff_header(AVFormatContext *s, int size,
     /* Block align needs to be computed in all cases, as the definition
      * is specific to applications -> here we use the WAVE format definition */
     if (!par->block_align)
-        par->block_align = (av_get_bits_per_sample(par->codec_id) * par->channels) >> 3;
+        par->block_align = (av_get_bits_per_sample(par->codec_id) * channels) >> 3;
 
     if (aiff->block_duration) {
         par->bit_rate = av_rescale(par->sample_rate, par->block_align * 8LL,
diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 1fd6b8a70b..bdaf5c2c3e 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -144,10 +144,10 @@  static int aiff_write_header(AVFormatContext *s)
         avio_wb32(pb, 0xA2805140);
     }
 
-    if (par->channels > 2 && par->channel_layout) {
+    if (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE && par->ch_layout.nb_channels > 2) {
         ffio_wfourcc(pb, "CHAN");
         avio_wb32(pb, 12);
-        ff_mov_write_chan(pb, par->channel_layout);
+        ff_mov_write_chan(pb, par->ch_layout.u.mask);
     }
 
     put_meta(s, "title",     MKTAG('N', 'A', 'M', 'E'));
@@ -158,7 +158,7 @@  static int aiff_write_header(AVFormatContext *s)
     /* Common chunk */
     ffio_wfourcc(pb, "COMM");
     avio_wb32(pb, aifc ? 24 : 18); /* size */
-    avio_wb16(pb, par->channels);  /* Number of channels */
+    avio_wb16(pb, par->ch_layout.nb_channels);  /* Number of channels */
 
     aiff->frames = avio_tell(pb);
     avio_wb32(pb, 0);              /* Number of frames */
@@ -170,7 +170,7 @@  static int aiff_write_header(AVFormatContext *s)
         return AVERROR(EINVAL);
     }
     if (!par->block_align)
-        par->block_align = (par->bits_per_coded_sample * par->channels) >> 3;
+        par->block_align = (par->bits_per_coded_sample * par->ch_layout.nb_channels) >> 3;
 
     avio_wb16(pb, par->bits_per_coded_sample); /* Sample size */