Merge commit '187cfd3c13a1deb47661486824a5b8f41e158a7a' into release/0.10
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 9 Aug 2014 16:59:24 +0000 (18:59 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 9 Aug 2014 17:04:40 +0000 (19:04 +0200)
* commit '187cfd3c13a1deb47661486824a5b8f41e158a7a':
  eamad: use the bytestream2 API instead of AV_RL

Conflicts:
libavcodec/eamad.c

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

@@@ -252,27 -243,27 +253,29 @@@ static int decode_frame(AVCodecContext 
      int chunk_type;
      int inter;
  
-     if (buf_size < 17) {
-         av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
-         *data_size = 0;
-         return -1;
-     }
+     bytestream2_init(&gb, buf, buf_size);
  
-     chunk_type = AV_RL32(&buf[0]);
+     chunk_type = bytestream2_get_le32(&gb);
      inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG);
-     buf += 8;
+     bytestream2_skip(&gb, 10);
  
      av_reduce(&avctx->time_base.num, &avctx->time_base.den,
-               AV_RL16(&buf[6]), 1000, 1<<30);
+               bytestream2_get_le16(&gb), 1000, 1<<30);
+     s->width  = bytestream2_get_le16(&gb);
+     s->height = bytestream2_get_le16(&gb);
+     bytestream2_skip(&gb, 1);
+     calc_intra_matrix(t, bytestream2_get_byte(&gb));
+     bytestream2_skip(&gb, 2);
  
-     s->width  = AV_RL16(&buf[8]);
-     s->height = AV_RL16(&buf[10]);
-     calc_intra_matrix(t, buf[13]);
-     buf += 16;
+     if (bytestream2_get_bytes_left(&gb) < 2) {
+         av_log(avctx, AV_LOG_ERROR, "Input data too small\n");
+         return AVERROR_INVALIDDATA;
+     }
  
      if (avctx->width != s->width || avctx->height != s->height) {
-         if((s->width * s->height)/2048*7 > buf_end-buf)
++        if((s->width * s->height)/2048*7 > bytestream2_get_bytes_left(&gb))
 +            return -1;
          if (av_image_check_size(s->width, s->height, 0, avctx) < 0)
              return -1;
          avcodec_set_dimensions(avctx, s->width, s->height);
          }
      }
  
-     av_fast_malloc(&t->bitstream_buf, &t->bitstream_buf_size, (buf_end-buf) + FF_INPUT_BUFFER_PADDING_SIZE);
+     av_fast_malloc(&t->bitstream_buf, &t->bitstream_buf_size,
+                    bytestream2_get_bytes_left(&gb) + FF_INPUT_BUFFER_PADDING_SIZE);
      if (!t->bitstream_buf)
          return AVERROR(ENOMEM);
-     bswap16_buf(t->bitstream_buf, (const uint16_t*)buf, (buf_end-buf)/2);
-     memset((uint8_t*)t->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE);
-     init_get_bits(&s->gb, t->bitstream_buf, 8*(buf_end-buf));
+     bswap16_buf(t->bitstream_buf, (const uint16_t *)(buf + bytestream2_tell(&gb)),
+                 bytestream2_get_bytes_left(&gb) / 2);
++    memset((uint8_t*)t->bitstream_buf + bytestream2_get_bytes_left(&gb), 0, FF_INPUT_BUFFER_PADDING_SIZE);
+     init_get_bits(&s->gb, t->bitstream_buf, 8*(bytestream2_get_bytes_left(&gb)));
      for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)
          for (s->mb_x=0; s->mb_x < (avctx->width +15)/16; s->mb_x++)
 -            decode_mb(t, inter);
 +            if(decode_mb(t, inter) < 0)
 +                return -1;
  
      *data_size = sizeof(AVFrame);
      *(AVFrame*)data = t->frame;