Merge commit 'd1016dccdcb10486245e5d7c186cc31af54b2a9c'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 4 Apr 2013 12:20:51 +0000 (14:20 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 4 Apr 2013 12:20:51 +0000 (14:20 +0200)
* commit 'd1016dccdcb10486245e5d7c186cc31af54b2a9c':
  xmv: check audio track parameters validity.
  bmv: check for len being valid in bmv_decode_frame().

Conflicts:
libavformat/xmv.c

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

Simple merge
@@@ -124,6 -126,16 +124,15 @@@ static int xmv_probe(AVProbeData *p
      return 0;
  }
  
 -    av_free(xmv->audio);
 -    av_free(xmv->audio_tracks);
+ static int xmv_read_close(AVFormatContext *s)
+ {
+     XMVDemuxContext *xmv = s->priv_data;
++    av_freep(&xmv->audio);
+     return 0;
+ }
  static int xmv_read_header(AVFormatContext *s)
  {
      XMVDemuxContext *xmv = s->priv_data;
          return AVERROR(ENOMEM);
  
      for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
 -        XMVAudioTrack  *track  = &xmv->audio_tracks[audio_track];
 -        XMVAudioPacket *packet = &xmv->audio       [audio_track];
 +        XMVAudioPacket *packet = &xmv->audio[audio_track];
          AVStream *ast = NULL;
  
 -        track->compression     = avio_rl16(pb);
 -        track->channels        = avio_rl16(pb);
 -        track->sample_rate     = avio_rl32(pb);
 -        track->bits_per_sample = avio_rl16(pb);
 -        track->flags           = avio_rl16(pb);
 -
 -        track->bit_rate      = track->bits_per_sample *
 -                               track->sample_rate *
 -                               track->channels;
 -        track->block_align   = 36 * track->channels;
 -        track->block_samples = 64;
 -        track->codec_id      = ff_wav_codec_get_id(track->compression,
 -                                                   track->bits_per_sample);
 -
 -        packet->track        = track;
 +        packet->compression     = avio_rl16(pb);
 +        packet->channels        = avio_rl16(pb);
 +        packet->sample_rate     = avio_rl32(pb);
 +        packet->bits_per_sample = avio_rl16(pb);
 +        packet->flags           = avio_rl16(pb);
 +
-         if (!packet->channels) {
-             av_log(s, AV_LOG_ERROR, "0 channels\n");
-             return AVERROR(EINVAL);
-         }
 +        packet->bit_rate      = packet->bits_per_sample *
 +                                packet->sample_rate *
 +                                packet->channels;
 +        packet->block_align   = 36 * packet->channels;
 +        packet->block_samples = 64;
 +        packet->codec_id      = ff_wav_codec_get_id(packet->compression,
 +                                                    packet->bits_per_sample);
 +
          packet->stream_index = -1;
  
          packet->frame_size  = 0;
  
          /* TODO: ADPCM'd 5.1 sound is encoded in three separate streams.
           *       Those need to be interleaved to a proper 5.1 stream. */
 -        if (track->flags & XMV_AUDIO_ADPCM51)
 +        if (packet->flags & XMV_AUDIO_ADPCM51)
              av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream "
 -                                      "(0x%04X)\n", track->flags);
 +                                      "(0x%04X)\n", packet->flags);
  
 -        if (!track->channels || !track->sample_rate) {
++        if (!packet->channels || !packet->sample_rate) {
+             av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %d.\n",
+                    audio_track);
+             ret = AVERROR_INVALIDDATA;
+             goto fail;
+         }
          ast = avformat_new_stream(s, NULL);
          if (!ast)
              return AVERROR(ENOMEM);