Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 6 Jan 2012 01:45:12 +0000 (02:45 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 6 Jan 2012 01:45:12 +0000 (02:45 +0100)
* qatar/master: (21 commits)
  ipmovie: do not read audio packets before the codec is known
  truemotion2: check size before GetBitContext initialisation
  avio: Only do implicit network initialization for network protocols
  avio: Add an URLProtocol flag for indicating that a protocol uses network
  adpcm: ADPCM Electronic Arts has always two channels
  matroskadec: Fix a bug where a pointer was cached to an array that might later move due to a realloc()
  fate: Add missing reference file from 9b4767e4.
  mov: Support MOV_CH_LAYOUT_USE_DESCRIPTIONS for labeled descriptions.
  4xm: Prevent buffer overreads.
  mjpegdec: parse RSTn to prevent skipping other data in mjpeg_decode_scan
  vp3: add fate test for non-zero last coefficient
  vp3: fix streams with non-zero last coefficient
  swscale: remove unused U/V arguments from yuv2rgb_write().
  timer: K&R formatting cosmetics
  lavf: cosmetics, reformat av_read_frame().
  lavf: refactor av_read_frame() to make it easier to understand.
  Report an error if pitch_lag is zero in AMR-NB decoder.
  Revert "4xm: Prevent buffer overreads."
  4xm: Prevent buffer overreads.
  4xm: pass the correct remaining buffer size to decode_i2_frame().
  ...

Conflicts:
libavcodec/4xm.c
libavcodec/mjpegdec.c
libavcodec/truemotion2.c
libavformat/ipmovie.c
libavformat/mov_chan.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
23 files changed:
1  2 
libavcodec/4xm.c
libavcodec/adpcm.c
libavcodec/amrnbdec.c
libavcodec/mjpegdec.c
libavcodec/truemotion2.c
libavcodec/vp3.c
libavformat/avio.c
libavformat/avio.h
libavformat/gopher.c
libavformat/http.c
libavformat/ipmovie.c
libavformat/librtmp.c
libavformat/mmsh.c
libavformat/mmst.c
libavformat/mov.c
libavformat/rtmpproto.c
libavformat/rtpproto.c
libavformat/tcp.c
libavformat/udp.c
libavformat/url.h
libavformat/utils.c
libavutil/timer.h
libswscale/swscale.c

@@@ -643,19 -614,24 +643,27 @@@ static int decode_i2_frame(FourXContex
      int x, y, x2, y2;
      const int width= f->avctx->width;
      const int height= f->avctx->height;
+     const int mbs = (FFALIGN(width, 16) >> 4) * (FFALIGN(height, 16) >> 4);
      uint16_t *dst= (uint16_t*)f->current_picture.data[0];
      const int stride= f->current_picture.linesize[0]>>1;
 +    const uint8_t *buf_end = buf + length;
+     GetByteContext g3;
+     if(length < mbs * 8) {
+         av_log(f->avctx, AV_LOG_ERROR, "packet size too small\n");
+         return AVERROR_INVALIDDATA;
+     }
+     bytestream2_init(&g3, buf, length);
  
      for(y=0; y<height; y+=16){
          for(x=0; x<width; x+=16){
              unsigned int color[4], bits;
 +            if (buf_end - buf < 8)
 +                return -1;
              memset(color, 0, sizeof(color));
  //warning following is purely guessed ...
-             color[0]= bytestream_get_le16(&buf);
-             color[1]= bytestream_get_le16(&buf);
+             color[0]= bytestream2_get_le16u(&g3);
+             color[1]= bytestream2_get_le16u(&g3);
  
              if(color[0]&0x8000) av_log(NULL, AV_LOG_ERROR, "unk bit 1\n");
              if(color[1]&0x8000) av_log(NULL, AV_LOG_ERROR, "unk bit 2\n");
@@@ -823,19 -794,15 +831,19 @@@ static int decode_frame(AVCodecContext 
  
      if(frame_4cc == AV_RL32("ifr2")){
          p->pict_type= AV_PICTURE_TYPE_I;
-         if(decode_i2_frame(f, buf-4, frame_size+4) < 0){
 -        if(decode_i2_frame(f, buf-4, frame_size + 4) < 0)
++        if(decode_i2_frame(f, buf-4, frame_size + 4) < 0) {
 +            av_log(f->avctx, AV_LOG_ERROR, "decode i2 frame failed\n");
              return -1;
 +        }
      }else if(frame_4cc == AV_RL32("ifrm")){
          p->pict_type= AV_PICTURE_TYPE_I;
 -        if(decode_i_frame(f, buf, frame_size) < 0)
 +        if(decode_i_frame(f, buf, frame_size) < 0){
 +            av_log(f->avctx, AV_LOG_ERROR, "decode i frame failed\n");
              return -1;
 +        }
      }else if(frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")){
          if(!f->last_picture.data[0]){
 -            f->last_picture.reference= 1;
 +            f->last_picture.reference= 3;
              if(avctx->get_buffer(avctx, &f->last_picture) < 0){
                  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
                  return -1;
Simple merge
Simple merge
@@@ -985,18 -881,21 +985,21 @@@ static int mjpeg_decode_scan(MJpegDecod
                  }
              }
  
-             if (s->restart_interval) --s->restart_count;
-             i= 8+((-get_bits_count(&s->gb))&7);
-             if (s->restart_interval && show_bits(&s->gb, i)  == (1<<i)-1){ /* skip RSTn */
-                 int pos= get_bits_count(&s->gb);
-                 align_get_bits(&s->gb);
-                 while(get_bits_count(&s->gb) < s->gb.size_in_bits && show_bits(&s->gb, 8) == 0xFF)
-                     skip_bits(&s->gb, 8);
-                 if(get_bits_count(&s->gb) < s->gb.size_in_bits && (get_bits(&s->gb, 8)&0xF8) == 0xD0){
-                     for (i=0; i<nb_components; i++) /* reset dc */
-                         s->last_dc[i] = 1024;
-                 }else{
-                     skip_bits_long(&s->gb, pos - get_bits_count(&s->gb));
+             if (s->restart_interval) {
+                 s->restart_count--;
+                 i = 8 + ((-get_bits_count(&s->gb)) & 7);
+                 /* skip RSTn */
+                 if (show_bits(&s->gb, i) == (1 << i) - 1) {
+                     int pos = get_bits_count(&s->gb);
+                     align_get_bits(&s->gb);
+                     while (get_bits_left(&s->gb) >= 8 && show_bits(&s->gb, 8) == 0xFF)
+                         skip_bits(&s->gb, 8);
 -                    if ((get_bits(&s->gb, 8) & 0xF8) == 0xD0) {
++                    if (get_bits_left(&s->gb) >= 8 && (get_bits(&s->gb, 8) & 0xF8) == 0xD0) {
+                         for (i = 0; i < nb_components; i++) /* reset dc */
+                             s->last_dc[i] = 1024;
+                     } else {
+                         skip_bits_long(&s->gb, pos - get_bits_count(&s->gb));
+                     }
                  }
              }
          }
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -115,7 -115,12 +115,12 @@@ static int load_ipmovie_packet(IPMVECon
  
      int chunk_type;
  
 -    if (s->audio_chunk_offset) {
 +    if (s->audio_chunk_offset && s->audio_channels && s->audio_bits) {
+         if (s->audio_type == CODEC_ID_NONE) {
+             av_log(NULL, AV_LOG_ERROR, "Can not read audio packet before"
+                    "audio codec is known\n");
+                 return CHUNK_BAD;
+         }
  
          /* adjust for PCM audio by skipping chunk header */
          if (s->audio_type != CODEC_ID_INTERPLAY_DPCM) {
Simple merge
@@@ -402,8 -362,7 +402,9 @@@ URLProtocol ff_mmsh_protocol = 
      .name           = "mmsh",
      .url_open       = mmsh_open,
      .url_read       = mmsh_read,
 +    .url_seek       = mmsh_seek,
      .url_close      = mmsh_close,
 +    .url_read_seek  = mmsh_read_seek,
      .priv_data_size = sizeof(MMSHContext),
+     .flags          = URL_PROTOCOL_FLAG_NETWORK,
  };
Simple merge
@@@ -595,12 -579,10 +596,10 @@@ static int mov_read_chan(MOVContext *c
      if (atom.size < 16ULL + num_descr * 20ULL)
          return 0;
  
 -    av_dlog(c->fc, "chan: size=%ld version=%u flags=%u layout=%u bitmap=%u num_descr=%u\n",
 +    av_dlog(c->fc, "chan: size=%" PRId64 " version=%u flags=%u layout=%u bitmap=%u num_descr=%u\n",
              atom.size, version, flags, layout_tag, bitmap, num_descr);
  
- #if 0
-     /* TODO: use the channel descriptions if the layout tag is 0 */
-     int i;
+     label_mask = 0;
      for (i = 0; i < num_descr; i++) {
          uint32_t label, cflags;
          float coords[3];
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge