From 82073bde10e2751e9e1376373e91c55ce38d1d9d Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 13 Feb 2019 09:18:01 +0100 Subject: [PATCH] Fix an overflow issue with long (>= 10 min) clips. --- futatabi/player.cpp | 2 +- shared/timebase.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/futatabi/player.cpp b/futatabi/player.cpp index ce165d0..9c20278 100644 --- a/futatabi/player.cpp +++ b/futatabi/player.cpp @@ -181,7 +181,7 @@ void Player::play_playlist_once() } steady_clock::time_point next_frame_start; - for (int frameno = 0; !should_quit; ++frameno) { // Ends when the clip ends. + for (int64_t frameno = 0; !should_quit; ++frameno) { // Ends when the clip ends. double out_pts = out_pts_origin + TIMEBASE * frameno / global_flags.output_framerate; next_frame_start = origin + microseconds(lrint((out_pts - out_pts_origin) * 1e6 / TIMEBASE)); diff --git a/shared/timebase.h b/shared/timebase.h index 532ec86..ba20d7f 100644 --- a/shared/timebase.h +++ b/shared/timebase.h @@ -3,6 +3,8 @@ #include +#include + // Common timebase that allows us to represent one frame exactly in all the // relevant frame rates: // @@ -15,7 +17,7 @@ // If we also wanted to represent one sample at 48000 Hz, we'd need // to go to 300000. Also supporting one sample at 44100 Hz would mean // going to 44100000; probably a bit excessive. -#define TIMEBASE 120000 +constexpr uint64_t TIMEBASE = 120000; // Some muxes, like MP4 (or at least avformat's implementation of it), // are not too fond of values above 2^31. At timebase 120000, that's only -- 2.39.2