[FFmpeg-devel] [PATCH 261/281] speex: convert to new channel layout API

James Almer jamrial at gmail.com
Thu Jan 13 04:07:05 EET 2022


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/speexdec.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
index dcbdf5e010..7b482f5390 100644
--- a/libavcodec/speexdec.c
+++ b/libavcodec/speexdec.c
@@ -1450,7 +1450,7 @@ static av_cold int speex_decode_init(AVCodecContext *avctx)
         if (s->rate <= 0)
             return AVERROR_INVALIDDATA;
 
-        s->nb_channels = avctx->channels;
+        s->nb_channels = avctx->ch_layout.nb_channels;
         if (s->nb_channels <= 0)
             return AVERROR_INVALIDDATA;
 
@@ -1492,7 +1492,9 @@ static av_cold int speex_decode_init(AVCodecContext *avctx)
 
     if (s->bitrate > 0)
         avctx->bit_rate = s->bitrate;
-    avctx->channels = s->nb_channels;
+    av_channel_layout_uninit(&avctx->ch_layout);
+    avctx->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
+    avctx->ch_layout.nb_channels = s->nb_channels;
     avctx->sample_rate = s->rate;
     avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
 
@@ -1554,12 +1556,12 @@ static int speex_decode_frame(AVCodecContext *avctx, void *data,
         ret = speex_modes[s->mode].decode(avctx, &s->st[s->mode], &s->gb, dst + i * s->frame_size);
         if (ret < 0)
             return ret;
-        if (avctx->channels == 2)
+        if (avctx->ch_layout.nb_channels == 2)
             speex_decode_stereo(dst + i * s->frame_size, s->frame_size, &s->stereo);
     }
 
     dst = (float *)frame->extended_data[0];
-    s->fdsp->vector_fmul_scalar(dst, dst, scale, frame->nb_samples * frame->channels);
+    s->fdsp->vector_fmul_scalar(dst, dst, scale, frame->nb_samples * frame->ch_layout.nb_channels);
     frame->nb_samples = s->frame_size * s->frames_per_packet;
 
     *got_frame_ptr = 1;
-- 
2.34.1



More information about the ffmpeg-devel mailing list