diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-12-15 21:40:13 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-12-15 21:43:19 +0100 |
commit | d600b18f224e02f8bfc6660bfa442e7ff3fb057c (patch) | |
tree | f004cb81e25e804181fbc53737cd9c5d021cec5c | |
parent | 476aceaa22a0f68d69fe8477f9ee98bf212d222c (diff) | |
download | ffmpeg-d600b18f224e02f8bfc6660bfa442e7ff3fb057c.tar.gz |
avformat/utils: limit rfps to values larger than fps
This avoids some nonsense values being produced by totally corrupted input
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/avformat.h | 1 | ||||
-rw-r--r-- | libavformat/utils.c | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6bd54cec64..52eef0dd5a 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -756,6 +756,7 @@ typedef struct AVStream { int64_t last_dts; int64_t duration_gcd; int duration_count; + int64_t rfps_duration_sum; double (*duration_error)[2][MAX_STD_TIMEBASES]; int64_t codec_info_duration; int64_t codec_info_duration_fields; diff --git a/libavformat/utils.c b/libavformat/utils.c index 8687cff584..7f19abc5f1 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2731,6 +2731,7 @@ int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t ts) } } st->info->duration_count++; + st->info->rfps_duration_sum += duration; if (st->info->duration_count % 10 == 0) { int n = st->info->duration_count; @@ -2784,6 +2785,10 @@ void ff_rfps_calculate(AVFormatContext *ic) continue; if(!st->info->codec_info_duration && 1.0 < (1001*12.0)/get_std_framerate(j)) continue; + + if (av_q2d(st->time_base) * st->info->rfps_duration_sum / st->info->duration_count < (1001*12.0 * 0.8)/get_std_framerate(j)) + continue; + for(k=0; k<2; k++){ int n= st->info->duration_count; double a= st->info->duration_error[k][0][j] / n; @@ -2805,6 +2810,7 @@ void ff_rfps_calculate(AVFormatContext *ic) av_freep(&st->info->duration_error); st->info->last_dts = AV_NOPTS_VALUE; st->info->duration_count = 0; + st->info->rfps_duration_sum = 0; } } |