From 97d9a3293854eda84f05c22e2eaefae7406ac969 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 3 Jun 2019 17:54:20 +0200 Subject: libspeex: convert to new channel layout API Signed-off-by: James Almer --- libavcodec/libspeexdec.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'libavcodec/libspeexdec.c') diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c index 6f032907fc..8029786b1f 100644 --- a/libavcodec/libspeexdec.c +++ b/libavcodec/libspeexdec.c @@ -42,7 +42,7 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx) LibSpeexContext *s = avctx->priv_data; const SpeexMode *mode; SpeexHeader *header = NULL; - int spx_mode; + int spx_mode, channels; if (avctx->extradata && avctx->extradata_size >= 80) { header = speex_packet_to_header(avctx->extradata, @@ -68,7 +68,7 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx) spx_mode = 0; } else if (header) { avctx->sample_rate = header->rate; - avctx->channels = header->nb_channels; + channels = header->nb_channels; spx_mode = header->mode; speex_header_free(header); } else { @@ -94,14 +94,15 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx) if (!avctx->sample_rate) avctx->sample_rate = 8000 << spx_mode; - if (avctx->channels < 1 || avctx->channels > 2) { + if (channels < 1 || channels > 2) { /* libspeex can handle mono or stereo if initialized as stereo */ av_log(avctx, AV_LOG_ERROR, "Invalid channel count: %d.\n" - "Decoding as stereo.\n", avctx->channels); - avctx->channels = 2; + "Decoding as stereo.\n", channels); + channels = 2; } - avctx->channel_layout = avctx->channels == 2 ? AV_CH_LAYOUT_STEREO : - AV_CH_LAYOUT_MONO; + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = channels == 2 ? (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO : + (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; speex_bits_init(&s->bits); s->dec_state = speex_decoder_init(mode); @@ -110,7 +111,7 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx) return -1; } - if (avctx->channels == 2) { + if (channels == 2) { SpeexCallback callback; callback.callback_id = SPEEX_INBAND_STEREO; callback.func = speex_std_stereo_request_handler; @@ -163,7 +164,7 @@ static int libspeex_decode_frame(AVCodecContext *avctx, void *data, av_log(avctx, AV_LOG_ERROR, "Error decoding Speex frame.\n"); return AVERROR_INVALIDDATA; } - if (avctx->channels == 2) + if (avctx->ch_layout.nb_channels == 2) speex_decode_stereo_int(output, s->frame_size, &s->stereo); *got_frame_ptr = 1; -- cgit v1.2.3