diff mbox series

[FFmpeg-devel,252/281] ralf: convert to new channel layout API

Message ID 20220113020713.801-13-jamrial@gmail.com
State Accepted
Commit 05cce829ee1cada89c7ec42508fc0478353b4a3e
Headers show
Series New channel layout API | expand

Commit Message

James Almer Jan. 13, 2022, 2: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/ralf.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c
index bb80119b0c..eac3e60371 100644
--- a/libavcodec/ralf.c
+++ b/libavcodec/ralf.c
@@ -128,7 +128,7 @@  static av_cold int decode_init(AVCodecContext *avctx)
 {
     RALFContext *ctx = avctx->priv_data;
     int i, j, k;
-    int ret;
+    int ret, channels;
 
     if (avctx->extradata_size < 24 || memcmp(avctx->extradata, "LSD:", 4)) {
         av_log(avctx, AV_LOG_ERROR, "Extradata is not groovy, dude\n");
@@ -141,17 +141,17 @@  static av_cold int decode_init(AVCodecContext *avctx)
         return AVERROR_PATCHWELCOME;
     }
 
-    avctx->channels    = AV_RB16(avctx->extradata + 8);
+    channels           = AV_RB16(avctx->extradata + 8);
     avctx->sample_rate = AV_RB32(avctx->extradata + 12);
-    if (avctx->channels < 1 || avctx->channels > 2
+    if (channels < 1 || channels > 2
         || avctx->sample_rate < 8000 || avctx->sample_rate > 96000) {
         av_log(avctx, AV_LOG_ERROR, "Invalid coding parameters %d Hz %d ch\n",
-               avctx->sample_rate, avctx->channels);
+               avctx->sample_rate, channels);
         return AVERROR_INVALIDDATA;
     }
     avctx->sample_fmt     = AV_SAMPLE_FMT_S16P;
-    avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO
-                                                   : AV_CH_LAYOUT_MONO;
+    av_channel_layout_uninit(&avctx->ch_layout);
+    av_channel_layout_default(&avctx->ch_layout, channels);
 
     ctx->max_frame_size = AV_RB32(avctx->extradata + 16);
     if (ctx->max_frame_size > (1 << 20) || !ctx->max_frame_size) {
@@ -358,7 +358,7 @@  static int decode_block(AVCodecContext *avctx, GetBitContext *gb,
         return AVERROR_INVALIDDATA;
     }
 
-    if (avctx->channels > 1)
+    if (avctx->ch_layout.nb_channels > 1)
         dmode = get_bits(gb, 2) + 1;
     else
         dmode = 0;
@@ -368,7 +368,7 @@  static int decode_block(AVCodecContext *avctx, GetBitContext *gb,
     bits[0] = 16;
     bits[1] = (mode[1] == 2) ? 17 : 16;
 
-    for (ch = 0; ch < avctx->channels; ch++) {
+    for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
         if ((ret = decode_channel(ctx, gb, ch, len, mode[ch], bits[ch])) < 0)
             return ret;
         if (ctx->filter_params > 1 && ctx->filter_params != FILTER_RAW) {
@@ -484,7 +484,7 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
     while (get_bits_left(&gb) > 0) {
         if (ctx->num_blocks >= FF_ARRAY_ELEMS(ctx->block_size))
             return AVERROR_INVALIDDATA;
-        ctx->block_size[ctx->num_blocks] = get_bits(&gb, 13 + avctx->channels);
+        ctx->block_size[ctx->num_blocks] = get_bits(&gb, 13 + avctx->ch_layout.nb_channels);
         if (get_bits1(&gb)) {
             ctx->block_pts[ctx->num_blocks] = get_bits(&gb, 9);
         } else {