diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-09-03 23:34:32 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-09-03 23:34:32 +0100 |
| commit | 4a33cfc3b4c51d4e047879051d70ae56ec8ee6e1 (patch) | |
| tree | f0d60dd160db8f0b9efd3c3ab2d8581d1b4d7401 /src/lib | |
| parent | 5db632783b3eba64d39538d1f29ccfe26adaaf19 (diff) | |
Put the right 'actual' ratio in DCP titles even with no-stretch and no-scale.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 18 | ||||
| -rw-r--r-- | src/lib/ratio.cc | 17 | ||||
| -rw-r--r-- | src/lib/ratio.h | 1 |
3 files changed, 29 insertions, 7 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 2701d81b8..b4d12a062 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -580,18 +580,22 @@ Film::isdcf_name (bool if_created_now) const d << "_" << container()->isdcf_name(); } - /* XXX: this only works for content which has been scaled to a given ratio, - and uses the first bit of content only. - */ + /* XXX: this uses the first bit of content only */ /* The standard says we don't do this for trailers, for some strange reason */ if (dcp_content_type() && dcp_content_type()->libdcp_kind() != libdcp::TRAILER) { - ContentList cl = content (); Ratio const * content_ratio = 0; - for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) { + ContentList cl = content (); + for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) { shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*i); - if (vc && (content_ratio == 0 || vc->scale().ratio() != content_ratio)) { - content_ratio = vc->scale().ratio(); + if (vc) { + /* Here's the first piece of video content */ + if (vc->scale().ratio ()) { + content_ratio = vc->scale().ratio (); + } else { + content_ratio = Ratio::from_ratio (vc->video_size().ratio ()); + } + break; } } diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc index 4a5b39a22..554d3c36c 100644 --- a/src/lib/ratio.cc +++ b/src/lib/ratio.cc @@ -56,3 +56,20 @@ Ratio::from_id (string i) return *j; } + +/** @return Ratio corresponding to a given fractional ratio (+/- 0.01), or 0 */ +Ratio const * +Ratio::from_ratio (float r) +{ + vector<Ratio const *>::iterator j = _ratios.begin (); + while (j != _ratios.end() && fabs ((*j)->ratio() - r) > 0.01) { + ++j; + } + + if (j == _ratios.end ()) { + return 0; + } + + return *j; +} + diff --git a/src/lib/ratio.h b/src/lib/ratio.h index 8b1a1fc71..ab157a9bc 100644 --- a/src/lib/ratio.h +++ b/src/lib/ratio.h @@ -52,6 +52,7 @@ public: static void setup_ratios (); static Ratio const * from_id (std::string i); + static Ratio const * from_ratio (float r); static std::vector<Ratio const *> all () { return _ratios; } |
