Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 15 Jul 2013 22:39:33 +0000 (00:39 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 15 Jul 2013 22:55:07 +0000 (00:55 +0200)
* qatar/master:
  lavf: Make sure avg_frame_rate can be calculated without integer overflow

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

@@@ -2954,9 -2355,12 +2954,12 @@@ int avformat_find_stream_info(AVFormatC
                  int      best_fps = 0;
                  double best_error = 0.01;
  
 -                if (delta_dts     >= INT64_MAX / st->time_base.num ||
 -                    delta_packets >= INT64_MAX / st->time_base.den)
++                if (st->info->codec_info_duration        >= INT64_MAX / st->time_base.num / 2||
++                    st->info->codec_info_duration_fields >= INT64_MAX / st->time_base.den)
+                     continue;
                  av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
 -                          delta_packets*(int64_t)st->time_base.den,
 -                          delta_dts*(int64_t)st->time_base.num, 60000);
 +                          st->info->codec_info_duration_fields*(int64_t)st->time_base.den,
 +                          st->info->codec_info_duration*2*(int64_t)st->time_base.num, 60000);
  
                  /* round guessed framerate to a "standard" framerate if it's
                   * within 1% of the original estimate*/