diff mbox series

[FFmpeg-devel,243/281] on2avc: convert to new channel layout API

Message ID 20220113020713.801-4-jamrial@gmail.com
State New
Headers show
Series New channel layout API
Related show

Commit Message

James Almer Jan. 13, 2022, 2:06 a.m. UTC
From: Anton Khirnov <anton@khirnov.net>

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/on2avc.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c
index fa3eb4b219..1d5a9487b3 100644
--- a/libavcodec/on2avc.c
+++ b/libavcodec/on2avc.c
@@ -691,7 +691,7 @@  static int on2avc_reconstruct_channel_ext(On2AVCContext *c, AVFrame *dst, int of
 {
     int ch, i;
 
-    for (ch = 0; ch < c->avctx->channels; ch++) {
+    for (ch = 0; ch < c->avctx->ch_layout.nb_channels; ch++) {
         float *out   = (float*)dst->extended_data[ch] + offset;
         float *in    = c->coeffs[ch];
         float *saved = c->delay[ch];
@@ -823,13 +823,13 @@  static int on2avc_decode_subframe(On2AVCContext *c, const uint8_t *buf,
         c->grouping[i] = !get_bits1(&gb);
 
     on2avc_read_ms_info(c, &gb);
-    for (i = 0; i < c->avctx->channels; i++)
+    for (i = 0; i < c->avctx->ch_layout.nb_channels; i++)
         if ((ret = on2avc_read_channel_data(c, &gb, i)) < 0)
             return AVERROR_INVALIDDATA;
-    if (c->avctx->channels == 2 && c->ms_present)
+    if (c->avctx->ch_layout.nb_channels == 2 && c->ms_present)
         on2avc_apply_ms(c);
     if (c->window_type < WINDOW_TYPE_EXT4) {
-        for (i = 0; i < c->avctx->channels; i++)
+        for (i = 0; i < c->avctx->ch_layout.nb_channels; i++)
             on2avc_reconstruct_channel(c, i, dst, offset);
     } else {
         on2avc_reconstruct_channel_ext(c, dst, offset);
@@ -910,21 +910,23 @@  static av_cold int on2avc_decode_init(AVCodecContext *avctx)
     On2AVCContext *c = avctx->priv_data;
     const uint8_t  *lens = ff_on2avc_cb_lens;
     const uint16_t *syms = ff_on2avc_cb_syms;
+    int channels = avctx->ch_layout.nb_channels;
     int i, ret;
 
-    if (avctx->channels > 2U) {
+    if (channels > 2U) {
         avpriv_request_sample(avctx, "Decoding more than 2 channels");
         return AVERROR_PATCHWELCOME;
     }
 
     c->avctx = avctx;
     avctx->sample_fmt     = AV_SAMPLE_FMT_FLTP;
-    avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO
-                                                   : AV_CH_LAYOUT_MONO;
+    av_channel_layout_uninit(&avctx->ch_layout);
+    avctx->ch_layout = (channels == 2) ? (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO :
+                                         (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
 
     c->is_av500 = (avctx->codec_tag == 0x500);
 
-    if (avctx->channels == 2)
+    if (channels == 2)
         av_log(avctx, AV_LOG_WARNING,
                "Stereo mode support is not good, patch is welcome\n");
 
@@ -936,7 +938,7 @@  static av_cold int on2avc_decode_init(AVCodecContext *avctx)
     for (; i < 128; i++)
         c->scale_tab[i] = ceil(ff_exp10(i * 0.1) * 0.5 - 0.01);
 
-    if (avctx->sample_rate < 32000 || avctx->channels == 1)
+    if (avctx->sample_rate < 32000 || channels == 1)
         memcpy(c->long_win, ff_on2avc_window_long_24000,
                1024 * sizeof(*c->long_win));
     else