forked from FFmpeg/FFmpeg
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>
This commit is contained in:
parent
62473cbd8e
commit
a4a73c6a9c
3 changed files with 17 additions and 17 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue