Offer only flat/scope/full-frame as container choices and differentiate
authorCarl Hetherington <cth@carlh.net>
Wed, 28 Jun 2017 15:17:39 +0000 (16:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 29 Jun 2017 10:26:56 +0000 (11:26 +0100)
the names from the UI for content ratios.

src/lib/ratio.cc
src/lib/ratio.h
src/lib/video_content.cc
src/lib/video_content_scale.cc
src/lib/writer.cc
src/tools/dcpomatic_cli.cc
src/wx/config_dialog.cc
src/wx/dcp_panel.cc
src/wx/dcp_panel.h

index 82602d2f2b24a48a722a9830591f9dbf16a58bbb..60384892dfd427d877ca53b9508c1b3f9548e996 100644 (file)
 
 using std::string;
 using std::vector;
+using boost::optional;
 
 vector<Ratio const *> Ratio::_ratios;
 
 void
 Ratio::setup_ratios ()
 {
-       _ratios.push_back (new Ratio (float(1290) / 1080, "119", _("1.19"), "119"));
-       _ratios.push_back (new Ratio (float(1440) / 1080, "133", _("4:3"), "133"));
-       _ratios.push_back (new Ratio (float(1485) / 1080, "138", _("Academy"), "137"));
-       _ratios.push_back (new Ratio (float(1544) / 1080, "143", _("IMAX"), "143"));
-       _ratios.push_back (new Ratio (float(1800) / 1080, "166", _("1.66"), "166"));
-       _ratios.push_back (new Ratio (float(1920) / 1080, "178", _("16:9"), "178"));
-       _ratios.push_back (new Ratio (float(1998) / 1080, "185", _("Flat"), "F"));
-       _ratios.push_back (new Ratio (float(2048) /  872, "235", _("2.35"), "S"));
-       _ratios.push_back (new Ratio (float(2048) /  858, "239", _("Scope"), "S"));
-       _ratios.push_back (new Ratio (float(2048) / 1080, "full-frame", _("Full frame"), "C"));
+       _ratios.push_back (new Ratio (float(1290) / 1080, "119",        _("1.19"),              optional<string>(),      "119"));
+       _ratios.push_back (new Ratio (float(1440) / 1080, "133",        _("1.33 (4:3)"),        optional<string>(),      "133"));
+       _ratios.push_back (new Ratio (float(1485) / 1080, "138",        _("1.38 (Academy)"),    optional<string>(),      "137"));
+       _ratios.push_back (new Ratio (float(1544) / 1080, "143",        _("1.43 (IMAX)"),       optional<string>(),      "143"));
+       _ratios.push_back (new Ratio (float(1800) / 1080, "166",        _("1.66"),              optional<string>(),      "166"));
+       _ratios.push_back (new Ratio (float(1920) / 1080, "178",        _("1.78 (16:9 or HD)"), optional<string>(),      "178"));
+       _ratios.push_back (new Ratio (float(1998) / 1080, "185",        _("1.85 (Flat)"),       string(_("DCI Flat")),   "F"));
+       _ratios.push_back (new Ratio (float(2048) /  872, "235",        _("2.35"),              optional<string>(),      "S"));
+       _ratios.push_back (new Ratio (float(2048) /  858, "239",        _("2.39 (Scope)"),      string(_("DCI Scope")),  "S"));
+       _ratios.push_back (new Ratio (float(2048) / 1080, "full-frame", _("1.90 (Full frame)"), string(_("Full frame")), "C"));
 }
 
 Ratio const *
@@ -97,3 +98,20 @@ Ratio::nearest_from_ratio (float r)
 
        return nearest;
 }
+
+vector<Ratio const *>
+Ratio::containers ()
+{
+       vector<Ratio const *> r;
+       r.push_back (Ratio::from_id ("185"));
+       r.push_back (Ratio::from_id ("239"));
+       r.push_back (Ratio::from_id ("full-frame"));
+       return r;
+}
+
+string
+Ratio::container_nickname () const
+{
+       DCPOMATIC_ASSERT (_container_nickname);
+       return *_container_nickname;
+}
index 9e9d58a4043355455a9c0b4281732611ce4d6039..42f29458ab883deead8b9ea4f826d3eefa6da5d1 100644 (file)
 class Ratio : public boost::noncopyable
 {
 public:
-       Ratio (float ratio, std::string id, std::string n, std::string d)
+       Ratio (float ratio, std::string id, std::string in, boost::optional<std::string> cn, std::string d)
                : _ratio (ratio)
                , _id (id)
-               , _nickname (n)
+               , _image_nickname (in)
+               , _container_nickname (cn)
                , _isdcf_name (d)
        {}
 
@@ -39,10 +40,12 @@ public:
                return _id;
        }
 
