Merge commit 'aaaf2dc023d31f30eeec874f24b50f44b9295185'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 28 Oct 2013 11:07:23 +0000 (12:07 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 28 Oct 2013 11:09:12 +0000 (12:09 +0100)
* commit 'aaaf2dc023d31f30eeec874f24b50f44b9295185':
  h263: Check init_get_bits return value

Conflicts:
libavcodec/h263dec.c

See: d47e14b53a3908e5bad82e22129bbd175b49e89b
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/h263dec.c

@@@ -414,26 -404,13 +414,27 @@@ int ff_h263_decode_frame(AVCodecContex
              return buf_size;
      }
  
 +retry:
 +    if (s->divx_packed && s->bitstream_buffer_size) {
 +        int i;
 +        for(i=0; i < buf_size-3; i++) {
 +            if (buf[i]==0 && buf[i+1]==0 && buf[i+2]==1) {
 +                if (buf[i+3]==0xB0) {
 +                    av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n");
 +                    s->bitstream_buffer_size = 0;
 +                }
 +                break;
 +            }
 +        }
 +    }
 +
      if (s->bitstream_buffer_size && (s->divx_packed || buf_size < 20)) // divx 5.01+/xvid frame reorder
-         ret = init_get_bits8(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size);
+         ret = init_get_bits8(&s->gb, s->bitstream_buffer,
+                              s->bitstream_buffer_size);
      else
          ret = init_get_bits8(&s->gb, buf, buf_size);
 -    s->bitstream_buffer_size = 0;
  
 +    s->bitstream_buffer_size = 0;
      if (ret < 0)
          return ret;
  
          if (s->avctx->extradata_size && s->picture_number == 0) {
              GetBitContext gb;
  
 -            ret = init_get_bits8(&gb, s->avctx->extradata,
 -                                 s->avctx->extradata_size);
 -            if (ret < 0)
 -                return ret;
 -            ff_mpeg4_decode_picture_header(s, &gb);
 +            if (init_get_bits8(&gb, s->avctx->extradata, s->avctx->extradata_size) >= 0 )
-                 ret = ff_mpeg4_decode_picture_header(s, &gb);
++                ff_mpeg4_decode_picture_header(s, &gb);
          }
          ret = ff_mpeg4_decode_picture_header(s, &s->gb);
      } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {