Use libdcp's compress_j2k; move Data into libdcp.
[dcpomatic.git] / src / lib / reel_writer.cc
index 803c2a8ed42ae266518aea5ca05edca905f7a39d..b26ff80640bd83d35e4a8f9d4e0c87218d648fd7 100644 (file)
@@ -54,6 +54,7 @@ using std::string;
 using boost::shared_ptr;
 using boost::optional;
 using boost::dynamic_pointer_cast;
+using dcp::Data;
 
 int const ReelWriter::_info_size = 48;
 
@@ -366,12 +367,18 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr
 
                boost::filesystem::path liberation_normal;
                try {
-                       liberation_normal = shared_path () / "LiberationSans-Regular.ttf";
+                       liberation_normal = shared_path() / "LiberationSans-Regular.ttf";
+                       if (!boost::filesystem::exists (liberation_normal)) {
+                               /* Hack for unit tests */
+                               liberation_normal = shared_path() / "fonts" / "LiberationSans-Regular.ttf";
+                       }
                } catch (boost::filesystem::filesystem_error& e) {
-                       /* Hack: try the debian/ubuntu location if getting the shared path failed */
-                       liberation_normal = "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf";
+
                }
 
+               if (!boost::filesystem::exists(liberation_normal)) {
+                       liberation_normal = "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf";
+               }
 
                /* Add all the fonts to the subtitle content */
                BOOST_FOREACH (shared_ptr<Font> j, fonts) {
@@ -478,7 +485,9 @@ ReelWriter::write (PlayerSubtitles subs)
                }
        }
 
-       for (list<dcp::SubtitleString>::const_iterator i = subs.text.begin(); i != subs.text.end(); ++i) {
-               _subtitle_asset->add (*i);
+       BOOST_FOREACH (dcp::SubtitleString i, subs.text) {
+               i.set_in  (i.in()  - dcp::Time (_period.from.seconds(), i.in().tcr));
+               i.set_out (i.out() - dcp::Time (_period.from.seconds(), i.out().tcr));
+               _subtitle_asset->add (i);
        }
 }