Merge master into direct-mxf.
[dcpomatic.git] / src / lib / format.cc
index eb42593feada4da576d645842bbd44cb13d60b42..016c21fdea09fb60d45636f91d2ee9b5d888879b 100644 (file)
@@ -35,6 +35,7 @@ using std::setprecision;
 using std::stringstream;
 using std::vector;
 using boost::shared_ptr;
+using libdcp::Size;
 
 vector<Format const *> Format::_formats;
 
@@ -67,18 +68,19 @@ Format::as_metadata () const
 void
 Format::setup_formats ()
 {
-       _formats.push_back (new FixedFormat (119, Size (1285, 1080), "119", "1.19", "F"));
-       _formats.push_back (new FixedFormat (133, Size (1436, 1080), "133", "1.33", "F"));
-       _formats.push_back (new FixedFormat (138, Size (1485, 1080), "138", "1.375", "F"));
-       _formats.push_back (new FixedFormat (133, Size (1998, 1080), "133-in-flat", "4:3 within Flat", "F"));
-       _formats.push_back (new FixedFormat (137, Size (1480, 1080), "137", "Academy", "F"));
-       _formats.push_back (new FixedFormat (166, Size (1793, 1080), "166", "1.66", "F"));
-       _formats.push_back (new FixedFormat (166, Size (1998, 1080), "166-in-flat", "1.66 within Flat", "F"));
-       _formats.push_back (new FixedFormat (178, Size (1998, 1080), "178-in-flat", "16:9 within Flat", "F"));
-       _formats.push_back (new FixedFormat (185, Size (1998, 1080), "185", "Flat", "F"));
-       _formats.push_back (new FixedFormat (239, Size (2048, 858), "239", "Scope", "S"));
-       _formats.push_back (new VariableFormat (Size (1998, 1080), "var-185", "Flat", "F"));
-       _formats.push_back (new VariableFormat (Size (2048, 858), "var-239", "Scope", "S"));
+       _formats.push_back (new FixedFormat (119, libdcp::Size (1285, 1080), "119", "1.19", "F"));
+       _formats.push_back (new FixedFormat (133, libdcp::Size (1436, 1080), "133", "1.33", "F"));
+       _formats.push_back (new FixedFormat (138, libdcp::Size (1485, 1080), "138", "1.375", "F"));
+       _formats.push_back (new FixedFormat (133, libdcp::Size (1998, 1080), "133-in-flat", "4:3 within Flat", "F"));
+       _formats.push_back (new FixedFormat (137, libdcp::Size (1480, 1080), "137", "Academy", "F"));
+       _formats.push_back (new FixedFormat (166, libdcp::Size (1793, 1080), "166", "1.66", "F"));
+       _formats.push_back (new FixedFormat (166, libdcp::Size (1998, 1080), "166-in-flat", "1.66 within Flat", "F"));
+       _formats.push_back (new FixedFormat (178, libdcp::Size (1998, 1080), "178-in-flat", "16:9 within Flat", "F"));
+       _formats.push_back (new FixedFormat (178, libdcp::Size (1920, 1080), "178", "16:9", "F"));
+       _formats.push_back (new FixedFormat (185, libdcp::Size (1998, 1080), "185", "Flat", "F"));
+       _formats.push_back (new FixedFormat (239, libdcp::Size (2048, 858), "239", "Scope", "S"));
+       _formats.push_back (new VariableFormat (libdcp::Size (1998, 1080), "var-185", "Flat", "F"));
+       _formats.push_back (new VariableFormat (libdcp::Size (2048, 858), "var-239", "Scope", "S"));
 }
 
 /** @param n Nickname.
@@ -139,13 +141,16 @@ Format::all ()
  *  @param id ID (e.g. 185)
  *  @param n Nick name (e.g. Flat)
  */
-FixedFormat::FixedFormat (int r, Size dcp, string id, string n, string d)
+FixedFormat::FixedFormat (int r, libdcp::Size dcp, string id, string n, string d)
        : Format (dcp, id, n, d)
        , _ratio (r)
 {
 
 }
 
+/** @return Number of pixels (int the DCP image) to pad either side of the film
+ *  (so there are dcp_padding() pixels on the left and dcp_padding() on the right)
+ */
 int
 Format::dcp_padding (shared_ptr<const Film> f) const
 {
@@ -159,7 +164,13 @@ Format::dcp_padding (shared_ptr<const Film> f) const
        return p;
 }
 
-VariableFormat::VariableFormat (Size dcp, string id, string n, string d)
+float
+Format::container_ratio_as_float () const
+{
+       return static_cast<float> (_dcp_size.width) / _dcp_size.height;
+}
+
+VariableFormat::VariableFormat (libdcp::Size dcp, string id, string n, string d)
        : Format (dcp, id, n, d)
 {