diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-05-07 07:20:32 +0200 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-03-15 09:42:44 -0300 |
commit | 05cce829ee1cada89c7ec42508fc0478353b4a3e (patch) | |
tree | ffe5c2d2334f3d135395b9dfa9cdaba19eb72765 | |
parent | b6c62cda7d79993997049c028e9eb5659cb4ca82 (diff) | |
download | ffmpeg-05cce829ee1cada89c7ec42508fc0478353b4a3e.tar.gz |
ralf: convert to new channel layout API
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>
-rw-r--r-- | libavcodec/ralf.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c index 0c51f49939..c4fd586296 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) { @@ -346,7 +346,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; @@ -356,7 +356,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) { @@ -472,7 +472,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 { |