diff mbox series

[FFmpeg-devel,180/279] 8svx: convert to new channel layout API

Message ID 20211208010649.381-20-jamrial@gmail.com
State New
Headers show
Series New channel layout API | expand

Commit Message

James Almer Dec. 8, 2021, 1:06 a.m. UTC
From: Anton Khirnov <anton@khirnov.net>

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>
---
 libavcodec/8svx.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c
index 6ef8cd73fe..6ef7921274 100644
--- a/libavcodec/8svx.c
+++ b/libavcodec/8svx.c
@@ -88,38 +88,39 @@  static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
 {
     EightSvxContext *esc = avctx->priv_data;
     AVFrame *frame       = data;
+    int channels         = avctx->ch_layout.nb_channels;
     int buf_size;
     int ch, ret;
     int hdr_size = 2;
 
     /* decode and interleave the first packet */
     if (!esc->data[0] && avpkt) {
-        int chan_size = avpkt->size / avctx->channels - hdr_size;
+        int chan_size = avpkt->size / channels - hdr_size;
 
-        if (avpkt->size % avctx->channels) {
+        if (avpkt->size % channels) {
             av_log(avctx, AV_LOG_WARNING, "Packet with odd size, ignoring last byte\n");
         }
-        if (avpkt->size < (hdr_size + 1) * avctx->channels) {
+        if (avpkt->size < (hdr_size + 1) * channels) {
             av_log(avctx, AV_LOG_ERROR, "packet size is too small\n");
             return AVERROR_INVALIDDATA;
         }
 
         esc->fib_acc[0] = avpkt->data[1] + 128;
-        if (avctx->channels == 2)
+        if (channels == 2)
             esc->fib_acc[1] = avpkt->data[2+chan_size+1] + 128;
 
         esc->data_idx  = 0;
         esc->data_size = chan_size;
         if (!(esc->data[0] = av_malloc(chan_size)))
             return AVERROR(ENOMEM);
-        if (avctx->channels == 2) {
+        if (channels == 2) {
             if (!(esc->data[1] = av_malloc(chan_size))) {
                 av_freep(&esc->data[0]);
                 return AVERROR(ENOMEM);
             }
         }
         memcpy(esc->data[0], &avpkt->data[hdr_size], chan_size);
-        if (avctx->channels == 2)
+        if (channels == 2)
             memcpy(esc->data[1], &avpkt->data[2*hdr_size+chan_size], chan_size);
     }
     if (!esc->data[0]) {
@@ -139,7 +140,7 @@  static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
-    for (ch = 0; ch < avctx->channels; ch++) {
+    for (ch = 0; ch < channels; ch++) {
         delta_decode(frame->data[ch], &esc->data[ch][esc->data_idx],
                      buf_size, &esc->fib_acc[ch], esc->table);
     }
@@ -148,14 +149,14 @@  static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
 
     *got_frame_ptr = 1;
 
-    return ((avctx->frame_number == 0)*hdr_size + buf_size)*avctx->channels;
+    return ((avctx->frame_number == 0) * hdr_size + buf_size) * channels;
 }
 
 static av_cold int eightsvx_decode_init(AVCodecContext *avctx)
 {
     EightSvxContext *esc = avctx->priv_data;
 
-    if (avctx->channels < 1 || avctx->channels > 2) {
+    if (avctx->ch_layout.nb_channels < 1 || avctx->ch_layout.nb_channels > 2) {
         av_log(avctx, AV_LOG_ERROR, "8SVX does not support more than 2 channels\n");
         return AVERROR_INVALIDDATA;
     }