Add basic quality option for x264 export.
[dcpomatic.git] / src / tools / dcpomatic.cc
index 416bdf6c4168afa0d733f0e7384fffae5a9cd129..3d4e5121d6fbca1abc61276c008a0e007844a727 100644 (file)
@@ -71,7 +71,8 @@
 #include "lib/transcode_job.h"
 #include "lib/dkdm_wrapper.h"
 #include "lib/audio_content.h"
-#include "lib/caption_content.h"
+#include "lib/check_content_change_job.h"
+#include "lib/text_content.h"
 #include <dcp/exceptions.h>
 #include <dcp/raw_convert.h>
 #include <wx/generic/aboutdlgg.h>
@@ -212,7 +213,8 @@ enum {
        ID_jobs_send_dcp_to_tms,
        ID_jobs_show_dcp,
        ID_jobs_open_dcp_in_player,
-       ID_tools_video_waveform,
+       ID_view_closed_captions,
+       ID_view_video_waveform,
        ID_tools_hints,
        ID_tools_encoding_servers,
        ID_tools_manage_templates,
@@ -297,7 +299,8 @@ public:
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_send_dcp_to_tms, this),    ID_jobs_send_dcp_to_tms);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_show_dcp, this),           ID_jobs_show_dcp);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_open_dcp_in_player, this), ID_jobs_open_dcp_in_player);
-               Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_video_waveform, this),    ID_tools_video_waveform);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_closed_captions, this),    ID_view_closed_captions);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_video_waveform, this),     ID_view_video_waveform);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_hints, this),             ID_tools_hints);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_encoding_servers, this),  ID_tools_encoding_servers);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_manage_templates, this),  ID_tools_manage_templates);
@@ -412,6 +415,8 @@ public:
                }
 
                set_film (film);
+
+               JobManager::instance()->add(shared_ptr<Job>(new CheckContentChangeJob(film)));
        }
        catch (std::exception& e) {
                wxString p = std_to_wx (file.string ());
@@ -424,13 +429,15 @@ public:
                _film = film;
                _film_viewer->set_film (_film);
                _film_editor->set_film (_film);
-               delete _video_waveform_dialog;
-               _video_waveform_dialog = 0;
+               if (_video_waveform_dialog) {
+                       _video_waveform_dialog->Destroy ();
+                       _video_waveform_dialog = 0;
+               }
                set_menu_sensitivity ();
                if (_film->directory()) {
                        Config::instance()->add_to_history (_film->directory().get());
                }
-               _film->Changed.connect (boost::bind (&DOMFrame::set_menu_sensitivity, this));
+               _film->Change.connect (boost::bind (&DOMFrame::film_change, this, _1));
        }
 
        shared_ptr<Film> film () const {
@@ -439,6 +446,13 @@ public:
 
 private:
 
+       void film_change (ChangeType type)
+       {
+               if (type == CHANGE_TYPE_DONE) {
+                       set_menu_sensitivity ();
+               }
+       }
+
        void file_changed (boost::filesystem::path f)
        {
                string s = wx_to_std (_("DCP-o-matic"));
@@ -563,7 +577,7 @@ private:
        {
                DCPOMATIC_ASSERT (_clipboard);
 
-               PasteDialog* d = new PasteDialog (this, static_cast<bool>(_clipboard->video), static_cast<bool>(_clipboard->audio), !_clipboard->caption.empty());
+               PasteDialog* d = new PasteDialog (this, static_cast<bool>(_clipboard->video), static_cast<bool>(_clipboard->audio), !_clipboard->text.empty());
                if (d->ShowModal() == wxID_OK) {
                        BOOST_FOREACH (shared_ptr<Content> i, _film_editor->content_panel()->selected()) {
                                if (d->video() && i->video) {
@@ -575,10 +589,10 @@ private:
                                        i->audio->take_settings_from (_clipboard->audio);
                                }
 
-                               if (d->caption()) {
-                                       list<shared_ptr<CaptionContent> >::iterator j = i->caption.begin ();
-                                       list<shared_ptr<CaptionContent> >::const_iterator k = _clipboard->caption.begin ();
-                                       while (j != i->caption.end() && k != _clipboard->caption.end()) {
+                               if (d->text()) {
+                                       list<shared_ptr<TextContent> >::iterator j = i->text.begin ();
+                                       list<shared_ptr<TextContent> >::const_iterator k = _clipboard->text.begin ();
+                                       while (j != i->text.end() && k != _clipboard->text.end()) {
                                                (*j)->take_settings_from (*k);
                                                ++j;
                                                ++k;
@@ -632,7 +646,7 @@ private:
                        }
                }
 
-               if (!get_hints(_film).empty() && Config::instance()->show_hints_before_make_dcp()) {
+               if (Config::instance()->show_hints_before_make_dcp()) {
                        HintsDialog* hints = new HintsDialog (this, _film, false);
                        int const r = hints->ShowModal();
                        hints->Destroy ();
@@ -731,7 +745,7 @@ private:
                        return;
                }
 
-               if (!get_hints(_film).empty() && Config::instance()->show_hints_before_make_dcp()) {
+               if (Config::instance()->show_hints_before_make_dcp()) {
                        HintsDialog* hints = new HintsDialog (this, _film, false);
                        int const r = hints->ShowModal();
                        hints->Destroy ();
@@ -820,7 +834,7 @@ private:
                ExportDialog* d = new ExportDialog (this);
                if (d->ShowModal() == wxID_OK) {
                        shared_ptr<TranscodeJob> job (new TranscodeJob (_film));
-                       job->set_encoder (shared_ptr<FFmpegEncoder> (new FFmpegEncoder (_film, job, d->path(), d->format(), d->mixdown_to_stereo())));
+                       job->set_encoder (shared_ptr<FFmpegEncoder> (new FFmpegEncoder (_film, job, d->path(), d->format(), d->mixdown_to_stereo(), d->x264_crf())));
                        JobManager::instance()->add (job);
                }
                d->Destroy ();
@@ -882,7 +896,12 @@ private:
 #endif
        }
 
-       void tools_video_waveform ()
+       void view_closed_captions ()
+       {
+               _film_viewer->show_closed_captions ();
+       }
+
+       void view_video_waveform ()
        {
                if (!_video_waveform_dialog) {
                        _video_waveform_dialog = new VideoWaveformDialog (this, _film, _film_viewer);
@@ -1141,8 +1160,11 @@ private:
                add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL);
                add_item (jobs_menu, _("Open DCP in &player"), ID_jobs_open_dcp_in_player, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL);
 
+               wxMenu* view = new wxMenu;
+               add_item (view, _("Closed captions..."), ID_view_closed_captions, NEEDS_FILM);
+               add_item (view, _("Video waveform..."), ID_view_video_waveform, NEEDS_FILM);
+
                wxMenu* tools = new wxMenu;
-               add_item (tools, _("Video waveform..."), ID_tools_video_waveform, NEEDS_FILM);
                add_item (tools, _("Hints..."), ID_tools_hints, 0);
                add_item (tools, _("Encoding servers..."), ID_tools_encoding_servers, 0);
                add_item (tools, _("Manage templates..."), ID_tools_manage_templates, 0);
@@ -1162,6 +1184,7 @@ private:
                m->Append (edit, _("&Edit"));
                m->Append (content, _("&Content"));
                m->Append (jobs_menu, _("&Jobs"));
+               m->Append (view, _("&View"));
                m->Append (tools, _("&Tools"));
                m->Append (help, _("&Help"));
        }