Merge commit 'f1bdc234370401c032cd85184e93c7c155eb6d62'
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 12 Jul 2015 14:23:27 +0000 (16:23 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 12 Jul 2015 14:23:42 +0000 (16:23 +0200)
* commit 'f1bdc234370401c032cd85184e93c7c155eb6d62':
  riff: Validate bitrate

Conflicts:
libavformat/riffdec.c

See: 189420cb561929e05f5cc4224cdca83740a24a32
Merged-by: Michael Niedermayer <michael@niedermayer.cc>
1  2 
libavformat/riffdec.c

@@@ -82,48 -75,25 +82,41 @@@ static void parse_waveformatex(AVIOCont
      }
  }
  
 +/* "big_endian" values are needed for RIFX file format */
  int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
 -                      AVCodecContext *codec, int size)
 +                      AVCodecContext *codec, int size, int big_endian)
  {
      int id;
+     uint64_t bitrate;
  
 -    if (size < 14)
 +    if (size < 14) {
 +        avpriv_request_sample(codec, "wav header size < 14");
          return AVERROR_INVALIDDATA;
 +    }
  
 -    id                 = avio_rl16(pb);
      codec->codec_type  = AVMEDIA_TYPE_AUDIO;
 -    codec->channels    = avio_rl16(pb);
 -    codec->sample_rate = avio_rl32(pb);
 -    bitrate            = avio_rl32(pb) * 8;
 -    codec->block_align = avio_rl16(pb);
 +    if (!big_endian) {
 +        id                 = avio_rl16(pb);
 +        codec->channels    = avio_rl16(pb);
 +        codec->sample_rate = avio_rl32(pb);
-         codec->bit_rate    = avio_rl32(pb) * 8;
++        bitrate            = avio_rl32(pb) * 8;
 +        codec->block_align = avio_rl16(pb);
 +    } else {
 +        id                 = avio_rb16(pb);
 +        codec->channels    = avio_rb16(pb);
 +        codec->sample_rate = avio_rb32(pb);
-         codec->bit_rate    = avio_rb32(pb) * 8;
++        bitrate            = avio_rb32(pb) * 8;
 +        codec->block_align = avio_rb16(pb);
 +    }
-     if (codec->bit_rate < 0) {
-         av_log(s, AV_LOG_WARNING,
-                "Invalid bit rate: %d\n", codec->bit_rate);
-         if (s->error_recognition & AV_EF_EXPLODE)
-             return AVERROR_INVALIDDATA;
-         else
-             codec->bit_rate = 0;
-     }
      if (size == 14) {  /* We're dealing with plain vanilla WAVEFORMAT */
          codec->bits_per_coded_sample = 8;
 -    } else
 -        codec->bits_per_coded_sample = avio_rl16(pb);
 +    } else {
 +        if (!big_endian) {
 +            codec->bits_per_coded_sample = avio_rl16(pb);
 +        } else {
 +            codec->bits_per_coded_sample = avio_rb16(pb);
 +        }
 +    }
      if (id == 0xFFFE) {
          codec->codec_tag = 0;
      } else {