summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-05-07 07:20:32 +0200
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:40 -0300
commit14b28ab6f787e451d08ab7cb6cd964922d4f2173 (patch)
treef44df71131f90a27444e6460ae78cce5585ecec0
parent411f2e058edddefa0c73b36ecf5f9d4bb45bc6e8 (diff)
binkaudio: 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/binkaudio.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index f808141ba5..be321233c8 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -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: