diff mbox series

[FFmpeg-devel,018/281] adxdec: convert to new channel layout API

Message ID 20220113015101.4-19-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
yinshiyou/makeloongarch64 warning New warnings during build
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/adxdec.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/adxdec.c b/libavformat/adxdec.c
index d91d43d114..fa91080f41 100644
--- a/libavformat/adxdec.c
+++ b/libavformat/adxdec.c
@@ -56,12 +56,12 @@  static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
     if (avio_feof(s->pb))
         return AVERROR_EOF;
 
-    if (par->channels <= 0) {
-        av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels);
+    if (par->ch_layout.nb_channels <= 0) {
+        av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->ch_layout.nb_channels);
         return AVERROR_INVALIDDATA;
     }
 
-    size = BLOCK_SIZE * par->channels;
+    size = BLOCK_SIZE * par->ch_layout.nb_channels;
 
     pkt->pos = avio_tell(s->pb);
     pkt->stream_index = 0;
@@ -79,8 +79,8 @@  static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
         size = ret;
     }
 
-    pkt->duration = size / (BLOCK_SIZE * par->channels);
-    pkt->pts      = (pkt->pos - c->header_size) / (BLOCK_SIZE * par->channels);
+    pkt->duration = size / (BLOCK_SIZE * par->ch_layout.nb_channels);
+    pkt->pts      = (pkt->pos - c->header_size) / (BLOCK_SIZE * par->ch_layout.nb_channels);
 
     return 0;
 }
@@ -90,6 +90,8 @@  static int adx_read_header(AVFormatContext *s)
     ADXDemuxerContext *c = s->priv_data;
     AVCodecParameters *par;
     int ret;
+    int channels;
+
     AVStream *st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
@@ -107,11 +109,11 @@  static int adx_read_header(AVFormatContext *s)
         av_log(s, AV_LOG_ERROR, "Invalid extradata size.\n");
         return AVERROR_INVALIDDATA;
     }
-    par->channels    = AV_RB8 (par->extradata + 7);
+    channels = AV_RB8 (par->extradata + 7);
     par->sample_rate = AV_RB32(par->extradata + 8);
 
-    if (par->channels <= 0) {
-        av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels);
+    if (channels <= 0) {
+        av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", channels);
         return AVERROR_INVALIDDATA;
     }
 
@@ -120,9 +122,11 @@  static int adx_read_header(AVFormatContext *s)
         return AVERROR_INVALIDDATA;
     }
 
+    par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
+    par->ch_layout.nb_channels = channels;
     par->codec_type  = AVMEDIA_TYPE_AUDIO;
     par->codec_id    = s->iformat->raw_codec_id;
-    par->bit_rate    = (int64_t)par->sample_rate * par->channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES;
+    par->bit_rate    = (int64_t)par->sample_rate * par->ch_layout.nb_channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES;
 
     avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate);