- if(s->stereo_in){
- if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
- samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S16);
- else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32)
- samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
- else
- samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
-
- if (samplecount < 0)
- return -1;
-
- samplecount >>= 1;
- }else{
- const int channel_stride = avctx->channels;
-
- if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
- samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S16);
- else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32)
- samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
- else
- samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
-
- if (samplecount < 0)
- return -1;
-
- if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S16){
- int16_t *dst = (int16_t*)samples + 1;
- int16_t *src = (int16_t*)samples;
- int cnt = samplecount;
- while(cnt--){
- *dst = *src;
- src += channel_stride;
- dst += channel_stride;
- }
- }else if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S32){
- int32_t *dst = (int32_t*)samples + 1;
- int32_t *src = (int32_t*)samples;
- int cnt = samplecount;
- while(cnt--){
- *dst = *src;
- src += channel_stride;
- dst += channel_stride;
- }
- }else if(s->stereo){
- float *dst = (float*)samples + 1;
- float *src = (float*)samples;
- int cnt = samplecount;
- while(cnt--){
- *dst = *src;
- src += channel_stride;
- dst += channel_stride;
- }
- }
+ if (wc->ch_offset + s->stereo >= avctx->channels) {
+ av_log(avctx, AV_LOG_WARNING, "Too many channels coded in a packet.\n");
+ return (avctx->err_recognition & AV_EF_EXPLODE) ? AVERROR_INVALIDDATA : 0;