Commit 14b28ab6 authored by Anton Khirnov's avatar Anton Khirnov Committed by James Almer

binkaudio: convert to new channel layout API

Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 411f2e05
......@@ -72,6 +72,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
int sample_rate_half;
int i, ret;
int frame_len_bits;
int channels = avctx->ch_layout.nb_channels;
/* determine frame length */
if (avctx->sample_rate < 22050) {
......@@ -82,26 +83,26 @@ static av_cold int decode_init(AVCodecContext *avctx)
frame_len_bits = 11;
}
if (avctx->channels < 1 || avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "invalid number of channels: %d\n", avctx->channels);
if (channels < 1 || channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "invalid number of channels: %d\n", channels);
return AVERROR_INVALIDDATA;
}
avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO :
AV_CH_LAYOUT_STEREO;
av_channel_layout_uninit(&avctx->ch_layout);
av_channel_layout_default(&avctx->ch_layout, channels);
s->version_b = avctx->extradata_size >= 4 && avctx->extradata[3] == 'b';
if (avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT) {
// audio is already interleaved for the RDFT format variant
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
if (sample_rate > INT_MAX / avctx->channels)
if (sample_rate > INT_MAX / channels)
return AVERROR_INVALIDDATA;
sample_rate *= avctx->channels;
sample_rate *= channels;
s->channels = 1;
if (!s->version_b)
frame_len_bits += av_log2(avctx->channels);
frame_len_bits += av_log2(channels);
} else {
s->channels = avctx->channels;
s->channels = channels;
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
}
......@@ -325,7 +326,7 @@ static int binkaudio_receive_frame(AVCodecContext *avctx, AVFrame *frame)
av_packet_unref(s->pkt);
}
frame->nb_samples = s->block_size / avctx->channels;
frame->nb_samples = s->block_size / avctx->ch_layout.nb_channels;
return 0;
fail:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment