Add default scale-to (#664).
authorCarl Hetherington <cth@carlh.net>
Fri, 12 May 2017 21:54:17 +0000 (22:54 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 12 May 2017 21:54:17 +0000 (22:54 +0100)
ChangeLog
src/lib/config.cc
src/lib/config.h
src/lib/video_content.cc
src/wx/config_dialog.cc

index d4d1b56b20fe9d5ca4619c82f680a9b7723c99d0..e7e9684543ccbff40c61c48b339c9c2925472e32 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-05-12  Carl Hetherington  <cth@carlh.net>
+
+       * Add option for default scale-to (#664).
+
 2017-05-11  Carl Hetherington  <cth@carlh.net>
 
        * Updated cs_CZ translation from Tomáš Begeni.
index a19a60f55aa06d5d16072f2cacea23f5bdd4ced6..1baba956e3bdc0efb47aeb03e94243a6fdcee667 100644 (file)
@@ -88,6 +88,7 @@ Config::set_defaults ()
        _language = optional<string> ();
        _default_still_length = 10;
        _default_container = Ratio::from_id ("185");
+       _default_scale_to = 0;
        _default_dcp_content_type = DCPContentType::from_isdcf_name ("FTR");
        _default_dcp_audio_channels = 6;
        _default_j2k_bandwidth = 100000000;
@@ -221,6 +222,11 @@ try
                _default_container = Ratio::from_id (c.get ());
        }
 
+       c = f.optional_string_child ("DefaultScaleTo");
+       if (c) {
+               _default_scale_to = Ratio::from_id (c.get ());
+       }
+
        c = f.optional_string_child ("DefaultDCPContentType");
        if (c) {
                _default_dcp_content_type = DCPContentType::from_isdcf_name (c.get ());
@@ -439,6 +445,9 @@ Config::write_config () const
        if (_default_container) {
                root->add_child("DefaultContainer")->add_child_text (_default_container->id ());
        }
+       if (_default_scale_to) {
+               root->add_child("DefaultScaleTo")->add_child_text (_default_scale_to->id ());
+       }
        if (_default_dcp_content_type) {
                root->add_child("DefaultDCPContentType")->add_child_text (_default_dcp_content_type->isdcf_name ());
        }
index fc6315242b21d084ccdf94c696dbb039296d648e..4406f164993915b12e987fb790213820f5e93d8d 100644 (file)
@@ -163,6 +163,10 @@ public:
                return _default_container;
        }
 
+       Ratio const * default_scale_to () const {
+               return _default_scale_to;
+       }
+
        DCPContentType const * default_dcp_content_type () const {
                return _default_dcp_content_type;
        }
@@ -431,6 +435,10 @@ public:
                maybe_set (_default_container, c);
        }
 
+       void set_default_scale_to (Ratio const * c) {
+               maybe_set (_default_scale_to, c);
+       }
+
        void set_default_dcp_content_type (DCPContentType const * t) {
                maybe_set (_default_dcp_content_type, t);
        }
@@ -697,6 +705,7 @@ private:
        /** Default length of still image content (seconds) */
        int _default_still_length;
        Ratio const * _default_container;
+       Ratio const * _default_scale_to;
        DCPContentType const * _default_dcp_content_type;
        int _default_dcp_audio_channels;
        std::string _dcp_issuer;
index 36438fc2a9041f34ec31027fd4c76ffb5f541746..8ccb921d04b06b932e63885be9adc302a0044b3d 100644 (file)
@@ -241,10 +241,14 @@ VideoContent::take_from_examiner (shared_ptr<VideoExaminer> d)
                _sample_aspect_ratio = ar;
                _yuv = yuv;
 
-               /* Guess correct scale from size and sample aspect ratio */
-               _scale = VideoContentScale (
-                       Ratio::nearest_from_ratio (double (_size.width) * ar.get_value_or (1) / _size.height)
-                       );
+               if (Config::instance()->default_scale_to ()) {
+                       _scale = VideoContentScale (Config::instance()->default_scale_to ());
+               } else {
+                       /* Guess correct scale from size and sample aspect ratio */
+                       _scale = VideoContentScale (
+                               Ratio::nearest_from_ratio (double (_size.width) * ar.get_value_or (1) / _size.height)
+                               );
+               }
        }
 
        LOG_GENERAL ("Video length obtained from header as %1 frames", _length);
index 63ce57823c59e792d34fdc1c03e83189d76aa0e9..261ace37336665623b3a34fd40254bd4587a89ae 100644 (file)
@@ -515,6 +515,10 @@ private:
                _container = new wxChoice (_panel, wxID_ANY);
                table->Add (_container);
 
+               add_label_to_sizer (table, _panel, _("Default scale-to"), true);
+               _scale_to = new wxChoice (_panel, wxID_ANY);
+               table->Add (_scale_to);
+
                add_label_to_sizer (table, _panel, _("Default content type"), true);
                _dcp_content_type = new wxChoice (_panel, wxID_ANY);
                table->Add (_dcp_content_type);
@@ -568,6 +572,14 @@ private:
 
                _container->Bind (wxEVT_CHOICE, boost::bind (&DefaultsPage::container_changed, this));
 
+               _scale_to->Append (_("Guess from content"));
+
+               for (size_t i = 0; i < ratios.size(); ++i) {
+                       _scale_to->Append (std_to_wx (ratios[i]->nickname ()));
+               }
+
+               _scale_to->Bind (wxEVT_CHOICE, boost::bind (&DefaultsPage::scale_to_changed, this));
+
                vector<DCPContentType const *> const ct = DCPContentType::all ();
                for (size_t i = 0; i < ct.size(); ++i) {
                        _dcp_content_type->Append (std_to_wx (ct[i]->pretty_name ()));
@@ -598,6 +610,13 @@ private:
                        if (ratios[i] == config->default_container ()) {
                                _container->SetSelection (i);
                        }
+                       if (ratios[i] == config->default_scale_to ()) {
+                               _scale_to->SetSelection (i + 1);
+                       }
+               }
+
+               if (!config->default_scale_to()) {
+                       _scale_to->SetSelection (0);
                }
 
                vector<DCPContentType const *> const ct = DCPContentType::all ();
@@ -666,6 +685,17 @@ private:
                Config::instance()->set_default_container (ratio[_container->GetSelection()]);
        }
 
+       void scale_to_changed ()
+       {
+               int const s = _scale_to->GetSelection ();
+               if (s == 0) {
+                       Config::instance()->set_default_scale_to (0);
+               } else {
+                       vector<Ratio const *> ratio = Ratio::all ();
+                       Config::instance()->set_default_scale_to (ratio[s - 1]);
+               }
+       }
+
        void dcp_content_type_changed ()
        {
                vector<DCPContentType const *> ct = DCPContentType::all ();
@@ -689,6 +719,7 @@ private:
        wxDirPickerCtrl* _kdm_directory;
 #endif
        wxChoice* _container;
+       wxChoice* _scale_to;
        wxChoice* _dcp_content_type;
        wxChoice* _dcp_audio_channels;
        wxChoice* _standard;