Add option to export Interop subs with or without the font file / reference.
authorCarl Hetherington <cth@carlh.net>
Tue, 25 Aug 2020 20:00:06 +0000 (22:00 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 25 Aug 2020 20:00:06 +0000 (22:00 +0200)
src/lib/subtitle_encoder.cc
src/lib/subtitle_encoder.h
src/tools/dcpomatic.cc
src/wx/export_subtitles_dialog.cc
src/wx/export_subtitles_dialog.h

index 2daa5086dda6c2a529c4420f4fb8c5f0525be99e..a94b9106ab5266ab4e3f45e9f6c385c8a2485f5c 100644 (file)
@@ -18,6 +18,7 @@
 
 */
 
+#include "font.h"
 #include "subtitle_encoder.h"
 #include "player.h"
 #include "compose.hpp"
@@ -39,9 +40,11 @@ using boost::shared_ptr;
 using boost::optional;
 using dcp::raw_convert;
 
-SubtitleEncoder::SubtitleEncoder (shared_ptr<const Film> film, shared_ptr<Job> job, boost::filesystem::path output, bool split_reels)
+/** @param include_font true to refer to and export any font file (for Interop; ignored for SMPTE) */
+SubtitleEncoder::SubtitleEncoder (shared_ptr<const Film> film, shared_ptr<Job> job, boost::filesystem::path output, bool split_reels, bool include_font)
        : Encoder (film, job)
        , _split_reels (split_reels)
+       , _include_font (include_font)
        , _reel_index (0)
        , _length (film->length())
 {
@@ -101,6 +104,12 @@ SubtitleEncoder::go ()
                        }
                }
 
+               if (!_film->interop() || _include_font) {
+                       BOOST_FOREACH (shared_ptr<dcpomatic::Font> j, _player->get_subtitle_fonts()) {
+                               i->first->add_font (j->id(), default_font_file());
+                       }
+               }
+
                i->first->write (i->second);
                ++reel;
        }
@@ -145,6 +154,9 @@ SubtitleEncoder::text (PlayerText subs, TextType type, optional<DCPTextTrack> tr
                /* XXX: couldn't / shouldn't we use period here rather than getting time from the subtitle? */
                i.set_in  (i.in());
                i.set_out (i.out());
+               if (_film->interop() && !_include_font) {
+                       i.unset_font ();
+               }
                _assets[_reel_index].first->add (shared_ptr<dcp::Subtitle>(new dcp::SubtitleString(i)));
        }
 
index 50485750d2ee146da8b0f57430aa52d2635eabfd..b267c9bae0b620244d50bd9aff88f9078a2112e0 100644 (file)
@@ -37,7 +37,7 @@ class Film;
 class SubtitleEncoder : public Encoder
 {
 public:
-       SubtitleEncoder (boost::shared_ptr<const Film> film, boost::shared_ptr<Job> job, boost::filesystem::path output, bool split_reels);
+       SubtitleEncoder (boost::shared_ptr<const Film> film, boost::shared_ptr<Job> job, boost::filesystem::path output, bool split_reels, bool include_font);
 
        void go ();
 
@@ -54,6 +54,7 @@ private:
        std::vector<std::pair<boost::shared_ptr<dcp::SubtitleAsset>, boost::filesystem::path> > _assets;
        std::vector<dcpomatic::DCPTimePeriod> _reels;
        bool _split_reels;
+       bool _include_font;
        int _reel_index;
        boost::optional<dcpomatic::DCPTime> _last;
        dcpomatic::DCPTime _length;
index 9401bc3405f8e995551f2fdd74fc39a3f943f62f..5c32fd487b735ee22200ae4aed35a6b6d5ffee1b 100644 (file)
@@ -990,7 +990,7 @@ private:
 
        void jobs_export_subtitles ()
        {
-               ExportSubtitlesDialog* d = new ExportSubtitlesDialog (this, _film->isdcf_name(true));
+               ExportSubtitlesDialog* d = new ExportSubtitlesDialog (this, _film->isdcf_name(true), _film->interop());
                if (d->ShowModal() == wxID_OK) {
                        if (boost::filesystem::exists(d->path())) {
                                bool ok = confirm_dialog(
@@ -1006,7 +1006,7 @@ private:
 
                        shared_ptr<TranscodeJob> job (new TranscodeJob (_film));
                        job->set_encoder (
-                               shared_ptr<SubtitleEncoder>(new SubtitleEncoder(_film, job, d->path(), d->split_reels()))
+                               shared_ptr<SubtitleEncoder>(new SubtitleEncoder(_film, job, d->path(), d->split_reels(), d->include_font()))
                                );
                        JobManager::instance()->add (job);
                }
index 83e08feb495d69584cfedb386093cc7f10265b1e..bcc8adbe14e1fd9ca9c3bceb9a47a6b90ca05c88 100644 (file)
@@ -34,13 +34,19 @@ using std::string;
 using boost::bind;
 
 
-ExportSubtitlesDialog::ExportSubtitlesDialog (wxWindow* parent, string name)
+ExportSubtitlesDialog::ExportSubtitlesDialog (wxWindow* parent, string name, bool interop)
        : TableDialog (parent, _("Export subtitles"), 2, 1, true)
        , _initial_name (name)
+       , _include_font (0)
 {
        _split_reels = new CheckBox (this, _("Write reels into separate files"));
        add (_split_reels, false);
        add_spacer ();
+       if (interop) {
+               _include_font = new CheckBox (this, _("Define font in output and export font file"));
+               add (_include_font, false);
+               add_spacer ();
+       }
 
        add (_("Output file"), true);
        /* Don't warn overwrite here, because on Linux (at least) if we specify a filename like foo
@@ -77,10 +83,17 @@ ExportSubtitlesDialog::split_reels () const
 }
 
 
+bool
+ExportSubtitlesDialog::include_font () const
+{
+       return _include_font ? _include_font->GetValue () : true;
+}
+
+
 void
 ExportSubtitlesDialog::file_changed ()
 {
-       wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
+       wxButton* ok = dynamic_cast<wxButton *> (FindWindowById(wxID_OK, this));
        DCPOMATIC_ASSERT (ok);
        ok->Enable (path().is_absolute());
 }
index d4405cb29957ec5683822a88dce8857c5c70d0cf..ee55729f731eb9ab4787eee975c4292f8c8f249a 100644 (file)
@@ -27,15 +27,17 @@ class FilePickerCtrl;
 class ExportSubtitlesDialog : public TableDialog
 {
 public:
-       ExportSubtitlesDialog (wxWindow* parent, std::string name);
+       ExportSubtitlesDialog (wxWindow* parent, std::string name, bool interop);
 
        boost::filesystem::path path () const;
        bool split_reels () const;
+       bool include_font () const;
 
 private:
        void file_changed ();
 
        std::string _initial_name;
        wxCheckBox* _split_reels;
+       wxCheckBox* _include_font;
        FilePickerCtrl* _file;
 };