-       std::string nickname () const {
-               return _nickname;
+       std::string image_nickname () const {
+               return _image_nickname;
        }
 
+       std::string container_nickname () const;
+
        std::string isdcf_name () const {
                return _isdcf_name;
        }
@@ -55,16 +58,21 @@ public:
        static Ratio const * from_id (std::string i);
        static Ratio const * from_ratio (float r);
        static Ratio const * nearest_from_ratio (float r);
+
        static std::vector<Ratio const *> all () {
                return _ratios;
        }
 
+       static std::vector<Ratio const *> containers ();
+
 private:
        float _ratio;
        /** id for use in metadata */
        std::string _id;
-       /** nickname (e.g. Flat, Scope) */
-       std::string _nickname;
+       /** nickname when used to describe an image ratio (e.g. Flat, Scope) */
+       std::string _image_nickname;
+       /** nickname when used to describe a container ratio */
+       boost::optional<std::string> _container_nickname;
        std::string _isdcf_name;
 
        static std::vector<Ratio const *> _ratios;
index 8ccb921d04b06b932e63885be9adc302a0044b3d..30a4630893ac4d2b97cd9bc9999577936e1a4711 100644 (file)
@@ -434,7 +434,7 @@ VideoContent::processing_description () const
        if (scaled != container_size) {
                d += String::compose (
                        _("\nPadded with black to fit container %1 (%2x%3)"),
-                       film->container()->nickname (),
+                       film->container()->container_nickname (),
                        container_size.width, container_size.height
                        );
 
index c86ba6ef8a9995cdc8bf7f5c23e1958f5a3a16b3..636f0e807413972d7fa5cb1ea8161e755bd4fb7a 100644 (file)
@@ -95,7 +95,7 @@ string
 VideoContentScale::name () const
 {
        if (_ratio) {
-               return _ratio->nickname ();
+               return _ratio->image_nickname ();
        }
 
        if (_scale) {
index 5e8f8fc9fd1935476a1a8f7238b3b4b14acf5be8..b5123ad74cf2e81511dbc1ad988a593c2fe52cb9 100644 (file)
@@ -554,7 +554,7 @@ Writer::write_cover_sheet ()
        string text = Config::instance()->cover_sheet ();
        boost::algorithm::replace_all (text, "$CPL_NAME", _film->name());
        boost::algorithm::replace_all (text, "$TYPE", _film->dcp_content_type()->pretty_name());
-       boost::algorithm::replace_all (text, "$CONTAINER", _film->container()->nickname());
+       boost::algorithm::replace_all (text, "$CONTAINER", _film->container()->container_nickname());
        boost::algorithm::replace_all (text, "$AUDIO_LANGUAGE", _film->isdcf_metadata().audio_language);
        boost::algorithm::replace_all (text, "$SUBTITLE_LANGUAGE", _film->isdcf_metadata().subtitle_language);
 
index cfd8b3eaeeca57686c9a4f69ded64b28e5e618ab..9572c79733284cfaf20593856c6f39cdf52d388f 100644 (file)
@@ -73,7 +73,7 @@ static void
 print_dump (shared_ptr<Film> film)
 {
        cout << film->dcp_name (true) << "\n"
-            << film->container()->nickname() << " at " << ((film->resolution() == RESOLUTION_2K) ? "2K" : "4K") << "\n"
+            << film->container()->container_nickname() << " at " << ((film->resolution() == RESOLUTION_2K) ? "2K" : "4K") << "\n"
             << (film->j2k_bandwidth() / 1000000) << "Mbit/s" << "\n"
             << "Output " << film->video_frame_rate() << "fps " << (film->three_d() ? "3D" : "2D") << " " << (film->audio_frame_rate() / 1000) << "kHz\n"
             << (film->interop() ? "Inter-Op" : "SMPTE") << " " << (film->encrypted() ? "encrypted" : "unencrypted") << "\n";
index 03dae5281ce4383cb0fcca77aff4eaa0ed699471..8dd6cab68503a7cdd4d7e1781a89585e8b594300 100644 (file)
@@ -577,24 +577,22 @@ private:
 
                _isdcf_metadata_button->Bind (wxEVT_BUTTON, boost::bind (&DefaultsPage::edit_isdcf_metadata_clicked, this));
 
-               vector<Ratio const *> ratios = Ratio::all ();
-               for (size_t i = 0; i < ratios.size(); ++i) {
-                       _container->Append (std_to_wx (ratios[i]->nickname ()));
+               BOOST_FOREACH (Ratio const * i, Ratio::containers()) {
+                       _container->Append (std_to_wx(i->container_nickname()));
                }
 
                _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 ()));
+               BOOST_FOREACH (Ratio const * i, Ratio::all()) {
+                       _scale_to->Append (std_to_wx(i->image_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 ()));
+               BOOST_FOREACH (DCPContentType const * i, DCPContentType::all()) {
+                       _dcp_content_type->Append (std_to_wx (i->pretty_name ()));
                }
 
                setup_audio_channels_choice (_dcp_audio_channels, 2);
index 2888bfb66cf4cad13ffffef701faf46e73cc4bcc..91ffe365f3b674004078b03f09d44ab14921ce52 100644 (file)
@@ -175,9 +175,8 @@ DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr<Film> film)
        _standard->Bind              (wxEVT_CHOICE,  boost::bind (&DCPPanel::standard_changed, this));
        _upload_after_make_dcp->Bind (wxEVT_CHECKBOX, boost::bind (&DCPPanel::upload_after_make_dcp_changed, this));
 
-       vector<DCPContentType const *> const ct = DCPContentType::all ();
-       for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
-               _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
+       BOOST_FOREACH (DCPContentType const * i, DCPContentType::all()) {
+               _dcp_content_type->Append (std_to_wx (i->pretty_name ()));
        }
 
        _reel_type->Append (_("Single reel"));
@@ -445,7 +444,7 @@ void
 DCPPanel::setup_container ()
 {
        int n = 0;
-       vector<Ratio const *> ratios = Ratio::all ();
+       vector<Ratio const *> ratios = Ratio::containers ();
        vector<Ratio const *>::iterator i = ratios.begin ();
        while (i != ratios.end() && *i != _film->container ()) {
                ++i;
@@ -474,7 +473,7 @@ DCPPanel::container_changed ()
 
        int const n = _container->GetSelection ();
        if (n >= 0) {
-               vector<Ratio const *> ratios = Ratio::all ();
+               vector<Ratio const *> ratios = Ratio::containers ();
                DCPOMATIC_ASSERT (n < int (ratios.size()));
                _film->set_container (ratios[n]);
        }
@@ -653,6 +652,11 @@ DCPPanel::make_video_panel ()
                ++r;
        }
 
+       add_label_to_sizer (grid, panel, _("Resolution"), true, wxGBPosition (r, 0));
+       _resolution = new wxChoice (panel, wxID_ANY);
+       grid->Add (_resolution, wxGBPosition (r, 1));
+       ++r;
+
        add_label_to_sizer (grid, panel, _("Frame Rate"), true, wxGBPosition (r, 0));
        {
                _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
@@ -671,11 +675,6 @@ DCPPanel::make_video_panel ()
        grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
        ++r;
 
-       add_label_to_sizer (grid, panel, _("Resolution"), true, wxGBPosition (r, 0));
-       _resolution = new wxChoice (panel, wxID_ANY);
-       grid->Add (_resolution, wxGBPosition (r, 1));
-       ++r;
-
        {
                add_label_to_sizer (grid, panel, _("JPEG2000 bandwidth\nfor newly-encoded data"), true, wxGBPosition (r, 0));
                wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
@@ -696,14 +695,12 @@ DCPPanel::make_video_panel ()
        _resolution->Bind       (wxEVT_CHOICE,       boost::bind (&DCPPanel::resolution_changed, this));
        _three_d->Bind          (wxEVT_CHECKBOX,      boost::bind (&DCPPanel::three_d_changed, this));
 
-       vector<Ratio const *> const ratio = Ratio::all ();
-       for (vector<Ratio const *>::const_iterator i = ratio.begin(); i != ratio.end(); ++i) {
-               _container->Append (std_to_wx ((*i)->nickname ()));
+       BOOST_FOREACH (Ratio const * i, Ratio::containers()) {
+               _container->Append (std_to_wx(i->container_nickname()));
        }
 
-       list<int> const dfr = Config::instance()->allowed_dcp_frame_rates ();
-       for (list<int>::const_iterator i = dfr.begin(); i != dfr.end(); ++i) {
-               _frame_rate_choice->Append (std_to_wx (boost::lexical_cast<string> (*i)));
+       BOOST_FOREACH (int i, Config::instance()->allowed_dcp_frame_rates()) {
+               _frame_rate_choice->Append (std_to_wx (boost::lexical_cast<string> (i)));
        }
 
        _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
index 9209d3f9ba5197e64df993cb8b0885f9b87c7691..f2e0455c97f3ff1eec43bd6374ace3fde183ca09 100644 (file)
@@ -33,8 +33,8 @@ class wxSpinCtrl;
 class wxSizer;
 
 class AudioDialog;
-
 class Film;
+class Ratio;
 
 class DCPPanel : public boost::noncopyable
 {