diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-12-20 00:08:20 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-12-22 01:21:00 +0100 |
| commit | 2b5af718d2a1f5da548303c8531afe86fa82d2d8 (patch) | |
| tree | 60195c46e9e872d9daf4b3042fa6d41b0526ee7a | |
| parent | 868078a89decdbc9a9149684364a8ed11e28d309 (diff) | |
A reel should be the length of its main picture, or the shortest other thing if there is no picture.
| -rw-r--r-- | src/reel.cc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/reel.cc b/src/reel.cc index 0a9a4b63..14c0b1e2 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -55,7 +55,7 @@ using std::string; using std::list; using std::cout; -using std::max; +using std::min; using boost::shared_ptr; using boost::dynamic_pointer_cast; using namespace dcp; @@ -325,26 +325,29 @@ Reel::resolve_refs (list<shared_ptr<Asset> > assets) int64_t Reel::duration () const { - int64_t d = 0; - if (_main_picture) { - d = max (d, _main_picture->actual_duration()); + return _main_picture->actual_duration(); } + + int64_t d = INT64_MAX; + if (_main_sound) { - d = max (d, _main_sound->actual_duration()); + d = min (d, _main_sound->actual_duration()); } if (_main_subtitle) { - d = max (d, _main_subtitle->actual_duration()); + d = min (d, _main_subtitle->actual_duration()); } if (_main_markers) { - d = max (d, _main_markers->actual_duration()); + d = min (d, _main_markers->actual_duration()); } BOOST_FOREACH (shared_ptr<ReelClosedCaptionAsset> i, _closed_captions) { - d = max (d, i->actual_duration()); + d = min (d, i->actual_duration()); } if (_atmos) { - d = max (d, _atmos->actual_duration()); + d = min (d, _atmos->actual_duration()); } + DCP_ASSERT (d < INT64_MAX); + return d; } |
