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:
committed by
James Almer
parent
62473cbd8e
commit
a4a73c6a9c
@@ -63,9 +63,9 @@ static int amr_parse(AVCodecParserContext *s1,
|
|||||||
*poutbuf_size = 0;
|
*poutbuf_size = 0;
|
||||||
*poutbuf = NULL;
|
*poutbuf = NULL;
|
||||||
|
|
||||||
if (!avctx->channels) {
|
if (!avctx->ch_layout.nb_channels) {
|
||||||
avctx->channels = 1;
|
av_channel_layout_uninit(&avctx->ch_layout);
|
||||||
avctx->channel_layout = AV_CH_LAYOUT_MONO;
|
avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {
|
if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {
|
||||||
@@ -73,7 +73,7 @@ static int amr_parse(AVCodecParserContext *s1,
|
|||||||
} else {
|
} else {
|
||||||
int ch, offset = 0;
|
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) {
|
if (s->remaining >= 0) {
|
||||||
next = s->remaining;
|
next = s->remaining;
|
||||||
} else {
|
} 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)
|
if (s->remaining < 0)
|
||||||
next = offset;
|
next = offset;
|
||||||
|
|
||||||
|
@@ -166,20 +166,20 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx)
|
|||||||
AMRChannelsContext *s = avctx->priv_data;
|
AMRChannelsContext *s = avctx->priv_data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (avctx->channels > 2) {
|
if (avctx->ch_layout.nb_channels > 2) {
|
||||||
avpriv_report_missing_feature(avctx, ">2 channel AMR");
|
avpriv_report_missing_feature(avctx, ">2 channel AMR");
|
||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!avctx->channels) {
|
if (!avctx->ch_layout.nb_channels) {
|
||||||
avctx->channels = 1;
|
av_channel_layout_uninit(&avctx->ch_layout);
|
||||||
avctx->channel_layout = AV_CH_LAYOUT_MONO;
|
avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
|
||||||
}
|
}
|
||||||
if (!avctx->sample_rate)
|
if (!avctx->sample_rate)
|
||||||
avctx->sample_rate = 8000;
|
avctx->sample_rate = 8000;
|
||||||
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
|
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];
|
AMRContext *p = &s->ch[ch];
|
||||||
// p->excitation always points to the same position in p->excitation_buf
|
// p->excitation always points to the same position in p->excitation_buf
|
||||||
p->excitation = &p->excitation_buf[PITCH_DELAY_MAX + LP_FILTER_ORDER + 1];
|
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)
|
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||||
return ret;
|
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];
|
AMRContext *p = &s->ch[ch];
|
||||||
float fixed_gain_factor;
|
float fixed_gain_factor;
|
||||||
AMRFixed fixed_sparse = {0}; // fixed vector up to anti-sparseness processing
|
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;
|
AMRWBChannelsContext *s = avctx->priv_data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (avctx->channels > 2) {
|
if (avctx->ch_layout.nb_channels > 2) {
|
||||||
avpriv_report_missing_feature(avctx, ">2 channel AMR");
|
avpriv_report_missing_feature(avctx, ">2 channel AMR");
|
||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!avctx->channels) {
|
if (!avctx->ch_layout.nb_channels) {
|
||||||
avctx->channels = 1;
|
av_channel_layout_uninit(&avctx->ch_layout);
|
||||||
avctx->channel_layout = AV_CH_LAYOUT_MONO;
|
avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
|
||||||
}
|
}
|
||||||
if (!avctx->sample_rate)
|
if (!avctx->sample_rate)
|
||||||
avctx->sample_rate = 16000;
|
avctx->sample_rate = 16000;
|
||||||
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
|
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];
|
AMRWBContext *ctx = &s->ch[ch];
|
||||||
|
|
||||||
av_lfg_init(&ctx->prng, 1);
|
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)
|
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||||
return ret;
|
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];
|
AMRWBContext *ctx = &s->ch[ch];
|
||||||
AMRWBFrame *cf = &ctx->frame;
|
AMRWBFrame *cf = &ctx->frame;
|
||||||
int expected_fr_size, header_size;
|
int expected_fr_size, header_size;
|
||||||
|
Reference in New Issue
Block a user