Merge commit '163196562fe744149ef599d754c30c08a9898381' into release/1.1
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 7 Oct 2013 22:49:18 +0000 (00:49 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 7 Oct 2013 22:49:18 +0000 (00:49 +0200)
* commit '163196562fe744149ef599d754c30c08a9898381':
  oggparseogm: Convert to use bytestream2
  rv34: Check the return value from ff_rv34_decode_init
  matroskadec: Verify realaudio codec parameters
  mace: Make sure that the channel count is set to a valid value
  svq3: Check for any negative return value from ff_h264_check_intra_pred_mode
  vp3: Check the framerate for validity
  cavsdec: Make sure a sequence header has been decoded before decoding pictures
  vocdec: Don't update codec parameters mid-stream
  sierravmd: Do sanity checking of frame sizes
  omadec: Properly check lengths before incrementing the position
  mpc8: Make sure the first stream exists before parsing the seek table

Conflicts:
libavcodec/mace.c
libavformat/oggparseogm.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
12 files changed:
1  2 
libavcodec/cavsdec.c
libavcodec/mace.c
libavcodec/rv30.c
libavcodec/rv40.c
libavcodec/svq3.c
libavcodec/vp3.c
libavformat/matroskadec.c
libavformat/mpc8.c
libavformat/oggparseogm.c
libavformat/omadec.c
libavformat/sierravmd.c
libavformat/vocdec.c

@@@ -941,9 -929,13 +941,14 @@@ static inline int check_for_slice(AVSCo
  static int decode_pic(AVSContext *h)
  {
      int skip_count    = -1;
 +    int ret;
      enum cavs_mb mb_type;
  
+     if (!h->top_qp) {
+         av_log(h->avctx, AV_LOG_ERROR, "No sequence header decoded yet\n");
+         return AVERROR_INVALIDDATA;
+     }
      skip_bits(&h->gb, 16);//bbv_dwlay
      if (h->stc == PIC_PB_START_CODE) {
          h->cur.f->pict_type = get_bits(&h->gb, 2) + AV_PICTURE_TYPE_I;
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -38,74 -37,62 +38,76 @@@ ogm_header(AVFormatContext *s, int idx
      struct ogg *ogg = s->priv_data;
      struct ogg_stream *os = ogg->streams + idx;
      AVStream *st = s->streams[idx];
-     const uint8_t *p = os->buf + os->pstart;
+     GetByteContext p;
      uint64_t time_unit;
      uint64_t spu;
 +    uint32_t size;
  
-     if(!(*p & 1))
+     bytestream2_init(&p, os->buf + os->pstart, os->psize);
+     if (!(bytestream2_peek_byte(&p) & 1))
          return 0;
  
-     if(*p == 1) {
-         p++;
+     if (bytestream2_peek_byte(&p) == 1) {
+         bytestream2_skip(&p, 1);
  
-         if(*p == 'v'){
+         if (bytestream2_peek_byte(&p) == 'v'){
              int tag;
              st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-             p += 8;
-             tag = bytestream_get_le32(&p);
+             bytestream2_skip(&p, 8);
+             tag = bytestream2_get_le32(&p);
              st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
              st->codec->codec_tag = tag;
-         } else if (*p == 't') {
+         } else if (bytestream2_peek_byte(&p) == 't') {
              st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
              st->codec->codec_id = AV_CODEC_ID_TEXT;
-             p += 12;
+             bytestream2_skip(&p, 12);
          } else {
-             uint8_t acid[5];
+             uint8_t acid[5] = { 0 };
              int cid;
              st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-             p += 8;
-             bytestream_get_buffer(&p, acid, 4);
+             bytestream2_skip(&p, 8);
+             bytestream2_get_buffer(&p, acid, 4);
              acid[4] = 0;
              cid = strtol(acid, NULL, 16);
              st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, cid);
 -            st->need_parsing = AVSTREAM_PARSE_FULL;
 +            // our parser completely breaks AAC in Ogg
 +            if (st->codec->codec_id != AV_CODEC_ID_AAC)
 +                st->need_parsing = AVSTREAM_PARSE_FULL;
          }
  
-         size        = bytestream_get_le32(&p);
 -        bytestream2_skip(&p, 4);    /* useless size field */
 -
++        size        = bytestream2_get_le32(&p);
 +        size        = FFMIN(size, os->psize);
-         time_unit   = bytestream_get_le64(&p);
-         spu         = bytestream_get_le64(&p);
-         p += 4;                     /* default_len */
-         p += 8;                     /* buffersize + bits_per_sample */
+         time_unit   = bytestream2_get_le64(&p);
+         spu         = bytestream2_get_le64(&p);
+         bytestream2_skip(&p, 4);    /* default_len */
+         bytestream2_skip(&p, 8);    /* buffersize + bits_per_sample */
  
          if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
-             st->codec->width = bytestream_get_le32(&p);
-             st->codec->height = bytestream_get_le32(&p);
+             st->codec->width = bytestream2_get_le32(&p);
+             st->codec->height = bytestream2_get_le32(&p);
              avpriv_set_pts_info(st, 64, time_unit, spu * 10000000);
          } else {
-             st->codec->channels = bytestream_get_le16(&p);
-             p += 2;                 /* block_align */
-             st->codec->bit_rate = bytestream_get_le32(&p) * 8;
+             st->codec->channels = bytestream2_get_le16(&p);
+             bytestream2_skip(&p, 2); /* block_align */
+             st->codec->bit_rate = bytestream2_get_le32(&p) * 8;
 -            st->codec->sample_rate = spu * 10000000 / time_unit;
 +            st->codec->sample_rate = time_unit ? spu * 10000000 / time_unit : 0;
              avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
-                 p += 4;
 +            if (size >= 56 && st->codec->codec_id == AV_CODEC_ID_AAC) {
-                 bytestream_get_buffer(&p, st->codec->extradata, size);
++                bytestream2_skip(&p, 4);
 +                size -= 4;
 +            }
 +            if (size > 52) {
 +                av_assert0(FF_INPUT_BUFFER_PADDING_SIZE <= 52);
 +                size -= 52;
 +                st->codec->extradata_size = size;
 +                st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
++                bytestream2_get_buffer(&p, st->codec->extradata, size);
 +            }
          }
-     } else if (*p == 3) {
-         if (os->psize > 8)
-             ff_vorbis_comment(s, &st->metadata, p+7, os->psize-8);
+     } else if (bytestream2_peek_byte(&p) == 3) {
+         bytestream2_skip(&p, 7);
+         if (bytestream2_get_bytes_left(&p) > 1)
+             ff_vorbis_comment(s, &st->metadata, p.buffer, bytestream2_get_bytes_left(&p) - 1);
      }
  
      return 1;
@@@ -169,9 -170,13 +169,13 @@@ static int nprobe(AVFormatContext *s, u
      taglen = AV_RB32(&enc_header[pos+32]);
      datalen = AV_RB32(&enc_header[pos+36]) >> 4;
  
-     pos += 44 + taglen;
+     pos += 44;
+     if (size - pos < taglen)
+         return -1;
+     pos += taglen;
  
 -    if (datalen << 4 > size - pos)
 +    if (pos + (((uint64_t)datalen) << 4) > size)
          return -1;
  
      av_des_init(&av_des, n_val, 192, 1);
Simple merge
Simple merge