2 Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "frame_interval_checker.h"
23 using namespace dcpomatic;
25 int const FrameIntervalChecker::_frames = 16;
28 FrameIntervalChecker::feed (ContentTime time, double frame_rate)
30 /* The caller isn't meant to feed too much data before
31 calling guess() and destroying the FrameIntervalChecker.
33 DCPOMATIC_ASSERT (_intervals.size() < _frames);
36 _intervals.push_back ((time - *_last).seconds() * frame_rate);
42 FrameIntervalChecker::Guess
43 FrameIntervalChecker::guess () const
45 if (_intervals.size() < _frames) {
46 /* How soon can you land?
48 * You can tell me, I'm a doctor.
49 * Nom I mean I'm just not sure.
50 * Can't you take a guess?
51 * Well, not for another two hours.
52 * You can't take a guess for another two hours?
58 BOOST_FOREACH (double i, _intervals) {
64 return (near_1 < 3 * _frames / 4) ? PROBABLY_3D : PROBABLY_NOT_3D;