Merge commit 'c49b88b93bca53c04f18d78c27dbf1dc6daea909' into release/2.4
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 20 Aug 2015 12:17:55 +0000 (14:17 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 20 Aug 2015 12:20:26 +0000 (14:20 +0200)
* commit 'c49b88b93bca53c04f18d78c27dbf1dc6daea909':
  opusdec: properly handle mismatching configurations in multichannel streams

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
1  2 
libavcodec/opus.h
libavcodec/opusdec.c

Simple merge
@@@ -372,11 -374,15 +373,15 @@@ static int opus_decode_subpacket(OpusSt
      int flush_needed   = 0;
      int i, j, ret;
  
+     s->out[0]   = out[0];
+     s->out[1]   = out[1];
+     s->out_size = out_size;
      /* check if we need to flush the resampler */
 -    if (avresample_is_open(s->avr)) {
 +    if (swr_is_initialized(s->swr)) {
          if (buf) {
              int64_t cur_samplerate;
 -            av_opt_get_int(s->avr, "in_sample_rate", 0, &cur_samplerate);
 +            av_opt_get_int(s->swr, "in_sample_rate", 0, &cur_samplerate);
              flush_needed = (s->packet.mode == OPUS_MODE_CELT) || (cur_samplerate != s->silk_samplerate);
          } else {
              flush_needed = !!s->delayed_samples;
@@@ -449,15 -455,14 +454,17 @@@ static int opus_decode_packet(AVCodecCo
      const uint8_t *buf  = avpkt->data;
      int buf_size        = avpkt->size;
      int coded_samples   = 0;
-     int decoded_samples = 0;
-     int i, ret;
+     int decoded_samples = INT_MAX;
      int delayed_samples = 0;
+     int i, ret;
  
+     /* calculate the number of delayed samples */
      for (i = 0; i < c->nb_streams; i++) {
-         delayed_samples = FFMAX(delayed_samples, s->delayed_samples);
 +        OpusStreamContext *s = &c->streams[i];
 +        s->out[0] =
 +        s->out[1] = NULL;
 -                                c->streams[i].delayed_samples + av_audio_fifo_size(c->sync_buffers[i]));
+         delayed_samples = FFMAX(delayed_samples,
++                                s->delayed_samples + av_audio_fifo_size(c->sync_buffers[i]));
      }
  
      /* decode the header of the first sub-packet to find out the sample count */
@@@ -568,8 -613,10 +615,10 @@@ static av_cold void opus_decode_flush(A
  
          if (s->celt_delay)
              av_audio_fifo_drain(s->celt_delay, av_audio_fifo_size(s->celt_delay));
 -        avresample_close(s->avr);
 +        swr_close(s->swr);
  
+         av_audio_fifo_drain(c->sync_buffers[i], av_audio_fifo_size(c->sync_buffers[i]));
          ff_silk_flush(s->silk);
          ff_celt_flush(s->celt);
      }