diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-01-26 22:51:54 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-01-26 22:51:54 +0000 |
| commit | b1873c51b2e8265a01a8f0eced7fc3465f1677dc (patch) | |
| tree | d0eb1d779f6f9e145e57693162af06a2390e84fb /src | |
| parent | 494b6ee180e531358bab39e72f6123e90f9314e5 (diff) | |
| parent | d641aee73077e93ca17b30acd5b9ed82f1e14cb9 (diff) | |
Merge master into direct-mxf.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/config.cc | 6 | ||||
| -rw-r--r-- | src/lib/config.h | 11 | ||||
| -rw-r--r-- | src/lib/dci_metadata.cc | 55 | ||||
| -rw-r--r-- | src/lib/dci_metadata.h | 40 | ||||
| -rw-r--r-- | src/lib/film.cc | 128 | ||||
| -rw-r--r-- | src/lib/film.h | 55 | ||||
| -rw-r--r-- | src/lib/format.cc | 9 | ||||
| -rw-r--r-- | src/lib/format.h | 3 | ||||
| -rw-r--r-- | src/lib/subtitle.cc | 2 | ||||
| -rw-r--r-- | src/lib/wscript | 3 | ||||
| -rw-r--r-- | src/wx/config_dialog.cc | 21 | ||||
| -rw-r--r-- | src/wx/config_dialog.h | 6 | ||||
| -rw-r--r-- | src/wx/dci_metadata_dialog.cc (renamed from src/wx/dci_name_dialog.cc) | 75 | ||||
| -rw-r--r-- | src/wx/dci_metadata_dialog.h (renamed from src/wx/dci_name_dialog.h) | 17 | ||||
| -rw-r--r-- | src/wx/film_editor.cc | 31 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 12 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 64 | ||||
| -rw-r--r-- | src/wx/film_viewer.h | 11 | ||||
| -rw-r--r-- | src/wx/wscript | 2 | ||||
| -rw-r--r-- | src/wx/wx_util.cc | 13 | ||||
| -rw-r--r-- | src/wx/wx_util.h | 4 |
21 files changed, 283 insertions, 285 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index 307b96844..c165859b0 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -90,6 +90,8 @@ Config::Config () } else if (k == "sound_processor") { _sound_processor = SoundProcessor::from_id (v); } + + _default_dci_metadata.read (k, v); } } @@ -136,7 +138,9 @@ Config::write () const f << "tms_path " << _tms_path << "\n"; f << "tms_user " << _tms_user << "\n"; f << "tms_password " << _tms_password << "\n"; - f << "sound_processor " << _sound_processor->id (); + f << "sound_processor " << _sound_processor->id () << "\n"; + + _default_dci_metadata.write (f); } string diff --git a/src/lib/config.h b/src/lib/config.h index c41437efb..fed297ad0 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -27,6 +27,7 @@ #include <vector> #include <boost/shared_ptr.hpp> #include <boost/signals2.hpp> +#include "dci_metadata.h" class ServerDescription; class Scaler; @@ -98,6 +99,10 @@ public: return _allowed_dcp_frame_rates; } + DCIMetadata default_dci_metadata () const { + return _default_dci_metadata; + } + /** @param n New number of local encoding threads */ void set_num_local_encoding_threads (int n) { _num_local_encoding_threads = n; @@ -149,6 +154,10 @@ public: _allowed_dcp_frame_rates = r; } + void set_default_dci_metadata (DCIMetadata d) { + _default_dci_metadata = d; + } + void write () const; static Config* instance (); @@ -181,6 +190,8 @@ private: /** Our sound processor */ SoundProcessor const * _sound_processor; std::list<int> _allowed_dcp_frame_rates; + /** Default DCI metadata for newly-created Films */ + DCIMetadata _default_dci_metadata; /** Singleton instance, or 0 */ static Config* _instance; diff --git a/src/lib/dci_metadata.cc b/src/lib/dci_metadata.cc new file mode 100644 index 000000000..2b4cc3ae7 --- /dev/null +++ b/src/lib/dci_metadata.cc @@ -0,0 +1,55 @@ +/* + Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <iostream> +#include "dci_metadata.h" + +using namespace std; + +void +DCIMetadata::write (ostream& f) const +{ + f << "audio_language " << audio_language << "\n"; + f << "subtitle_language " << subtitle_language << "\n"; + f << "territory " << territory << "\n"; + f << "rating " << rating << "\n"; + f << "studio " << studio << "\n"; + f << "facility " << facility << "\n"; + f << "package_type " << package_type << "\n"; +} + +void +DCIMetadata::read (string k, string v) +{ + if (k == "audio_language") { + audio_language = v; + } else if (k == "subtitle_language") { + subtitle_language = v; + } else if (k == "territory") { + territory = v; + } else if (k == "rating") { + rating = v; + } else if (k == "studio") { + studio = v; + } else if (k == "facility") { + facility = v; + } else if (k == "package_type") { + package_type = v; + } +} diff --git a/src/lib/dci_metadata.h b/src/lib/dci_metadata.h new file mode 100644 index 000000000..eecdc7655 --- /dev/null +++ b/src/lib/dci_metadata.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef DVDOMATIC_DCI_METADATA_H +#define DVDOMATIC_DCI_METADATA_H + +#include <string> + +class DCIMetadata +{ +public: + void read (std::string, std::string); + void write (std::ostream &) const; + + std::string audio_language; + std::string subtitle_language; + std::string territory; + std::string rating; + std::string studio; + std::string facility; + std::string package_type; +}; + +#endif diff --git a/src/lib/film.cc b/src/lib/film.cc index f6eb032fd..bdc4cca73 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -100,6 +100,7 @@ Film::Film (string d, bool must_exist) , _subtitle_scale (1) , _colour_lut (0) , _j2k_bandwidth (200000000) + , _dci_metadata (Config::instance()->default_dci_metadata ()) , _frames_per_second (0) , _dirty (false) { @@ -169,13 +170,7 @@ Film::Film (Film const & o) , _subtitle_scale (o._subtitle_scale) , _colour_lut (o._colour_lut) , _j2k_bandwidth (o._j2k_bandwidth) - , _audio_language (o._audio_language) - , _subtitle_language (o._subtitle_language) - , _territory (o._territory) - , _rating (o._rating) - , _studio (o._studio) - , _facility (o._facility) - , _package_type (o._package_type) + , _dci_metadata (o._dci_metadata) , _size (o._size) , _length (o._length) , _dcp_intrinsic_duration (o._dcp_intrinsic_duration) @@ -413,14 +408,7 @@ Film::write_metadata () const f << "subtitle_scale " << _subtitle_scale << "\n"; f << "colour_lut " << _colour_lut << "\n"; f << "j2k_bandwidth " << _j2k_bandwidth << "\n"; - f << "audio_language " << _audio_language << "\n"; - f << "subtitle_language " << _subtitle_language << "\n"; - f << "territory " << _territory << "\n"; - f << "rating " << _rating << "\n"; - f << "studio " << _studio << "\n"; - f << "facility " << _facility << "\n"; - f << "package_type " << _package_type << "\n"; - + _dci_metadata.write (f); f << "width " << _size.width << "\n"; f << "height " << _size.height << "\n"; f << "length " << _length.get_value_or(0) << "\n"; @@ -543,21 +531,9 @@ Film::read_metadata () _colour_lut = atoi (v.c_str ()); } else if (k == "j2k_bandwidth") { _j2k_bandwidth = atoi (v.c_str ()); - } else if (k == "audio_language") { - _audio_language = v; - } else if (k == "subtitle_language") { - _subtitle_language = v; - } else if (k == "territory") { - _territory = v; - } else if (k == "rating") { - _rating = v; - } else if (k == "studio") { - _studio = v; - } else if (k == "facility") { - _facility = v; - } else if (k == "package_type") { - _package_type = v; } + + _dci_metadata.read (k, v); /* Cached stuff */ if (k == "width") { @@ -734,10 +710,12 @@ Film::dci_name () const d << format()->dci_name() << "_"; } - if (!audio_language().empty ()) { - d << audio_language(); - if (!subtitle_language().empty() && with_subtitles()) { - d << "-" << subtitle_language(); + DCIMetadata const dm = dci_metadata (); + + if (!dm.audio_language.empty ()) { + d << dm.audio_language; + if (!dm.subtitle_language.empty() && with_subtitles()) { + d << "-" << dm.subtitle_language; } else { d << "-XX"; } @@ -745,10 +723,10 @@ Film::dci_name () const d << "_"; } - if (!territory().empty ()) { - d << territory(); - if (!rating().empty ()) { - d << "-" << rating(); + if (!dm.territory.empty ()) { + d << dm.territory; + if (!dm.rating.empty ()) { + d << "-" << dm.rating; } d << "_"; } @@ -770,18 +748,18 @@ Film::dci_name () const d << "2K_"; - if (!studio().empty ()) { - d << studio() << "_"; + if (!dm.studio.empty ()) { + d << dm.studio << "_"; } d << boost::gregorian::to_iso_string (_dci_date) << "_"; - if (!facility().empty ()) { - d << facility() << "_"; + if (!dm.facility.empty ()) { + d << dm.facility << "_"; } - if (!package_type().empty ()) { - d << package_type(); + if (!dm.package_type.empty ()) { + d << dm.package_type; } return d.str (); @@ -1207,71 +1185,11 @@ Film::set_j2k_bandwidth (int b) } void -Film::set_audio_language (string l) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _audio_language = l; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_subtitle_language (string l) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _subtitle_language = l; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_territory (string t) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _territory = t; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_rating (string r) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _rating = r; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_studio (string s) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _studio = s; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_facility (string f) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _facility = f; - } - signal_changed (DCI_METADATA); -} - -void -Film::set_package_type (string p) +Film::set_dci_metadata (DCIMetadata m) { { boost::mutex::scoped_lock lm (_state_mutex); - _package_type = p; + _dci_metadata = m; } signal_changed (DCI_METADATA); } diff --git a/src/lib/film.h b/src/lib/film.h index 07764dac8..7c4c72f7b 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -38,6 +38,7 @@ extern "C" { #include "dcp_content_type.h" #include "util.h" #include "stream.h" +#include "dci_metadata.h" class Format; class Job; @@ -275,41 +276,11 @@ public: return _j2k_bandwidth; } - std::string audio_language () const { + DCIMetadata dci_metadata () const { boost::mutex::scoped_lock lm (_state_mutex); - return _audio_language; + return _dci_metadata; } - std::string subtitle_language () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _subtitle_language; - } - - std::string territory () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _territory; - } - - std::string rating () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _rating; - } - - std::string studio () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _studio; - } - - std::string facility () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _facility; - } - - std::string package_type () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _package_type; - } - libdcp::Size size () const { boost::mutex::scoped_lock lm (_state_mutex); return _size; @@ -378,13 +349,7 @@ public: void set_subtitle_scale (float); void set_colour_lut (int); void set_j2k_bandwidth (int); - void set_audio_language (std::string); - void set_subtitle_language (std::string); - void set_territory (std::string); - void set_rating (std::string); - void set_studio (std::string); - void set_facility (std::string); - void set_package_type (std::string); + void set_dci_metadata (DCIMetadata); void set_size (libdcp::Size); void set_length (SourceFrame); void unset_length (); @@ -484,15 +449,9 @@ private: int _colour_lut; /** bandwidth for J2K files in bits per second */ int _j2k_bandwidth; - - /* DCI naming stuff */ - std::string _audio_language; - std::string _subtitle_language; - std::string _territory; - std::string _rating; - std::string _studio; - std::string _facility; - std::string _package_type; + + /** DCI naming stuff */ + DCIMetadata _dci_metadata; /* Data which are cached to speed things up */ diff --git a/src/lib/format.cc b/src/lib/format.cc index 4583dd0e5..016c21fde 100644 --- a/src/lib/format.cc +++ b/src/lib/format.cc @@ -148,6 +148,9 @@ FixedFormat::FixedFormat (int r, libdcp::Size dcp, string id, string n, string d } +/** @return Number of pixels (int the DCP image) to pad either side of the film + * (so there are dcp_padding() pixels on the left and dcp_padding() on the right) + */ int Format::dcp_padding (shared_ptr<const Film> f) const { @@ -161,6 +164,12 @@ Format::dcp_padding (shared_ptr<const Film> f) const return p; } +float +Format::container_ratio_as_float () const +{ + return static_cast<float> (_dcp_size.width) / _dcp_size.height; +} + VariableFormat::VariableFormat (libdcp::Size dcp, string id, string n, string d) : Format (dcp, id, n, d) { diff --git a/src/lib/format.h b/src/lib/format.h index b4c691e56..783ff25ce 100644 --- a/src/lib/format.h +++ b/src/lib/format.h @@ -46,6 +46,9 @@ public: /** @return the ratio as a floating point number */ virtual float ratio_as_float (boost::shared_ptr<const Film> f) const = 0; + /** @return the ratio of the container (including any padding) as a floating point number */ + float container_ratio_as_float () const; + int dcp_padding (boost::shared_ptr<const Film> f) const; /** @return size in pixels of the images that we should diff --git a/src/lib/subtitle.cc b/src/lib/subtitle.cc index 3754e5acf..bd5f0c879 100644 --- a/src/lib/subtitle.cc +++ b/src/lib/subtitle.cc @@ -35,7 +35,7 @@ using libdcp::Size; */ TimedSubtitle::TimedSubtitle (AVSubtitle const & sub) { - assert (sub.rects > 0); + assert (sub.num_rects > 0); /* Subtitle PTS in seconds (within the source, not taking into account any of the source that we may have chopped off for the DCP) diff --git a/src/lib/wscript b/src/lib/wscript index 5d676f249..454565cdc 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -6,7 +6,7 @@ def build(bld): obj.name = 'libdvdomatic' obj.export_includes = ['.'] - obj.uselib = 'AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE SWRESAMPLE SNDFILE BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 OPENJPEG POSTPROC TIFF MAGICK SSH DCP GLIB' + obj.uselib = 'AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE SWRESAMPLE SNDFILE BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 OPENJPEG POSTPROC TIFF MAGICK SSH DCP GLIB LZMA' if bld.env.TARGET_WINDOWS: obj.uselib += ' WINSOCK2' obj.source = """ @@ -17,6 +17,7 @@ def build(bld): config.cc combiner.cc cross.cc + dci_metadata.cc dcp_content_type.cc dcp_video_frame.cc decoder.cc diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 9de8e7001..b656a5278 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -35,6 +35,7 @@ #include "filter_dialog.h" #include "server_dialog.h" #include "dir_picker_ctrl.h" +#include "dci_metadata_dialog.h" using namespace std; using boost::bind; @@ -79,8 +80,13 @@ ConfigDialog::ConfigDialog (wxWindow* parent) table->Add (_default_directory, 1, wxEXPAND); table->AddSpacer (0); + add_label_to_sizer (table, this, "Default DCI name details"); + _default_dci_metadata_button = new wxButton (this, wxID_ANY, _("Edit...")); + table->Add (_default_dci_metadata_button); + table->AddSpacer (1); + add_label_to_sizer (table, this, "Reference scaler for A/B"); - _reference_scaler = new wxComboBox (this, wxID_ANY); + _reference_scaler = new wxChoice (this, wxID_ANY); vector<Scaler const *> const sc = Scaler::all (); for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) { _reference_scaler->Append (std_to_wx ((*i)->name ())); @@ -142,8 +148,10 @@ ConfigDialog::ConfigDialog (wxWindow* parent) _default_directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())))); _default_directory->Connect (wxID_ANY, wxEVT_COMMAND_DIRPICKER_CHANGED, wxCommandEventHandler (ConfigDialog::default_directory_changed), 0, this); + _default_dci_metadata_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ConfigDialog::edit_default_dci_metadata_clicked), 0, this); + _reference_scaler->SetSelection (Scaler::as_index (config->reference_scaler ())); - _reference_scaler->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (ConfigDialog::reference_scaler_changed), 0, this); + _reference_scaler->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (ConfigDialog::reference_scaler_changed), 0, this); pair<string, string> p = Filter::ffmpeg_strings (config->reference_filters ()); _reference_filters->SetLabel (std_to_wx (p.first + " " + p.second)); @@ -307,3 +315,12 @@ ConfigDialog::reference_filters_changed (vector<Filter const *> f) pair<string, string> p = Filter::ffmpeg_strings (Config::instance()->reference_filters ()); _reference_filters->SetLabel (std_to_wx (p.first + " " + p.second)); } + +void +ConfigDialog::edit_default_dci_metadata_clicked (wxCommandEvent &) +{ + DCIMetadataDialog* d = new DCIMetadataDialog (this, Config::instance()->default_dci_metadata ()); + d->ShowModal (); + Config::instance()->set_default_dci_metadata (d->dci_metadata ()); + d->Destroy (); +} diff --git a/src/wx/config_dialog.h b/src/wx/config_dialog.h index 32123a0d7..948bf0571 100644 --- a/src/wx/config_dialog.h +++ b/src/wx/config_dialog.h @@ -45,6 +45,7 @@ private: void tms_password_changed (wxCommandEvent &); void num_local_encoding_threads_changed (wxCommandEvent &); void default_directory_changed (wxCommandEvent &); + void edit_default_dci_metadata_clicked (wxCommandEvent &); void reference_scaler_changed (wxCommandEvent &); void edit_reference_filters_clicked (wxCommandEvent &); void reference_filters_changed (std::vector<Filter const *>); @@ -64,8 +65,9 @@ private: DirPickerCtrl* _default_directory; #else wxDirPickerCtrl* _default_directory; -#endif - wxComboBox* _reference_scaler; +#endif + wxButton* _default_dci_metadata_button; + wxChoice* _reference_scaler; wxStaticText* _reference_filters; wxButton* _reference_filters_button; wxListCtrl* _servers; diff --git a/src/wx/dci_name_dialog.cc b/src/wx/dci_metadata_dialog.cc index 6927d6c9e..c5682e19e 100644 --- a/src/wx/dci_name_dialog.cc +++ b/src/wx/dci_metadata_dialog.cc @@ -18,15 +18,14 @@ */ #include <wx/sizer.h> -#include "dci_name_dialog.h" +#include "dci_metadata_dialog.h" #include "wx_util.h" #include "film.h" using boost::shared_ptr; -DCINameDialog::DCINameDialog (wxWindow* parent, shared_ptr<Film> film) +DCIMetadataDialog::DCIMetadataDialog (wxWindow* parent, DCIMetadata dm) : wxDialog (parent, wxID_ANY, _("DCI name"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) - , _film (film) { wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6); table->AddGrowableCol (1, 1); @@ -59,21 +58,13 @@ DCINameDialog::DCINameDialog (wxWindow* parent, shared_ptr<Film> film) _package_type = new wxTextCtrl (this, wxID_ANY); table->Add (_package_type, 1, wxEXPAND); - _audio_language->SetValue (std_to_wx (_film->audio_language ())); - _subtitle_language->SetValue (std_to_wx (_film->subtitle_language ())); - _territory->SetValue (std_to_wx (_film->territory ())); - _rating->SetValue (std_to_wx (_film->rating ())); - _studio->SetValue (std_to_wx (_film->studio ())); - _facility->SetValue (std_to_wx (_film->facility ())); - _package_type->SetValue (std_to_wx (_film->package_type ())); - - _audio_language->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::audio_language_changed), 0, this); - _subtitle_language->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::subtitle_language_changed), 0, this); - _territory->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::territory_changed), 0, this); - _rating->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::rating_changed), 0, this); - _studio->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::studio_changed), 0, this); - _facility->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::facility_changed), 0, this); - _package_type->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (DCINameDialog::package_type_changed), 0, this); + _audio_language->SetValue (std_to_wx (dm.audio_language)); + _subtitle_language->SetValue (std_to_wx (dm.subtitle_language)); + _territory->SetValue (std_to_wx (dm.territory)); + _rating->SetValue (std_to_wx (dm.rating)); + _studio->SetValue (std_to_wx (dm.studio)); + _facility->SetValue (std_to_wx (dm.facility)); + _package_type->SetValue (std_to_wx (dm.package_type)); wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); overall_sizer->Add (table, 1, wxEXPAND | wxALL, 6); @@ -88,44 +79,18 @@ DCINameDialog::DCINameDialog (wxWindow* parent, shared_ptr<Film> film) overall_sizer->SetSizeHints (this); } -void -DCINameDialog::audio_language_changed (wxCommandEvent &) +DCIMetadata +DCIMetadataDialog::dci_metadata () const { - _film->set_audio_language (wx_to_std (_audio_language->GetValue ())); -} + DCIMetadata dm; -void -DCINameDialog::subtitle_language_changed (wxCommandEvent &) -{ - _film->set_subtitle_language (wx_to_std (_subtitle_language->GetValue ())); -} + dm.audio_language = wx_to_std (_audio_language->GetValue ()); + dm.subtitle_language = wx_to_std (_subtitle_language->GetValue ()); + dm.territory = wx_to_std (_territory->GetValue ()); + dm.rating = wx_to_std (_rating->GetValue ()); + dm.studio = wx_to_std (_studio->GetValue ()); + dm.facility = wx_to_std (_facility->GetValue ()); + dm.package_type = wx_to_std (_package_type->GetValue ()); -void -DCINameDialog::territory_changed (wxCommandEvent &) -{ - _film->set_territory (wx_to_std (_territory->GetValue ())); -} - -void -DCINameDialog::rating_changed (wxCommandEvent &) -{ - _film->set_rating (wx_to_std (_rating->GetValue ())); -} - -void -DCINameDialog::studio_changed (wxCommandEvent &) -{ - _film->set_studio (wx_to_std (_studio->GetValue ())); -} - -void -DCINameDialog::facility_changed (wxCommandEvent &) -{ - _film->set_facility (wx_to_std (_facility->GetValue ())); -} - -void -DCINameDialog::package_type_changed (wxCommandEvent &) -{ - _film->set_package_type (wx_to_std (_package_type->GetValue ())); + return dm; } diff --git a/src/wx/dci_name_dialog.h b/src/wx/dci_metadata_dialog.h index 1fd5436b8..fbc5e3b86 100644 --- a/src/wx/dci_name_dialog.h +++ b/src/wx/dci_metadata_dialog.h @@ -20,23 +20,18 @@ #include <wx/dialog.h> #include <wx/textctrl.h> #include <boost/shared_ptr.hpp> +#include "dci_metadata.h" class Film; -class DCINameDialog : public wxDialog +class DCIMetadataDialog : public wxDialog { public: - DCINameDialog (wxWindow *, boost::shared_ptr<Film>); + DCIMetadataDialog (wxWindow *, DCIMetadata); + + DCIMetadata dci_metadata () const; private: - void audio_language_changed (wxCommandEvent &); - void subtitle_language_changed (wxCommandEvent &); - void territory_changed (wxCommandEvent &); - void rating_changed (wxCommandEvent &); - void studio_changed (wxCommandEvent &); - void facility_changed (wxCommandEvent &); - void package_type_changed (wxCommandEvent &); - wxTextCtrl* _audio_language; wxTextCtrl* _subtitle_language; wxTextCtrl* _territory; @@ -44,6 +39,4 @@ private: wxTextCtrl* _studio; wxTextCtrl* _facility; wxTextCtrl* _package_type; - - boost::shared_ptr<Film> _film; }; diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 4e99bcd96..f274416fb 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -43,7 +43,7 @@ #include "film_editor.h" #include "gain_calculator_dialog.h" #include "sound_processor.h" -#include "dci_name_dialog.h" +#include "dci_metadata_dialog.h" #include "scaler.h" using std::string; @@ -120,7 +120,7 @@ FilmEditor::make_film_panel () _film_sizer->AddSpacer (0); add_label_to_sizer (_film_sizer, _film_panel, "Content Type"); - _dcp_content_type = new wxComboBox (_film_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY); + _dcp_content_type = new wxChoice (_film_panel, wxID_ANY); _film_sizer->Add (_dcp_content_type); video_control (add_label_to_sizer (_film_sizer, _film_panel, "Frames Per Second")); @@ -177,7 +177,7 @@ FilmEditor::connect_to_widgets () _name->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (FilmEditor::name_changed), 0, this); _use_dci_name->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::use_dci_name_toggled), 0, this); _edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this); - _format->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this); + _format->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this); _content->Connect (wxID_ANY, wxEVT_COMMAND_FILEPICKER_CHANGED, wxCommandEventHandler (FilmEditor::content_changed), 0, this); _trust_content_header->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::trust_content_header_changed), 0, this); _left_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this); @@ -185,8 +185,8 @@ FilmEditor::connect_to_widgets () _top_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this); _bottom_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::bottom_crop_changed), 0, this); _filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_filters_clicked), 0, this); - _scaler->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::scaler_changed), 0, this); - _dcp_content_type->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this); + _scaler->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::scaler_changed), 0, this); + _dcp_content_type->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this); _dcp_ab->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::dcp_ab_toggled), 0, this); _still_duration->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::still_duration_changed), 0, this); _trim_start->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::trim_start_changed), 0, this); @@ -194,10 +194,10 @@ FilmEditor::connect_to_widgets () _with_subtitles->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this); _subtitle_offset->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_offset_changed), 0, this); _subtitle_scale->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this); - _colour_lut->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::colour_lut_changed), 0, this); + _colour_lut->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::colour_lut_changed), 0, this); _j2k_bandwidth->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::j2k_bandwidth_changed), 0, this); - _subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this); - _audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this); + _subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this); + _audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this); _audio_gain->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this); _audio_gain_calculate_button->Connect ( wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::audio_gain_calculate_button_clicked), 0, this @@ -222,7 +222,7 @@ FilmEditor::make_video_panel () _video_panel->SetSizer (pad); add_label_to_sizer (_video_sizer, _video_panel, "Format"); - _format = new wxComboBox (_video_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY); + _format = new wxChoice (_video_panel, wxID_ANY); _video_sizer->Add (_format); { @@ -259,7 +259,7 @@ FilmEditor::make_video_panel () } video_control (add_label_to_sizer (_video_sizer, _video_panel, "Scaler")); - _scaler = new wxComboBox (_video_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY); + _scaler = new wxChoice (_video_panel, wxID_ANY); _video_sizer->Add (video_control (_scaler), 1); vector<Scaler const *> const sc = Scaler::all (); @@ -268,7 +268,7 @@ FilmEditor::make_video_panel () } add_label_to_sizer (_video_sizer, _video_panel, "Colour look-up table"); - _colour_lut = new wxComboBox (_video_panel, wxID_ANY); + _colour_lut = new wxChoice (_video_panel, wxID_ANY); for (int i = 0; i < 2; ++i) { _colour_lut->Append (std_to_wx (colour_lut_index_to_name (i))); } @@ -328,7 +328,7 @@ FilmEditor::make_audio_panel () _use_content_audio = new wxRadioButton (_audio_panel, wxID_ANY, _("Use content's audio"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); _audio_sizer->Add (video_control (_use_content_audio)); wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); - _audio_stream = new wxComboBox (_audio_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY); + _audio_stream = new wxChoice (_audio_panel, wxID_ANY); s->Add (video_control (_audio_stream), 1); _audio = new wxStaticText (_audio_panel, wxID_ANY, wxT ("")); s->Add (video_control (_audio), 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 8); @@ -373,7 +373,7 @@ FilmEditor::make_subtitle_panel () video_control (_with_subtitles); _subtitle_sizer->Add (_with_subtitles, 1); - _subtitle_stream = new wxComboBox (_subtitle_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY); + _subtitle_stream = new wxChoice (_subtitle_panel, wxID_ANY); _subtitle_sizer->Add (video_control (_subtitle_stream)); video_control (add_label_to_sizer (_subtitle_sizer, _subtitle_panel, "Subtitle Offset")); @@ -1058,8 +1058,9 @@ FilmEditor::edit_dci_button_clicked (wxCommandEvent &) return; } - DCINameDialog* d = new DCINameDialog (this, _film); + DCIMetadataDialog* d = new DCIMetadataDialog (this, _film->dci_metadata ()); d->ShowModal (); + _film->set_dci_metadata (d->dci_metadata ()); d->Destroy (); } @@ -1086,7 +1087,7 @@ FilmEditor::setup_streams () if (_film->subtitle_stream()) { checked_set (_subtitle_stream, _film->subtitle_stream()->to_string()); } else { - _subtitle_stream->SetValue (wxT ("")); + _subtitle_stream->SetSelection (wxNOT_FOUND); } } diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 7272315fc..90be752d8 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -118,7 +118,7 @@ private: wxCheckBox* _use_dci_name; wxButton* _edit_dci_button; /** The Film's format */ - wxComboBox* _format; + wxChoice* _format; /** The Film's content file */ wxFilePickerCtrl* _content; wxCheckBox* _trust_content_header; @@ -135,9 +135,9 @@ private: /** Button to open the filters dialogue */ wxButton* _filters_button; /** The Film's scaler */ - wxComboBox* _scaler; + wxChoice* _scaler; wxRadioButton* _use_content_audio; - wxComboBox* _audio_stream; + wxChoice* _audio_stream; wxRadioButton* _use_external_audio; wxFilePickerCtrl* _external_audio[MAX_AUDIO_CHANNELS]; /** The Film's audio gain */ @@ -147,13 +147,13 @@ private: /** The Film's audio delay */ wxSpinCtrl* _audio_delay; wxCheckBox* _with_subtitles; - wxComboBox* _subtitle_stream; + wxChoice* _subtitle_stream; wxSpinCtrl* _subtitle_offset; wxSpinCtrl* _subtitle_scale; - wxComboBox* _colour_lut; + wxChoice* _colour_lut; wxSpinCtrl* _j2k_bandwidth; /** The Film's DCP content type */ - wxComboBox* _dcp_content_type; + wxChoice* _dcp_content_type; /** The Film's frames per second */ wxStaticText* _frames_per_second; /** The Film's original size */ diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 4176f4f42..7b8f02220 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -51,11 +51,8 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p) , _panel (new wxPanel (this)) , _slider (new wxSlider (this, wxID_ANY, 0, 0, 4096)) , _play_button (new wxToggleButton (this, wxID_ANY, wxT ("Play"))) + , _display_frame_x (0) , _got_frame (false) - , _out_width (0) - , _out_height (0) - , _panel_width (0) - , _panel_height (0) , _clear_required (false) { _panel->SetDoubleBuffered (true); @@ -196,14 +193,21 @@ FilmViewer::paint_panel (wxPaintEvent &) _clear_required = false; } - if (!_display_frame || !_film || !_out_width || !_out_height) { + if (!_display_frame || !_film || !_out_size.width || !_out_size.height) { dc.Clear (); return; } - wxImage frame (_out_width, _out_height, _display_frame->data()[0], true); + if (_display_frame_x) { + dc.SetPen(*wxBLACK_PEN); + dc.SetBrush(*wxBLACK_BRUSH); + dc.DrawRectangle (0, 0, _display_frame_x, _film_size.height); + dc.DrawRectangle (_display_frame_x + _film_size.width, 0, _display_frame_x * 2 + _film_size.width, _film_size.height); + } + + wxImage frame (_film_size.width, _film_size.height, _display_frame->data()[0], true); wxBitmap frame_bitmap (frame); - dc.DrawBitmap (frame_bitmap, 0, 0); + dc.DrawBitmap (frame_bitmap, _display_frame_x, 0); if (_film->with_subtitles() && _display_sub) { wxImage sub (_display_sub->size().width, _display_sub->size().height, _display_sub->data()[0], _display_sub->alpha(), true); @@ -232,8 +236,8 @@ FilmViewer::slider_moved (wxScrollEvent &) void FilmViewer::panel_sized (wxSizeEvent& ev) { - _panel_width = ev.GetSize().GetWidth(); - _panel_height = ev.GetSize().GetHeight(); + _panel_size.width = ev.GetSize().GetWidth(); + _panel_size.height = ev.GetSize().GetHeight(); calculate_sizes (); update_from_raw (); } @@ -254,7 +258,7 @@ FilmViewer::update_from_raw () void FilmViewer::raw_to_display () { - if (!_raw_frame || _out_width < 64 || _out_height < 64 || !_film) { + if (!_raw_frame || _out_size.width < 64 || _out_size.height < 64 || !_film) { return; } @@ -264,7 +268,7 @@ FilmViewer::raw_to_display () } /* Get a compacted image as we have to feed it to wxWidgets */ - _display_frame = _raw_frame->scale_and_convert_to_rgb (libdcp::Size (_out_width, _out_height), 0, _film->scaler(), false); + _display_frame = _raw_frame->scale_and_convert_to_rgb (_film_size, 0, _film->scaler(), false); if (old_size != _display_frame->size()) { _clear_required = true; @@ -272,13 +276,14 @@ FilmViewer::raw_to_display () if (_raw_sub) { Rect tx = subtitle_transformed_area ( - float (_out_width) / _film->size().width, - float (_out_height) / _film->size().height, + float (_film_size.width) / _film->size().width, + float (_film_size.height) / _film->size().height, _raw_sub->area(), _film->subtitle_offset(), _film->subtitle_scale() ); _display_sub.reset (new RGBPlusAlphaImage (_raw_sub->image()->scale (tx.size(), _film->scaler(), false))); _display_sub_position = tx.position(); + _display_sub_position.x += _display_frame_x; } else { _display_sub.reset (); } @@ -290,17 +295,36 @@ FilmViewer::calculate_sizes () if (!_film) { return; } + + Format const * format = _film->format (); - float const panel_ratio = static_cast<float> (_panel_width) / _panel_height; - float const film_ratio = _film->format() ? _film->format()->ratio_as_float(_film) : 1.78; + float const panel_ratio = static_cast<float> (_panel_size.width) / _panel_size.height; + float const film_ratio = format ? format->container_ratio_as_float () : 1.78; + if (panel_ratio < film_ratio) { /* panel is less widscreen than the film; clamp width */ - _out_width = _panel_width; - _out_height = _out_width / film_ratio; + _out_size.width = _panel_size.width; + _out_size.height = _out_size.width / film_ratio; } else { - /* panel is more widescreen than the film; clamp heignt */ - _out_height = _panel_height; - _out_width = _out_height * film_ratio; + /* panel is more widescreen than the film; clamp height */ + _out_size.height = _panel_size.height; + _out_size.width = _out_size.height * film_ratio; + } + + /* Work out how much padding there is in terms of our display; this will be the x position + of our _display_frame. + */ + _display_frame_x = 0; + if (format) { + _display_frame_x = static_cast<float> (format->dcp_padding (_film)) * _out_size.width / format->dcp_size().width; + } + + _film_size = _out_size; + _film_size.width -= _display_frame_x * 2; + + /* Catch silly values */ + if (_out_size.width < 64) { + _out_size.width = 64; } } diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index c6b5e7c0c..456301eb4 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -69,14 +69,17 @@ private: boost::shared_ptr<Image> _raw_frame; boost::shared_ptr<Subtitle> _raw_sub; boost::shared_ptr<Image> _display_frame; + int _display_frame_x; boost::shared_ptr<RGBPlusAlphaImage> _display_sub; Position _display_sub_position; bool _got_frame; - int _out_width; - int _out_height; - int _panel_width; - int _panel_height; + /** Size of our output (including padding if we have any) */ + libdcp::Size _out_size; + /** Size that we will make our film (equal to _out_size unless we have padding) */ + libdcp::Size _film_size; + /** Size of the panel that we have available */ + libdcp::Size _panel_size; bool _clear_required; }; diff --git a/src/wx/wscript b/src/wx/wscript index 4dbb04eea..47272f697 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -14,7 +14,7 @@ def build(bld): obj.use = 'libdvdomatic' obj.source = """ config_dialog.cc - dci_name_dialog.cc + dci_metadata_dialog.cc dir_picker_ctrl.cc film_editor.cc film_viewer.cc diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index bc444e4bc..413071ea6 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -138,22 +138,15 @@ checked_set (wxSpinCtrl* widget, int value) } void -checked_set (wxComboBox* widget, int value) +checked_set (wxChoice* widget, int value) { if (widget->GetSelection() != value) { - if (value == wxNOT_FOUND) { - /* Work around an apparent wxWidgets bug; SetSelection (wxNOT_FOUND) - appears not to work sometimes. - */ - widget->SetValue (wxT ("")); - } else { - widget->SetSelection (value); - } + widget->SetSelection (value); } } void -checked_set (wxComboBox* widget, string value) +checked_set (wxChoice* widget, string value) { wxClientData* o = 0; if (widget->GetSelection() != -1) { diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index 6cb7fd002..0c77735eb 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -58,8 +58,8 @@ extern std::string string_client_data (wxClientData* o); extern void checked_set (wxFilePickerCtrl* widget, std::string value); extern void checked_set (wxSpinCtrl* widget, int value); -extern void checked_set (wxComboBox* widget, int value); -extern void checked_set (wxComboBox* widget, std::string value); +extern void checked_set (wxChoice* widget, int value); +extern void checked_set (wxChoice* widget, std::string value); extern void checked_set (wxTextCtrl* widget, std::string value); extern void checked_set (wxCheckBox* widget, bool value); extern void checked_set (wxRadioButton* widget, bool value); |
