diff mbox series

[FFmpeg-devel,062/281] fsb: convert to new channel layout API

Message ID 20220113015101.4-63-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
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson fail Make fate failed
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

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/fsb.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/fsb.c b/libavformat/fsb.c
index 9e8b9ca6b1..3faae6974b 100644
--- a/libavformat/fsb.c
+++ b/libavformat/fsb.c
@@ -68,30 +68,31 @@  static int fsb_read_header(AVFormatContext *s)
         if (par->sample_rate <= 0)
             return AVERROR_INVALIDDATA;
         avio_skip(pb, 6);
-        par->channels    = avio_rl16(pb);
-        if (!par->channels)
+        par->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
+        par->ch_layout.nb_channels = avio_rl16(pb);
+        if (!par->ch_layout.nb_channels)
             return AVERROR_INVALIDDATA;
 
         if (format & 0x00000100) {
             par->codec_id    = AV_CODEC_ID_PCM_S16LE;
-            par->block_align = 4096 * par->channels;
+            par->block_align = 4096 * par->ch_layout.nb_channels;
         } else if (format & 0x00400000) {
             par->bits_per_coded_sample = 4;
             par->codec_id    = AV_CODEC_ID_ADPCM_IMA_WAV;
-            par->block_align = 36 * par->channels;
+            par->block_align = 36 * par->ch_layout.nb_channels;
         } else if (format & 0x00800000) {
             par->codec_id    = AV_CODEC_ID_ADPCM_PSX;
-            par->block_align = 16 * par->channels;
+            par->block_align = 16 * par->ch_layout.nb_channels;
         } else if (format & 0x02000000) {
             par->codec_id    = AV_CODEC_ID_ADPCM_THP;
-            par->block_align = 8 * par->channels;
-            if (par->channels > INT_MAX / 32)
+            par->block_align = 8 * par->ch_layout.nb_channels;
+            if (par->ch_layout.nb_channels > INT_MAX / 32)
                 return AVERROR_INVALIDDATA;
-            ret = ff_alloc_extradata(par, 32 * par->channels);
+            ret = ff_alloc_extradata(par, 32 * par->ch_layout.nb_channels);
             if (ret < 0)
                 return ret;
             avio_seek(pb, 0x68, SEEK_SET);
-            for (c = 0; c < par->channels; c++) {
+            for (c = 0; c < par->ch_layout.nb_channels; c++) {
                 avio_read(pb, par->extradata + 32 * c, 32);
                 avio_skip(pb, 14);
             }
@@ -125,8 +126,9 @@  static int fsb_read_header(AVFormatContext *s)
             return AVERROR_INVALIDDATA;
         avio_skip(pb, 6);
 
-        par->channels    = avio_rl16(pb);
-        if (!par->channels)
+        par->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
+        par->ch_layout.nb_channels = avio_rl16(pb);
+        if (!par->ch_layout.nb_channels)
             return AVERROR_INVALIDDATA;
 
         switch (par->codec_id) {
@@ -138,17 +140,17 @@  static int fsb_read_header(AVFormatContext *s)
             par->block_align = 2048;
             break;
         case AV_CODEC_ID_ADPCM_THP:
-            if (par->channels > INT_MAX / 32)
+            if (par->ch_layout.nb_channels > INT_MAX / 32)
                 return AVERROR_INVALIDDATA;
-            ret = ff_alloc_extradata(par, 32 * par->channels);
+            ret = ff_alloc_extradata(par, 32 * par->ch_layout.nb_channels);
             if (ret < 0)
                 return ret;
             avio_seek(pb, 0x80, SEEK_SET);
-            for (c = 0; c < par->channels; c++) {
+            for (c = 0; c < par->ch_layout.nb_channels; c++) {
                 avio_read(pb, par->extradata + 32 * c, 32);
                 avio_skip(pb, 14);
             }
-            par->block_align = 8 * par->channels;
+            par->block_align = 8 * par->ch_layout.nb_channels;
             break;
         }
     } else {
@@ -174,14 +176,14 @@  static int fsb_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     pos = avio_tell(s->pb);
     if (par->codec_id == AV_CODEC_ID_ADPCM_THP &&
-               par->channels > 1) {
+        par->ch_layout.nb_channels > 1) {
         int i, ch;
 
         ret = av_new_packet(pkt, par->block_align);
         if (ret < 0)
             return ret;
         for (i = 0; i < 4; i++) {
-            for (ch = 0; ch < par->channels; ch++) {
+            for (ch = 0; ch < par->ch_layout.nb_channels; ch++) {
                 pkt->data[ch * 8 + i * 2 + 0] = avio_r8(s->pb);
                 pkt->data[ch * 8 + i * 2 + 1] = avio_r8(s->pb);
             }