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;
}
}
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;
+}
+
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;
}