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:40 -0300 |
commit | a4a73c6a9c2007dbea55519482499c7b7462ac9b (patch) | |
tree | fd99363eae27f6263c8b87e7901ab119fc6ee009 | |
parent | 62473cbd8e43cfcdca3024787e2baef6daff80ce (diff) | |
download | ffmpeg-a4a73c6a9c2007dbea55519482499c7b7462ac9b.tar.gz |
amr: 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/amr_parser.c | 10 | ||||
-rw-r--r-- | libavcodec/amrnbdec.c | 12 | ||||
-rw-r--r-- | libavcodec/amrwbdec.c | 12 |
3 files changed, 17 insertions, 17 deletions
diff --git a/libavcodec/amr_parser.c b/libavcodec/amr_parser.c index c0b14700e2..9484d720ee 100644 --- a/libavcodec/amr_parser.c +++ b/libavcodec/amr_parser.c @@ -63,9 +63,9 @@ static int amr_parse(AVCodecParserContext *s1, *poutbuf_size = 0; *poutbuf = NULL; - if (!avctx->channels) { - avctx->channels = 1; - avctx->channel_layout = AV_CH_LAYOUT_MONO; + if (!avctx->ch_layout.nb_channels) { + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; } if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) { @@ -73,7 +73,7 @@ static int amr_parse(AVCodecParserContext *s1, } else { int ch, offset = 0; - for (ch = s->current_channel; ch < avctx->channels; ch++) { + for (ch = s->current_channel; ch < avctx->ch_layout.nb_channels; ch++) { if (s->remaining >= 0) { next = s->remaining; } else { @@ -96,7 +96,7 @@ static int amr_parse(AVCodecParserContext *s1, } } - s->current_channel = ch % avctx->channels; + s->current_channel = ch % avctx->ch_layout.nb_channels; if (s->remaining < 0) next = offset; diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index 1e11445cd3..1844ad1925 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -166,20 +166,20 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx) AMRChannelsContext *s = avctx->priv_data; int i; - if (avctx->channels > 2) { + if (avctx->ch_layout.nb_channels > 2) { avpriv_report_missing_feature(avctx, ">2 channel AMR"); return AVERROR_PATCHWELCOME; } - if (!avctx->channels) { - avctx->channels = 1; - avctx->channel_layout = AV_CH_LAYOUT_MONO; + if (!avctx->ch_layout.nb_channels) { + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; } if (!avctx->sample_rate) avctx->sample_rate = 8000; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; - for (int ch = 0; ch < avctx->channels; ch++) { + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { AMRContext *p = &s->ch[ch]; // p->excitation always points to the same position in p->excitation_buf p->excitation = &p->excitation_buf[PITCH_DELAY_MAX + LP_FILTER_ORDER + 1]; @@ -969,7 +969,7 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; - for (int ch = 0; ch < avctx->channels; ch++) { + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { AMRContext *p = &s->ch[ch]; float fixed_gain_factor; AMRFixed fixed_sparse = {0}; // fixed vector up to anti-sparseness processing diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index 7d1b820bbb..261ef02255 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -102,20 +102,20 @@ static av_cold int amrwb_decode_init(AVCodecContext *avctx) AMRWBChannelsContext *s = avctx->priv_data; int i; - if (avctx->channels > 2) { + if (avctx->ch_layout.nb_channels > 2) { avpriv_report_missing_feature(avctx, ">2 channel AMR"); return AVERROR_PATCHWELCOME; } - if (!avctx->channels) { - avctx->channels = 1; - avctx->channel_layout = AV_CH_LAYOUT_MONO; + if (!avctx->ch_layout.nb_channels) { + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; } if (!avctx->sample_rate) avctx->sample_rate = 16000; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; - for (int ch = 0; ch < avctx->channels; ch++) { + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { AMRWBContext *ctx = &s->ch[ch]; av_lfg_init(&ctx->prng, 1); @@ -1115,7 +1115,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; - for (int ch = 0; ch < avctx->channels; ch++) { + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { AMRWBContext *ctx = &s->ch[ch]; AMRWBFrame *cf = &ctx->frame; int expected_fr_size, header_size; |