title: Decoder crashes after ffmpeg upgrade
body: <p>Recently I upgraded ffmpeg from 0.9 to 1.0 (tested on Win7x64 and on iOS), and now <code>avcodec_decode_video2</code> seagfaults. Long story short: the crash occurs every time the video dimensions change (eg. from 320x240 to 160x120 or vice versa).</p>
  
  <p>I receive mpeg4 video stream from some proprietary source and decode it like this:</p>
  
  <pre><code>// once, during initialization:
  AVCodec *codec_ = avcodec_find_decoder(CODEC_ID_MPEG4);
  AVCodecContext ctx_ = avcodec_alloc_context3(codec_);
  avcodec_open2(ctx_, codec_, 0);
  AVPacket packet_;
  av_init_packet(&amp;packet_);
  AVFrame picture_ = avcodec_alloc_frame();
  
  // on every frame:
  int got_picture;
  packet_.size = size;
  packet_.data = (uint8_t *)buffer;
  avcodec_decode_video2(ctx_, picture_, &amp;got_picture, &amp;packet_);
  </code></pre>
  
  <p>Again, all the above had worked flawlessly until I upgraded to 1.0. Now every time the frame dimensions change - <code>avcodec_decode_video2</code> crashes. Note that I don't assign width/height in AVCodecContext - neither in the beginning, nor when the stream changes - can it be the reason?</p>
  
  <p>I'd appreciate any idea!</p>
  
  <p><strong>Update:</strong> setting ctx_.width and ctx_.height doesn't help.</p>
  
  <p><strong>Update2:</strong> just before the crash I get the following log messages:</p>
  
  <blockquote>
    <p>mpeg4, level 24: "Found 2 unreleased buffers!". 
    level 8: "Assertion i &lt; avci->buffer_count failed at libavcodec/utils.c:603"</p>
  </blockquote>
  
  <p><strong>Update3</strong> upgrading to 1.1.2 fixed this crash. The decoder is able again to cope with dimensions change on the fly.</p>