summaryrefslogtreecommitdiffstats
path: root/player/video.c
diff options
context:
space:
mode:
Diffstat (limited to 'player/video.c')
-rw-r--r--player/video.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/player/video.c b/player/video.c
index 5e0266b8d0..1ceda1f999 100644
--- a/player/video.c
+++ b/player/video.c
@@ -1291,11 +1291,10 @@ static void calculate_frame_duration(struct MPContext *mpctx)
// The following code tries to compensate for rounded Matroska timestamps
// by "unrounding" frame durations, or if not possible, approximating them.
- // These formats usually round on 1ms. (Some muxers do this incorrectly,
- // and might be off by 2ms or more, and compensate for it later by an
- // equal rounding error into the opposite direction. Don't try to deal
- // with them; too much potential damage to timing.)
- double tolerance = 0.0011;
+ // These formats usually round on 1ms. Some muxers do this incorrectly,
+ // and might go off by 1ms more, and compensate for it later by an equal
+ // rounding error into the opposite direction.
+ double tolerance = 0.001 * 3 + 0.0001;
double total = 0;
int num_dur = 0;
@@ -1314,7 +1313,7 @@ static void calculate_frame_duration(struct MPContext *mpctx)
// Note that even if each timestamp is within rounding tolerance, it
// could literally not add up (e.g. if demuxer FPS is rounded itself).
if (fabs(duration - demux_duration) < tolerance &&
- fabs(total - demux_duration * num_dur) < tolerance)
+ fabs(total - demux_duration * num_dur) < tolerance && num_dur >= 16)
{
approx_duration = demux_duration;
}
@@ -1322,6 +1321,9 @@ static void calculate_frame_duration(struct MPContext *mpctx)
mpctx->past_frames[0].duration = duration;
mpctx->past_frames[0].approx_duration = approx_duration;
+
+ MP_STATS(mpctx, "value %f frame-duration", MPMAX(0, duration));
+ MP_STATS(mpctx, "value %f frame-duration-approx", MPMAX(0, approx_duration));
}
void write_video(struct MPContext *mpctx)