X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flibopusdec.c;h=e6ca61a78f3fc250f1e371f310241f2b6dc1095d;hb=1daa08bd96991d798ab883e049ef9177001efa98;hp=acc62f14d86fc9d369dc81c9a266fc67aa0d73c4;hpb=0bd76401d1666bf8f0a67946d761ed9ba4751e49;p=ffmpeg diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c index acc62f14d86..e6ca61a78f3 100644 --- a/libavcodec/libopusdec.c +++ b/libavcodec/libopusdec.c @@ -47,6 +47,13 @@ static av_cold int libopus_decode_init(AVCodecContext *avc) int ret, channel_map = 0, gain_db = 0, nb_streams, nb_coupled; uint8_t mapping_arr[8] = { 0, 1 }, *mapping; + avc->channels = avc->extradata_size >= 10 ? avc->extradata[9] : (avc->channels == 1) ? 1 : 2; + if (avc->channels <= 0) { + av_log(avc, AV_LOG_WARNING, + "Invalid number of channels %d, defaulting to stereo\n", avc->channels); + avc->channels = 2; + } + avc->sample_rate = 48000; avc->sample_fmt = avc->request_sample_fmt == AV_SAMPLE_FMT_FLT ? AV_SAMPLE_FMT_FLT : AV_SAMPLE_FMT_S16;