[FFmpeg-devel] [PATCH 128/281] redspark: convert to new channel layout API

James Almer jamrial at gmail.com
Thu Jan 13 03:57:45 EET 2022


From: Anton Khirnov <anton at khirnov.net>

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/redspark.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavformat/redspark.c b/libavformat/redspark.c
index eca182c3a7..f4386d7759 100644
--- a/libavformat/redspark.c
+++ b/libavformat/redspark.c
@@ -97,26 +97,27 @@ static int redspark_read_header(AVFormatContext *s)
     st->duration = bytestream2_get_be32u(&gbc) * 14;
     redspark->samples_count = 0;
     bytestream2_skipu(&gbc, 10);
-    par->channels = bytestream2_get_byteu(&gbc);
-    if (!par->channels) {
+    par->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
+    par->ch_layout.nb_channels = bytestream2_get_byteu(&gbc);
+    if (!par->ch_layout.nb_channels) {
         return AVERROR_INVALIDDATA;
     }
 
-    coef_off = 0x54 + par->channels * 8;
+    coef_off = 0x54 + par->ch_layout.nb_channels * 8;
     if (bytestream2_get_byteu(&gbc)) // Loop flag
         coef_off += 16;
 
-    if (coef_off + par->channels * (32 + 14) > HEADER_SIZE) {
+    if (coef_off + par->ch_layout.nb_channels * (32 + 14) > HEADER_SIZE) {
         return AVERROR_INVALIDDATA;
     }
 
-    if (ff_alloc_extradata(par, 32 * par->channels)) {
+    if (ff_alloc_extradata(par, 32 * par->ch_layout.nb_channels)) {
         return AVERROR_INVALIDDATA;
     }
 
     /* Get the ADPCM table */
     bytestream2_seek(&gbc, coef_off, SEEK_SET);
-    for (i = 0; i < par->channels; i++) {
+    for (i = 0; i < par->ch_layout.nb_channels; i++) {
         if (bytestream2_get_bufferu(&gbc, par->extradata + i * 32, 32) != 32) {
             return AVERROR_INVALIDDATA;
         }
@@ -132,7 +133,7 @@ static int redspark_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     AVCodecParameters *par = s->streams[0]->codecpar;
     RedSparkContext *redspark = s->priv_data;
-    uint32_t size = 8 * par->channels;
+    uint32_t size = 8 * par->ch_layout.nb_channels;
     int ret;
 
     if (avio_feof(s->pb) || redspark->samples_count == s->streams[0]->duration)
-- 
2.34.1



More information about the ffmpeg-devel mailing list