File "%deps%/bin/libgobject-2.0-0.dll"
File "%deps%/bin/libiconv-2.dll"
File "%deps%/bin/libjpeg-8.dll"
-File "%deps%/bin/libMagick++-5.dll"
-File "%deps%/bin/libMagickCore-5.dll"
-File "%deps%/bin/libMagickWand-5.dll"
+File "%deps%/bin/libMagick++-6.Q16-2.dll"
+File "%deps%/bin/libMagickCore-6.Q16-1.dll"
+File "%deps%/bin/libMagickWand-6.Q16-1.dll"
File "%deps%/bin/libopenjpeg-1.dll"
File "%deps%/bin/libpng15-15.dll"
File "%deps%/bin/libsigc-2.0-0.dll"
File "%deps%/bin/libgobject-2.0-0.dll"
File "%deps%/bin/libiconv-2.dll"
File "%deps%/bin/libjpeg-8.dll"
-File "%deps%/bin/libMagick++-5.dll"
-File "%deps%/bin/libMagickCore-5.dll"
-File "%deps%/bin/libMagickWand-5.dll"
+File "%deps%/bin/libMagick++-6.Q16-2.dll"
+File "%deps%/bin/libMagickCore-6.Q16-1.dll"
+File "%deps%/bin/libMagickWand-6.Q16-1.dll"
File "%deps%/bin/libopenjpeg-1.dll"
File "%deps%/bin/libpng15-15.dll"
File "%deps%/bin/libsigc-2.0-0.dll"
#include <libxml++/libxml++.h>
#include <libdcp/colour_matrix.h>
#include <libcxml/cxml.h>
+#include "config.h"
#include "colour_conversion.h"
#include "i18n.h"
using std::list;
using std::string;
+using std::cout;
+using std::vector;
using boost::shared_ptr;
using boost::lexical_cast;
+using boost::optional;
ColourConversion::ColourConversion ()
- : name (_("Untitled"))
- , input_gamma (2.4)
+ : input_gamma (2.4)
, input_gamma_linearised (true)
, matrix (3, 3)
, output_gamma (2.6)
}
}
-ColourConversion::ColourConversion (string n, float i, bool il, float const m[3][3], float o)
- : name (n)
- , input_gamma (i)
+ColourConversion::ColourConversion (double i, bool il, double const m[3][3], double o)
+ : input_gamma (i)
, input_gamma_linearised (il)
, matrix (3, 3)
, output_gamma (o)
ColourConversion::ColourConversion (shared_ptr<cxml::Node> node)
: matrix (3, 3)
{
- name = node->string_child ("Name");
- input_gamma = node->number_child<float> ("InputGamma");
+ input_gamma = node->number_child<double> ("InputGamma");
input_gamma_linearised = node->bool_child ("InputGammaLinearised");
for (int i = 0; i < 3; ++i) {
for (list<shared_ptr<cxml::Node> >::iterator i = m.begin(); i != m.end(); ++i) {
int const ti = (*i)->number_attribute<int> ("i");
int const tj = (*i)->number_attribute<int> ("j");
- matrix(ti, tj) = lexical_cast<float> ((*i)->content ());
+ matrix(ti, tj) = lexical_cast<double> ((*i)->content ());
}
- output_gamma = node->number_child<float> ("OutputGamma");
+ output_gamma = node->number_child<double> ("OutputGamma");
}
void
ColourConversion::as_xml (xmlpp::Node* node) const
{
- node->add_child("Name")->add_child_text (name);
node->add_child("InputGamma")->add_child_text (lexical_cast<string> (input_gamma));
node->add_child("InputGammaLinearised")->add_child_text (input_gamma_linearised ? "1" : "0");
node->add_child("OutputGamma")->add_child_text (lexical_cast<string> (output_gamma));
}
+
+optional<size_t>
+ColourConversion::preset () const
+{
+ vector<PresetColourConversion> presets = Config::instance()->colour_conversions ();
+ size_t i = 0;
+ while (i < presets.size() && (presets[i].conversion != *this)) {
+ ++i;
+ }
+
+ if (i >= presets.size ()) {
+ return optional<size_t> ();
+ }
+
+ return i;
+}
+
+PresetColourConversion::PresetColourConversion ()
+ : name (_("Untitled"))
+{
+
+}
+
+PresetColourConversion::PresetColourConversion (string n, double i, bool il, double const m[3][3], double o)
+ : name (n)
+ , conversion (i, il, m, o)
+{
+
+}
+
+PresetColourConversion::PresetColourConversion (shared_ptr<cxml::Node> node)
+ : conversion (node)
+{
+ name = node->string_child ("Name");
+}
+
+void
+PresetColourConversion::as_xml (xmlpp::Node* node) const
+{
+ conversion.as_xml (node);
+ node->add_child("Name")->add_child_text (name);
+}
+
+static bool
+about_equal (double a, double b)
+{
+ static const double eps = 1e-6;
+ return fabs (a - b) < eps;
+}
+
+bool
+operator== (ColourConversion const & a, ColourConversion const & b)
+{
+ if (
+ !about_equal (a.input_gamma, b.input_gamma) ||
+ a.input_gamma_linearised != b.input_gamma_linearised ||
+ !about_equal (a.output_gamma, b.output_gamma)) {
+ return false;
+ }
+
+ for (int i = 0; i < 3; ++i) {
+ for (int j = 0; j < 3; ++j) {
+ if (!about_equal (a.matrix (i, j), b.matrix (i, j))) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool
+operator!= (ColourConversion const & a, ColourConversion const & b)
+{
+ return !(a == b);
+}
*/
+#ifndef DCPOMATIC_COLOUR_CONVERSION_H
+#define DCPOMATIC_COLOUR_CONVERSION_H
+
#include <boost/utility.hpp>
+#include <boost/optional.hpp>
#include <boost/numeric/ublas/matrix.hpp>
namespace cxml {
class Node;
}
-class ColourConversion : public boost::noncopyable
+class ColourConversion
{
public:
ColourConversion ();
- ColourConversion (std::string, float, bool, float const matrix[3][3], float);
+ ColourConversion (double, bool, double const matrix[3][3], double);
ColourConversion (boost::shared_ptr<cxml::Node>);
+ virtual void as_xml (xmlpp::Node *) const;
+
+ boost::optional<size_t> preset () const;
+
+ double input_gamma;
+ bool input_gamma_linearised;
+ boost::numeric::ublas::matrix<double> matrix;
+ double output_gamma;
+};
+
+class PresetColourConversion
+{
+public:
+ PresetColourConversion ();
+ PresetColourConversion (std::string, double, bool, double const matrix[3][3], double);
+ PresetColourConversion (boost::shared_ptr<cxml::Node>);
+
void as_xml (xmlpp::Node *) const;
std::string name;
- float input_gamma;
- bool input_gamma_linearised;
- boost::numeric::ublas::matrix<float> matrix;
- float output_gamma;
+ ColourConversion conversion;
};
+
+bool operator== (ColourConversion const &, ColourConversion const &);
+bool operator!= (ColourConversion const &, ColourConversion const &);
+
+#endif
_allowed_dcp_frame_rates.push_back (50);
_allowed_dcp_frame_rates.push_back (60);
- _colour_conversions.push_back (shared_ptr<ColourConversion> (
- new ColourConversion (_("sRGB"), 2.4, true, libdcp::colour_matrix::xyz_to_rgb, 2.6))
- );
-
- _colour_conversions.push_back (shared_ptr<ColourConversion> (
- new ColourConversion (_("sRGB non-linearised"), 2.4, false, libdcp::colour_matrix::xyz_to_rgb, 2.6))
- );
+ _colour_conversions.push_back (PresetColourConversion (_("sRGB"), 2.4, true, libdcp::colour_matrix::xyz_to_rgb, 2.6));
+ _colour_conversions.push_back (PresetColourConversion (_("sRGB non-linearised"), 2.4, false, libdcp::colour_matrix::xyz_to_rgb, 2.6));
}
void
list<shared_ptr<cxml::Node> > servers = f.node_children ("Server");
for (list<shared_ptr<cxml::Node> >::iterator i = servers.begin(); i != servers.end(); ++i) {
- _servers.push_back (shared_ptr<ServerDescription> (new ServerDescription (*i)));
+ _servers.push_back (ServerDescription (*i));
}
_tms_ip = f.string_child ("TMSIP");
}
for (list<shared_ptr<cxml::Node> >::iterator i = cc.begin(); i != cc.end(); ++i) {
- _colour_conversions.push_back (shared_ptr<ColourConversion> (new ColourConversion (*i)));
+ _colour_conversions.push_back (PresetColourConversion (*i));
}
}
} else if (k == N_("server_port")) {
_server_port = atoi (v.c_str ());
} else if (k == N_("server")) {
- _servers.push_back (ServerDescription::create_from_metadata (v));
+ optional<ServerDescription> server = ServerDescription::create_from_metadata (v);
+ if (server) {
+ _servers.push_back (server.get ());
+ }
} else if (k == N_("tms_ip")) {
_tms_ip = v;
} else if (k == N_("tms_path")) {
root->add_child("DefaultDirectory")->add_child_text (_default_directory);
root->add_child("ServerPort")->add_child_text (lexical_cast<string> (_server_port));
- for (vector<shared_ptr<ServerDescription> >::const_iterator i = _servers.begin(); i != _servers.end(); ++i) {
- (*i)->as_xml (root->add_child ("Server"));
+ for (vector<ServerDescription>::const_iterator i = _servers.begin(); i != _servers.end(); ++i) {
+ i->as_xml (root->add_child ("Server"));
}
root->add_child("TMSIP")->add_child_text (_tms_ip);
root->add_child("DefaultStillLength")->add_child_text (lexical_cast<string> (_default_still_length));
root->add_child("DefaultJ2KBandwidth")->add_child_text (lexical_cast<string> (_default_j2k_bandwidth));
- for (vector<shared_ptr<ColourConversion> >::const_iterator i = _colour_conversions.begin(); i != _colour_conversions.end(); ++i) {
- (*i)->as_xml (root->add_child ("ColourConversion"));
+ for (vector<PresetColourConversion>::const_iterator i = _colour_conversions.begin(); i != _colour_conversions.end(); ++i) {
+ i->as_xml (root->add_child ("ColourConversion"));
}
doc.write_to_file_formatted (file (false));
#include <boost/signals2.hpp>
#include <libdcp/metadata.h>
#include "dci_metadata.h"
+#include "colour_conversion.h"
+#include "server.h"
class ServerDescription;
class Scaler;
class SoundProcessor;
class DCPContentType;
class Ratio;
-class ColourConversion;
/** @class Config
* @brief A singleton class holding configuration.
}
/** @return J2K encoding servers to use */
- std::vector<boost::shared_ptr<ServerDescription> > servers () const {
+ std::vector<ServerDescription> servers () const {
return _servers;
}
return _default_j2k_bandwidth;
}
- std::vector<boost::shared_ptr<ColourConversion> > colour_conversions () const {
+ std::vector<PresetColourConversion> colour_conversions () const {
return _colour_conversions;
}
}
/** @param s New list of servers */
- void set_servers (std::vector<boost::shared_ptr<ServerDescription> > s) {
+ void set_servers (std::vector<ServerDescription> s) {
_servers = s;
}
_default_j2k_bandwidth = b;
}
- void set_colour_conversions (std::vector<boost::shared_ptr<ColourConversion> > const & c) {
+ void set_colour_conversions (std::vector<PresetColourConversion> const & c) {
_colour_conversions = c;
}
int _server_port;
/** J2K encoding servers to use */
- std::vector<boost::shared_ptr<ServerDescription> > _servers;
+ std::vector<ServerDescription> _servers;
/** Scaler to use for the "A" part of A/B comparisons */
Scaler const * _reference_scaler;
/** Filters to use for the "A" part of A/B comparisons */
DCPContentType const * _default_dcp_content_type;
libdcp::XMLMetadata _dcp_metadata;
int _default_j2k_bandwidth;
- std::vector<boost::shared_ptr<ColourConversion> > _colour_conversions;
+ std::vector<PresetColourConversion> _colour_conversions;
/** Singleton instance, or 0 */
static Config* _instance;
* @return Encoded data.
*/
shared_ptr<EncodedData>
-DCPVideoFrame::encode_remotely (boost::shared_ptr<const ServerDescription> serv)
+DCPVideoFrame::encode_remotely (ServerDescription serv)
{
boost::asio::io_service io_service;
boost::asio::ip::tcp::resolver resolver (io_service);
- boost::asio::ip::tcp::resolver::query query (serv->host_name(), boost::lexical_cast<string> (Config::instance()->server_port ()));
+ boost::asio::ip::tcp::resolver::query query (serv.host_name(), boost::lexical_cast<string> (Config::instance()->server_port ()));
boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve (query);
shared_ptr<Socket> socket (new Socket);
DCPVideoFrame (boost::shared_ptr<const Image>, int, Eyes, int, int, boost::shared_ptr<Log>);
boost::shared_ptr<EncodedData> encode_locally ();
- boost::shared_ptr<EncodedData> encode_remotely (boost::shared_ptr<const ServerDescription>);
+ boost::shared_ptr<EncodedData> encode_remotely (ServerDescription);
Eyes eyes () const {
return _eyes;
Encoder::process_begin ()
{
for (int i = 0; i < Config::instance()->num_local_encoding_threads (); ++i) {
- _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, shared_ptr<ServerDescription> ())));
+ _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<ServerDescription> ())));
}
- vector<shared_ptr<ServerDescription> > servers = Config::instance()->servers ();
+ vector<ServerDescription> servers = Config::instance()->servers ();
- for (vector<shared_ptr<ServerDescription> >::iterator i = servers.begin(); i != servers.end(); ++i) {
- for (int j = 0; j < (*i)->threads (); ++j) {
+ for (vector<ServerDescription>::iterator i = servers.begin(); i != servers.end(); ++i) {
+ for (int j = 0; j < i->threads (); ++j) {
_threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, *i)));
}
}
}
void
-Encoder::encoder_thread (shared_ptr<ServerDescription> server)
+Encoder::encoder_thread (optional<ServerDescription> server)
{
/* Number of seconds that we currently wait between attempts
to connect to the server; not relevant for localhost
if (server) {
try {
- encoded = vf->encode_remotely (server);
+ encoded = vf->encode_remotely (server.get ());
if (remote_backoff > 0) {
_film->log()->log (String::compose (N_("%1 was lost, but now she is found; removing backoff"), server->host_name ()));
void frame_done ();
- void encoder_thread (boost::shared_ptr<ServerDescription>);
+ void encoder_thread (boost::optional<ServerDescription>);
void terminate_threads ();
/** Film that we are encoding */
using boost::thread;
using boost::bind;
using boost::scoped_array;
+using boost::optional;
using libdcp::Size;
ServerDescription::ServerDescription (shared_ptr<const cxml::Node> node)
* @param v Metadata.
* @return ServerDescription, or 0.
*/
-shared_ptr<ServerDescription>
+optional<ServerDescription>
ServerDescription::create_from_metadata (string v)
{
vector<string> b;
split (b, v, is_any_of (N_(" ")));
if (b.size() != 2) {
- return shared_ptr<ServerDescription> ();
+ return optional<ServerDescription> ();
}
- return shared_ptr<ServerDescription> (new ServerDescription (b[0], atoi (b[1].c_str ())));
+ return ServerDescription (b[0], atoi (b[1].c_str ()));
}
Server::Server (shared_ptr<Log> log)
*/
+#ifndef DCPOMATIC_SERVER_H
+#define DCPOMATIC_SERVER_H
+
/** @file src/server.h
* @brief Class to describe a server to which we can send
* encoding work, and a class to implement such a server.
void as_xml (xmlpp::Node *) const;
- static boost::shared_ptr<ServerDescription> create_from_metadata (std::string v);
+ static boost::optional<ServerDescription> create_from_metadata (std::string);
private:
/** server's host name */
boost::condition _worker_condition;
boost::shared_ptr<Log> _log;
};
+
+#endif
#include "video_examiner.h"
#include "ratio.h"
#include "compose.hpp"
+#include "config.h"
+#include "colour_conversion.h"
#include "i18n.h"
-int const VideoContentProperty::VIDEO_SIZE = 0;
-int const VideoContentProperty::VIDEO_FRAME_RATE = 1;
-int const VideoContentProperty::VIDEO_FRAME_TYPE = 2;
-int const VideoContentProperty::VIDEO_CROP = 3;
-int const VideoContentProperty::VIDEO_RATIO = 4;
+int const VideoContentProperty::VIDEO_SIZE = 0;
+int const VideoContentProperty::VIDEO_FRAME_RATE = 1;
+int const VideoContentProperty::VIDEO_FRAME_TYPE = 2;
+int const VideoContentProperty::VIDEO_CROP = 3;
+int const VideoContentProperty::VIDEO_RATIO = 4;
+int const VideoContentProperty::COLOUR_CONVERSION = 5;
using std::string;
using std::stringstream;
, _video_frame_rate (0)
, _video_frame_type (VIDEO_FRAME_TYPE_2D)
, _ratio (Ratio::from_id ("185"))
+ , _colour_conversion (Config::instance()->colour_conversions().front().conversion)
{
}
, _video_frame_rate (0)
, _video_frame_type (VIDEO_FRAME_TYPE_2D)
, _ratio (Ratio::from_id ("185"))
+ , _colour_conversion (Config::instance()->colour_conversions().front().conversion)
{
}
if (r) {
_ratio = Ratio::from_id (r.get ());
}
+ _colour_conversion = ColourConversion (node->node_child ("ColourConversion"));
}
void
if (_ratio) {
node->add_child("Ratio")->add_child_text (_ratio->id ());
}
+ _colour_conversion.as_xml (node->add_child("ColourConversion"));
}
void
assert (false);
}
+
+void
+VideoContent::set_colour_conversion (ColourConversion c)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _colour_conversion = c;
+ }
+
+ signal_changed (VideoContentProperty::COLOUR_CONVERSION);
+}
#define DCPOMATIC_VIDEO_CONTENT_H
#include "content.h"
+#include "colour_conversion.h"
class VideoExaminer;
class Ratio;
static int const VIDEO_FRAME_TYPE;
static int const VIDEO_CROP;
static int const VIDEO_RATIO;
+ static int const COLOUR_CONVERSION;
};
class VideoContent : public virtual Content
void set_top_crop (int);
void set_bottom_crop (int);
+ void set_colour_conversion (ColourConversion);
+
VideoFrameType video_frame_type () const {
boost::mutex::scoped_lock lm (_mutex);
return _video_frame_type;
return _ratio;
}
+ ColourConversion colour_conversion () const {
+ boost::mutex::scoped_lock lm (_mutex);
+ return _colour_conversion;
+ }
+
libdcp::Size video_size_after_3d_split () const;
protected:
VideoFrameType _video_frame_type;
Crop _crop;
Ratio const * _ratio;
+ ColourConversion _colour_conversion;
};
#endif
dcpomatic_setup ();
if (no_remote) {
- Config::instance()->set_servers (vector<shared_ptr<ServerDescription> > ());
+ Config::instance()->set_servers (vector<ServerDescription> ());
}
cout << "DCP-o-matic " << dcpomatic_version << " git " << dcpomatic_git_commit;
+++ /dev/null
-/*
- Copyright (C) 2013 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 <boost/lexical_cast.hpp>
-#include <wx/spinctrl.h>
-#include <wx/gbsizer.h>
-#include "lib/colour_conversion.h"
-#include "wx_util.h"
-#include "colour_conversion_dialog.h"
-
-using std::string;
-using std::cout;
-using boost::shared_ptr;
-using boost::lexical_cast;
-
-ColourConversionDialog::ColourConversionDialog (wxWindow* parent, shared_ptr<ColourConversion> conversion)
- : wxDialog (parent, wxID_ANY, _("Colour conversion"))
- , _conversion (conversion)
-{
- wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
- SetSizer (overall_sizer);
-
- wxGridBagSizer* table = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
- overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-
- int r = 0;
-
- add_label_to_grid_bag_sizer (table, this, _("Name"), true, wxGBPosition (r, 0));
- _name = new wxTextCtrl (this, wxID_ANY, wxT (""));
- table->Add (_name, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
- ++r;
-
- add_label_to_grid_bag_sizer (table, this, _("Input gamma"), true, wxGBPosition (r, 0));
- _input_gamma = new wxSpinCtrlDouble (this);
- table->Add (_input_gamma, wxGBPosition (r, 1));
- ++r;
-
- _input_gamma_linearised = new wxCheckBox (this, wxID_ANY, _("Linearise input gamma curve for low values"));
- table->Add (_input_gamma_linearised, wxGBPosition (r, 0), wxGBSpan (1, 2));
- ++r;
-
- wxClientDC dc (parent);
- wxSize size = dc.GetTextExtent (wxT ("0.123456789012"));
- size.SetHeight (-1);
-
- wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
- wxArrayString list;
-
- wxString n (wxT ("0123456789.-"));
- for (size_t i = 0; i < n.Length(); ++i) {
- list.Add (n[i]);
- }
-
- validator.SetIncludes (list);
-
- add_label_to_grid_bag_sizer (table, this, _("Matrix"), true, wxGBPosition (r, 0));
- wxFlexGridSizer* matrix_sizer = new wxFlexGridSizer (3, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
- for (int x = 0; x < 3; ++x) {
- for (int y = 0; y < 3; ++y) {
- _matrix[x][y] = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, size, 0, validator);
- matrix_sizer->Add (_matrix[x][y]);
- }
- }
- table->Add (matrix_sizer, wxGBPosition (r, 1));
- ++r;
-
- add_label_to_grid_bag_sizer (table, this, _("Output gamma"), true, wxGBPosition (r, 0));
- wxBoxSizer* output_sizer = new wxBoxSizer (wxHORIZONTAL);
- /* TRANSLATORS: this means the mathematical reciprocal operation, i.e. we are dividing 1 by the control that
- comes after it.
- */
- add_label_to_sizer (output_sizer, this, _("1 / "), false);
- _output_gamma = new wxSpinCtrlDouble (this);
- output_sizer->Add (_output_gamma);
- table->Add (output_sizer, wxGBPosition (r, 1));
- ++r;
-
- wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
- if (buttons) {
- overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
- }
-
- SetSizer (overall_sizer);
- overall_sizer->Layout ();
- overall_sizer->SetSizeHints (this);
-
- _input_gamma->SetRange(0.1, 4.0);
- _input_gamma->SetDigits (1);
- _input_gamma->SetIncrement (0.1);
- _output_gamma->SetRange(0.1, 4.0);
- _output_gamma->SetDigits (1);
- _output_gamma->SetIncrement (0.1);
-
- _name->SetValue (std_to_wx (conversion->name));
- _input_gamma->SetValue (conversion->input_gamma);
- _input_gamma_linearised->SetValue (conversion->input_gamma_linearised);
- for (int i = 0; i < 3; ++i) {
- for (int j = 0; j < 3; ++j) {
- _matrix[i][j]->SetValue (std_to_wx (lexical_cast<string> (conversion->matrix(i, j))));
- }
- }
- _output_gamma->SetValue (conversion->output_gamma);
-
- _name->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ColourConversionDialog::changed, this));
- _input_gamma->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ColourConversionDialog::changed, this));
- _input_gamma_linearised->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ColourConversionDialog::changed, this));
- _output_gamma->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ColourConversionDialog::changed, this));
- for (int i = 0; i < 3; ++i) {
- for (int j = 0; j < 3; ++j) {
- _matrix[i][j]->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ColourConversionDialog::changed, this));
- }
- }
-}
-
-void
-ColourConversionDialog::changed ()
-{
- _conversion->name = wx_to_std (_name->GetValue ());
- _conversion->input_gamma = _input_gamma->GetValue ();
- _conversion->input_gamma_linearised = _input_gamma_linearised->GetValue ();
-
- for (int i = 0; i < 3; ++i) {
- for (int j = 0; j < 3; ++j) {
- string const v = wx_to_std (_matrix[i][j]->GetValue ());
- if (v.empty ()) {
- _conversion->matrix (i, j) = 0;
- } else {
- _conversion->matrix (i, j) = lexical_cast<float> (v);
- }
- }
- }
- _conversion->output_gamma = _output_gamma->GetValue ();
-}
-
+++ /dev/null
-/*
- Copyright (C) 2013 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 <wx/wx.h>
-
-class wxSpinCtrlDouble;
-class ColourConversion;
-
-class ColourConversionDialog : public wxDialog
-{
-public:
- ColourConversionDialog (wxWindow *, boost::shared_ptr<ColourConversion>);
-
-private:
- void changed ();
-
- boost::shared_ptr<ColourConversion> _conversion;
- wxTextCtrl* _name;
- wxSpinCtrlDouble* _input_gamma;
- wxCheckBox* _input_gamma_linearised;
- wxTextCtrl* _matrix[3][3];
- wxSpinCtrlDouble* _output_gamma;
-};
--- /dev/null
+/*
+ Copyright (C) 2013 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 <boost/lexical_cast.hpp>
+#include <wx/spinctrl.h>
+#include <wx/gbsizer.h>
+#include "lib/colour_conversion.h"
+#include "wx_util.h"
+#include "colour_conversion_editor.h"
+
+using std::string;
+using std::cout;
+using std::stringstream;
+using boost::shared_ptr;
+using boost::lexical_cast;
+
+ColourConversionEditor::ColourConversionEditor (wxWindow* parent)
+ : wxPanel (parent, wxID_ANY)
+{
+ wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ SetSizer (overall_sizer);
+
+ wxGridBagSizer* table = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+
+ int r = 0;
+
+ add_label_to_grid_bag_sizer (table, this, _("Input gamma"), true, wxGBPosition (r, 0));
+ _input_gamma = new wxSpinCtrlDouble (this);
+ table->Add (_input_gamma, wxGBPosition (r, 1));
+ ++r;
+
+ _input_gamma_linearised = new wxCheckBox (this, wxID_ANY, _("Linearise input gamma curve for low values"));
+ table->Add (_input_gamma_linearised, wxGBPosition (r, 0), wxGBSpan (1, 2));
+ ++r;
+
+ wxClientDC dc (parent);
+ wxSize size = dc.GetTextExtent (wxT ("-0.123456789012345678"));
+ size.SetHeight (-1);
+
+ wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
+ wxArrayString list;
+
+ wxString n (wxT ("0123456789.-"));
+ for (size_t i = 0; i < n.Length(); ++i) {
+ list.Add (n[i]);
+ }
+
+ validator.SetIncludes (list);
+
+ add_label_to_grid_bag_sizer (table, this, _("Matrix"), true, wxGBPosition (r, 0));
+ wxFlexGridSizer* matrix_sizer = new wxFlexGridSizer (3, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ for (int i = 0; i < 3; ++i) {
+ for (int j = 0; j < 3; ++j) {
+ _matrix[i][j] = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, size, 0, validator);
+ matrix_sizer->Add (_matrix[i][j]);
+ }
+ }
+ table->Add (matrix_sizer, wxGBPosition (r, 1));
+ ++r;
+
+ add_label_to_grid_bag_sizer (table, this, _("Output gamma"), true, wxGBPosition (r, 0));
+ wxBoxSizer* output_sizer = new wxBoxSizer (wxHORIZONTAL);
+ /* TRANSLATORS: this means the mathematical reciprocal operation, i.e. we are dividing 1 by the control that
+ comes after it.
+ */
+ add_label_to_sizer (output_sizer, this, _("1 / "), false);
+ _output_gamma = new wxSpinCtrlDouble (this);
+ output_sizer->Add (_output_gamma);
+ table->Add (output_sizer, wxGBPosition (r, 1));
+ ++r;
+
+ _input_gamma->SetRange(0.1, 4.0);
+ _input_gamma->SetDigits (1);
+ _input_gamma->SetIncrement (0.1);
+ _output_gamma->SetRange(0.1, 4.0);
+ _output_gamma->SetDigits (1);
+ _output_gamma->SetIncrement (0.1);
+
+ _input_gamma->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ColourConversionEditor::changed, this));
+ _input_gamma_linearised->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ColourConversionEditor::changed, this));
+ for (int i = 0; i < 3; ++i) {
+ for (int j = 0; j < 3; ++j) {
+ _matrix[i][j]->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ColourConversionEditor::changed, this));
+ }
+ }
+ _output_gamma->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ColourConversionEditor::changed, this));
+}
+
+void
+ColourConversionEditor::set (ColourConversion conversion)
+{
+ _input_gamma->SetValue (conversion.input_gamma);
+ _input_gamma_linearised->SetValue (conversion.input_gamma_linearised);
+ for (int i = 0; i < 3; ++i) {
+ for (int j = 0; j < 3; ++j) {
+ stringstream s;
+ s.setf (std::ios::fixed, std::ios::floatfield);
+ s.precision (14);
+ s << conversion.matrix (i, j);
+ _matrix[i][j]->SetValue (std_to_wx (s.str ()));
+ }
+ }
+ _output_gamma->SetValue (conversion.output_gamma);
+}
+
+ColourConversion
+ColourConversionEditor::get () const
+{
+ ColourConversion conversion;
+
+ conversion.input_gamma = _input_gamma->GetValue ();
+ conversion.input_gamma_linearised = _input_gamma_linearised->GetValue ();
+
+ for (int i = 0; i < 3; ++i) {
+ for (int j = 0; j < 3; ++j) {
+ string const v = wx_to_std (_matrix[i][j]->GetValue ());
+ if (v.empty ()) {
+ conversion.matrix (i, j) = 0;
+ } else {
+ conversion.matrix (i, j) = lexical_cast<double> (v);
+ }
+ }
+ }
+
+ conversion.output_gamma = _output_gamma->GetValue ();
+
+ return conversion;
+}
+
+void
+ColourConversionEditor::changed ()
+{
+ Changed ();
+}
+
--- /dev/null
+/*
+ Copyright (C) 2013 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 DCPOMATIC_COLOUR_CONVERSION_EDITOR_H
+#define DCPOMATIC_COLOUR_CONVERSION_EDITOR_H
+
+#include <boost/signals2.hpp>
+#include <wx/wx.h>
+
+class wxSpinCtrlDouble;
+class ColourConversion;
+
+class ColourConversionEditor : public wxPanel
+{
+public:
+ ColourConversionEditor (wxWindow *);
+
+ void set (ColourConversion);
+ ColourConversion get () const;
+
+ boost::signals2::signal<void ()> Changed;
+
+private:
+ void changed ();
+
+ wxSpinCtrlDouble* _input_gamma;
+ wxCheckBox* _input_gamma_linearised;
+ wxTextCtrl* _matrix[3][3];
+ wxSpinCtrlDouble* _output_gamma;
+};
+
+#endif
#include "server_dialog.h"
#include "dir_picker_ctrl.h"
#include "dci_metadata_dialog.h"
-#include "colour_conversion_dialog.h"
+#include "preset_colour_conversion_dialog.h"
using std::vector;
using std::string;
}
static std::string
-server_column (shared_ptr<ServerDescription> s, int c)
+server_column (ServerDescription s, int c)
{
switch (c) {
case 0:
- return s->host_name ();
+ return s.host_name ();
case 1:
- return lexical_cast<string> (s->threads ());
+ return lexical_cast<string> (s.threads ());
}
return "";
}
static std::string
-colour_conversion_column (shared_ptr<ColourConversion> c)
+colour_conversion_column (PresetColourConversion c)
{
- return c->name;
+ return c.name;
}
void
{
vector<string> columns;
columns.push_back (wx_to_std (_("Name")));
- _colour_conversions_panel = new EditableList<ColourConversion, ColourConversionDialog> (
+ _colour_conversions_panel = new EditableList<PresetColourConversion, PresetColourConversionDialog> (
_notebook,
columns,
boost::bind (&Config::colour_conversions, Config::instance()),
class DirPickerCtrl;
class wxNotebook;
class ServerDescription;
-class ColourConversion;
-class ColourConversionDialog;
+class PresetColourConversion;
+class PresetColourConversionDialog;
class ServerDialog;
/** @class ConfigDialog
wxNotebook* _notebook;
wxPanel* _misc_panel;
wxPanel* _tms_panel;
- EditableList<ColourConversion, ColourConversionDialog>* _colour_conversions_panel;
+ EditableList<PresetColourConversion, PresetColourConversionDialog>* _colour_conversions_panel;
EditableList<ServerDescription, ServerDialog>* _servers_panel;
wxPanel* _metadata_panel;
wxCheckBox* _set_language;
--- /dev/null
+/*
+ Copyright (C) 2013 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 <wx/statline.h>
+#include "lib/colour_conversion.h"
+#include "lib/config.h"
+#include "wx_util.h"
+#include "content_colour_conversion_dialog.h"
+#include "colour_conversion_editor.h"
+
+using std::string;
+using std::vector;
+using std::cout;
+using boost::optional;
+
+ContentColourConversionDialog::ContentColourConversionDialog (wxWindow* parent)
+ : wxDialog (parent, wxID_ANY, _("Colour conversion"))
+ , _editor (new ColourConversionEditor (this))
+ , _setting (false)
+{
+ wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ SetSizer (overall_sizer);
+
+ wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ _preset_check = new wxCheckBox (this, wxID_ANY, _("Use preset"));
+ table->Add (_preset_check, 0, wxALIGN_CENTER_VERTICAL);
+ _preset_choice = new wxChoice (this, wxID_ANY);
+ table->Add (_preset_choice);
+
+ overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+ overall_sizer->Add (new wxStaticLine (this, wxID_ANY));
+ overall_sizer->Add (_editor);
+
+ wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
+ if (buttons) {
+ overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
+ }
+
+ overall_sizer->Layout ();
+ overall_sizer->SetSizeHints (this);
+
+ _preset_check->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ContentColourConversionDialog::preset_check_clicked, this));
+ _preset_choice->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&ContentColourConversionDialog::preset_choice_changed, this));
+
+ _editor->Changed.connect (boost::bind (&ContentColourConversionDialog::check_for_preset, this));
+
+ vector<PresetColourConversion> presets = Config::instance()->colour_conversions ();
+ for (vector<PresetColourConversion>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
+ _preset_choice->Append (std_to_wx (i->name));
+ }
+}
+
+ColourConversion
+ContentColourConversionDialog::get () const
+{
+ return _editor->get ();
+}
+
+void
+ContentColourConversionDialog::set (ColourConversion c)
+{
+ _setting = true;
+ _editor->set (c);
+ _setting = false;
+
+ check_for_preset ();
+}
+
+void
+ContentColourConversionDialog::check_for_preset ()
+{
+ if (_setting) {
+ return;
+ }
+
+ optional<size_t> preset = _editor->get().preset ();
+
+ _preset_check->SetValue (preset);
+ _preset_choice->Enable (preset);
+ _preset_choice->SetSelection (preset.get_value_or (-1));
+}
+
+void
+ContentColourConversionDialog::preset_check_clicked ()
+{
+ if (_preset_check->GetValue ()) {
+ _preset_choice->SetSelection (0);
+ preset_choice_changed ();
+ } else {
+ _preset_choice->SetSelection (-1);
+ _preset_choice->Enable (false);
+ }
+}
+
+void
+ContentColourConversionDialog::preset_choice_changed ()
+{
+ vector<PresetColourConversion> presets = Config::instance()->colour_conversions ();
+ int const s = _preset_choice->GetSelection();
+ if (s != -1) {
+ set (presets[s].conversion);
+ }
+}
+
+
--- /dev/null
+/*
+ Copyright (C) 2013 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 <wx/wx.h>
+
+class ColourConversionEditor;
+
+class ContentColourConversionDialog : public wxDialog
+{
+public:
+ ContentColourConversionDialog (wxWindow *);
+
+ void set (ColourConversion);
+ ColourConversion get () const;
+
+private:
+ void check_for_preset ();
+ void preset_check_clicked ();
+ void preset_choice_changed ();
+
+ wxCheckBox* _preset_check;
+ wxChoice* _preset_choice;
+ ColourConversionEditor* _editor;
+ bool _setting;
+};
EditableList (
wxWindow* parent,
std::vector<std::string> columns,
- boost::function<std::vector<boost::shared_ptr<T> > ()> get,
- boost::function<void (std::vector<boost::shared_ptr<T> >)> set,
- boost::function<std::string (boost::shared_ptr<T>, int)> column
+ boost::function<std::vector<T> ()> get,
+ boost::function<void (std::vector<T>)> set,
+ boost::function<std::string (T, int)> column
)
: wxPanel (parent)
, _get (get)
table->Add (s, 0);
}
- std::vector<boost::shared_ptr<T> > current = _get ();
- for (typename std::vector<boost::shared_ptr<T> >::iterator i = current.begin (); i != current.end(); ++i) {
+ std::vector<T> current = _get ();
+ for (typename std::vector<T>::iterator i = current.begin (); i != current.end(); ++i) {
add_to_control (*i);
}
_list->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&EditableList::selection_changed, this));
_list->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&EditableList::selection_changed, this));
+ _list->Bind (wxEVT_SIZE, boost::bind (&EditableList::resized, this, _1));
selection_changed ();
+
}
- void add_to_control (boost::shared_ptr<T> item)
+private:
+
+ void add_to_control (T item)
{
wxListItem list_item;
int const n = _list->GetItemCount ();
void add_clicked ()
{
- boost::shared_ptr<T> new_item (new T);
- S* dialog = new S (this, new_item);
+ T new_item;
+ S* dialog = new S (this);
+ dialog->set (new_item);
dialog->ShowModal ();
- dialog->Destroy ();
- add_to_control (new_item);
- std::vector<boost::shared_ptr<T> > all = _get ();
- all.push_back (new_item);
+ add_to_control (dialog->get ());
+
+ std::vector<T> all = _get ();
+ all.push_back (dialog->get ());
_set (all);
+
+ dialog->Destroy ();
}
void edit_clicked ()
return;
}
- std::vector<boost::shared_ptr<T> > all = _get ();
+ std::vector<T> all = _get ();
assert (item >= 0 && item < int (all.size ()));
- S* dialog = new S (this, all[item]);
+ S* dialog = new S (this);
+ dialog->set (all[item]);
dialog->ShowModal ();
+ all[item] = dialog->get ();
dialog->Destroy ();
-
+
for (int i = 0; i < _columns; ++i) {
_list->SetItem (item, i, std_to_wx (_column (all[item], i)));
}
_list->DeleteItem (i);
}
- std::vector<boost::shared_ptr<T> > all = _get ();
+ std::vector<T> all = _get ();
all.erase (all.begin() + i);
_set (all);
}
-private:
- boost::function <std::vector<boost::shared_ptr<T> > ()> _get;
- boost::function <void (std::vector<boost::shared_ptr<T> >)> _set;
+ void resized (wxSizeEvent& ev)
+ {
+ int const w = GetSize().GetWidth() / _columns;
+ for (int i = 0; i < _columns; ++i) {
+ _list->SetColumnWidth (i, w);
+ }
+ ev.Skip ();
+ }
+
+ boost::function <std::vector<T> ()> _get;
+ boost::function <void (std::vector<T>)> _set;
int _columns;
- boost::function<std::string (boost::shared_ptr<T>, int)> _column;
+ boost::function<std::string (T, int)> _column;
wxButton* _add;
wxButton* _edit;
film_content_changed (s, VideoContentProperty::VIDEO_CROP);
film_content_changed (s, VideoContentProperty::VIDEO_RATIO);
film_content_changed (s, VideoContentProperty::VIDEO_FRAME_TYPE);
+ film_content_changed (s, VideoContentProperty::COLOUR_CONVERSION);
film_content_changed (s, AudioContentProperty::AUDIO_GAIN);
film_content_changed (s, AudioContentProperty::AUDIO_DELAY);
film_content_changed (s, AudioContentProperty::AUDIO_MAPPING);
#include "lib/film.h"
#include "filter_dialog.h"
-#include "filter_view.h"
+#include "filter_editor.h"
using namespace std;
using boost::bind;
FilterDialog::FilterDialog (wxWindow* parent, vector<Filter const *> const & f)
: wxDialog (parent, wxID_ANY, wxString (_("Filters")))
- , _filters (new FilterView (this, f))
+ , _filters (new FilterEditor (this, f))
{
wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
sizer->Add (_filters, 1, wxEXPAND | wxALL, 6);
#include <boost/signals2.hpp>
class Film;
-class FilterView;
+class FilterEditor;
class Filter;
/** @class FilterDialog
private:
void active_changed ();
- FilterView* _filters;
+ FilterEditor* _filters;
};
--- /dev/null
+/*
+ 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.
+
+*/
+
+/** @file src/filter_editor.cc
+ * @brief A panel to select FFmpeg filters.
+ */
+
+#include <iostream>
+#include <algorithm>
+#include "lib/filter.h"
+#include "filter_editor.h"
+#include "wx_util.h"
+
+using namespace std;
+
+FilterEditor::FilterEditor (wxWindow* parent, vector<Filter const *> const & active)
+ : wxPanel (parent)
+{
+ wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+ SetSizer (sizer);
+
+ vector<Filter const *> filters = Filter::all ();
+
+ typedef map<string, list<Filter const *> > CategoryMap;
+ CategoryMap categories;
+
+ for (vector<Filter const *>::iterator i = filters.begin(); i != filters.end(); ++i) {
+ CategoryMap::iterator j = categories.find ((*i)->category ());
+ if (j == categories.end ()) {
+ list<Filter const *> c;
+ c.push_back (*i);
+ categories[(*i)->category()] = c;
+ } else {
+ j->second.push_back (*i);
+ }
+ }
+
+ for (CategoryMap::iterator i = categories.begin(); i != categories.end(); ++i) {
+
+ wxStaticText* c = new wxStaticText (this, wxID_ANY, std_to_wx (i->first));
+ wxFont font = c->GetFont();
+ font.SetWeight(wxFONTWEIGHT_BOLD);
+ c->SetFont(font);
+ sizer->Add (c);
+
+ for (list<Filter const *>::iterator j = i->second.begin(); j != i->second.end(); ++j) {
+ wxCheckBox* b = new wxCheckBox (this, wxID_ANY, std_to_wx ((*j)->name ()));
+ bool const a = find (active.begin(), active.end(), *j) != active.end ();
+ b->SetValue (a);
+ _filters[*j] = b;
+ b->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilterEditor::filter_toggled, this));
+ sizer->Add (b);
+ }
+
+ sizer->AddSpacer (6);
+ }
+}
+
+void
+FilterEditor::filter_toggled ()
+{
+ ActiveChanged ();
+}
+
+vector<Filter const*>
+FilterEditor::active () const
+{
+ vector<Filter const *> active;
+ for (map<Filter const *, wxCheckBox*>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
+ if (i->second->IsChecked ()) {
+ active.push_back (i->first);
+ }
+ }
+
+ return active;
+}
--- /dev/null
+/*
+ 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.
+
+*/
+
+/** @file src/filter_editor.h
+ * @brief A panel to select FFmpeg filters.
+ */
+
+#include <boost/signals2.hpp>
+#include <vector>
+#include <map>
+#include <wx/wx.h>
+
+class Filter;
+
+/** @class FilterEditor
+ * @brief A panel to select FFmpeg filters.
+ */
+class FilterEditor : public wxPanel
+{
+public:
+ FilterEditor (wxWindow *, std::vector<Filter const *> const &);
+
+ std::vector<Filter const *> active () const;
+
+ boost::signals2::signal<void()> ActiveChanged;
+
+private:
+ void filter_toggled ();
+
+ std::map<Filter const *, wxCheckBox *> _filters;
+};
+++ /dev/null
-/*
- 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.
-
-*/
-
-/** @file src/filter_view.cc
- * @brief A panel to select FFmpeg filters.
- */
-
-#include <iostream>
-#include <algorithm>
-#include "lib/filter.h"
-#include "filter_view.h"
-#include "wx_util.h"
-
-using namespace std;
-
-FilterView::FilterView (wxWindow* parent, vector<Filter const *> const & active)
- : wxPanel (parent)
-{
- wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
- SetSizer (sizer);
-
- vector<Filter const *> filters = Filter::all ();
-
- typedef map<string, list<Filter const *> > CategoryMap;
- CategoryMap categories;
-
- for (vector<Filter const *>::iterator i = filters.begin(); i != filters.end(); ++i) {
- CategoryMap::iterator j = categories.find ((*i)->category ());
- if (j == categories.end ()) {
- list<Filter const *> c;
- c.push_back (*i);
- categories[(*i)->category()] = c;
- } else {
- j->second.push_back (*i);
- }
- }
-
- for (CategoryMap::iterator i = categories.begin(); i != categories.end(); ++i) {
-
- wxStaticText* c = new wxStaticText (this, wxID_ANY, std_to_wx (i->first));
- wxFont font = c->GetFont();
- font.SetWeight(wxFONTWEIGHT_BOLD);
- c->SetFont(font);
- sizer->Add (c);
-
- for (list<Filter const *>::iterator j = i->second.begin(); j != i->second.end(); ++j) {
- wxCheckBox* b = new wxCheckBox (this, wxID_ANY, std_to_wx ((*j)->name ()));
- bool const a = find (active.begin(), active.end(), *j) != active.end ();
- b->SetValue (a);
- _filters[*j] = b;
- b->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&FilterView::filter_toggled, this));
- sizer->Add (b);
- }
-
- sizer->AddSpacer (6);
- }
-}
-
-void
-FilterView::filter_toggled ()
-{
- ActiveChanged ();
-}
-
-vector<Filter const*>
-FilterView::active () const
-{
- vector<Filter const *> active;
- for (map<Filter const *, wxCheckBox*>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
- if (i->second->IsChecked ()) {
- active.push_back (i->first);
- }
- }
-
- return active;
-}
+++ /dev/null
-/*
- 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.
-
-*/
-
-/** @file src/filter_view.h
- * @brief A panel to select FFmpeg filters.
- */
-
-#include <boost/signals2.hpp>
-#include <vector>
-#include <map>
-#include <wx/wx.h>
-
-class Filter;
-
-/** @class FilterView
- * @brief A panel to select FFmpeg filters.
- */
-class FilterView : public wxPanel
-{
-public:
- FilterView (wxWindow *, std::vector<Filter const *> const &);
-
- std::vector<Filter const *> active () const;
-
- boost::signals2::signal<void()> ActiveChanged;
-
-private:
- void filter_toggled ();
-
- std::map<Filter const *, wxCheckBox *> _filters;
-};
--- /dev/null
+/*
+ Copyright (C) 2013 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 <wx/statline.h>
+#include "lib/colour_conversion.h"
+#include "wx_util.h"
+#include "preset_colour_conversion_dialog.h"
+#include "colour_conversion_editor.h"
+
+using std::string;
+using std::cout;
+
+PresetColourConversionDialog::PresetColourConversionDialog (wxWindow* parent)
+ : wxDialog (parent, wxID_ANY, _("Colour conversion"))
+ , _editor (new ColourConversionEditor (this))
+{
+ wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ SetSizer (overall_sizer);
+
+ wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ add_label_to_sizer (table, this, _("Name"), true);
+ _name = new wxTextCtrl (this, wxID_ANY, wxT (""));
+ table->Add (_name);
+
+ overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+ overall_sizer->Add (new wxStaticLine (this, wxID_ANY));
+ overall_sizer->Add (_editor);
+
+ wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
+ if (buttons) {
+ overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
+ }
+
+ overall_sizer->Layout ();
+ overall_sizer->SetSizeHints (this);
+}
+
+PresetColourConversion
+PresetColourConversionDialog::get () const
+{
+ PresetColourConversion pc;
+ pc.name = wx_to_std (_name->GetValue ());
+ pc.conversion = _editor->get ();
+ return pc;
+}
+
+void
+PresetColourConversionDialog::set (PresetColourConversion c)
+{
+ _name->SetValue (std_to_wx (c.name));
+ _editor->set (c.conversion);
+}
--- /dev/null
+/*
+ Copyright (C) 2013 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 <wx/wx.h>
+
+class ColourConversionEditor;
+
+class PresetColourConversionDialog : public wxDialog
+{
+public:
+ PresetColourConversionDialog (wxWindow *);
+
+ void set (PresetColourConversion);
+ PresetColourConversion get () const;
+
+private:
+ wxTextCtrl* _name;
+ ColourConversionEditor* _editor;
+};
using boost::shared_ptr;
-ServerDialog::ServerDialog (wxWindow* parent, shared_ptr<ServerDescription> server)
+ServerDialog::ServerDialog (wxWindow* parent)
: wxDialog (parent, wxID_ANY, _("Server"))
{
- if (server) {
- _server = server;
- } else {
- _server.reset (new ServerDescription (wx_to_std (N_("localhost")), 1));
- }
-
wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
table->AddGrowableCol (1, 1);
_threads = new wxSpinCtrl (this, wxID_ANY);
table->Add (_threads, 1, wxEXPAND);
- _host->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ServerDialog::host_changed, this));
_threads->SetRange (0, 256);
- _threads->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&ServerDialog::threads_changed, this));
-
- _host->SetValue (std_to_wx (_server->host_name ()));
- _threads->SetValue (_server->threads ());
wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
overall_sizer->Add (table, 1, wxEXPAND | wxALL, 6);
}
void
-ServerDialog::host_changed ()
-{
- _server->set_host_name (wx_to_std (_host->GetValue ()));
-}
-
-void
-ServerDialog::threads_changed ()
+ServerDialog::set (ServerDescription server)
{
- _server->set_threads (_threads->GetValue ());
+ _host->SetValue (std_to_wx (server.host_name ()));
+ _threads->SetValue (server.threads ());
}
-shared_ptr<ServerDescription>
-ServerDialog::server () const
+ServerDescription
+ServerDialog::get () const
{
- return _server;
+ ServerDescription server;
+ server.set_host_name (wx_to_std (_host->GetValue ()));
+ server.set_threads (_threads->GetValue ());
+ return server;
}
class ServerDialog : public wxDialog
{
public:
- ServerDialog (wxWindow *, boost::shared_ptr<ServerDescription>);
+ ServerDialog (wxWindow *);
- boost::shared_ptr<ServerDescription> server () const;
+ void set (ServerDescription);
+ ServerDescription get () const;
private:
- void host_changed ();
- void threads_changed ();
-
- boost::shared_ptr<ServerDescription> _server;
wxTextCtrl* _host;
wxSpinCtrl* _threads;
};
#include "video_panel.h"
#include "wx_util.h"
#include "film_editor.h"
+#include "content_colour_conversion_dialog.h"
using std::vector;
using std::string;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using boost::bind;
+using boost::optional;
VideoPanel::VideoPanel (FilmEditor* e)
: FilmEditorPanel (e, _("Video"))
{
add_label_to_grid_bag_sizer (grid, this, _("Filters"), true, wxGBPosition (r, 0));
wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
- _filters = new wxStaticText (this, wxID_ANY, _("None"));
+
+ wxClientDC dc (this);
+ wxSize size = dc.GetTextExtent (wxT ("A quite long name"));
+ size.SetHeight (-1);
+
+ _filters = new wxStaticText (this, wxID_ANY, _("None"), wxDefaultPosition, size);
s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
_filters_button = new wxButton (this, wxID_ANY, _("Edit..."));
s->Add (_filters_button, 0, wxALIGN_CENTER_VERTICAL);
grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
}
++r;
+
+ {
+ add_label_to_grid_bag_sizer (grid, this, _("Colour conversion"), true, wxGBPosition (r, 0));
+ wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
- add_label_to_grid_bag_sizer (grid, this, _("Colour conversion"), true, wxGBPosition (r, 0));
- _colour_conversion = new wxChoice (this, wxID_ANY);
- grid->Add (_colour_conversion, wxGBPosition (r, 1));
+ wxClientDC dc (this);
+ wxSize size = dc.GetTextExtent (wxT ("A quite long name"));
+ size.SetHeight (-1);
+
+ _colour_conversion = new wxStaticText (this, wxID_ANY, wxT (""), wxDefaultPosition, size);
+
+ s->Add (_colour_conversion, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
+ _colour_conversion_button = new wxButton (this, wxID_ANY, _("Edit..."));
+ s->Add (_colour_conversion_button, 0, wxALIGN_CENTER_VERTICAL);
+ grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
+ }
++r;
_description = new wxStaticText (this, wxID_ANY, wxT ("\n \n \n \n \n"), wxDefaultPosition, wxDefaultSize);
_frame_type->Append (_("2D"));
_frame_type->Append (_("3D left/right"));
- setup_colour_conversions ();
-
- _frame_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::frame_type_changed, this));
- _left_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::left_crop_changed, this));
- _right_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::right_crop_changed, this));
- _top_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::top_crop_changed, this));
- _bottom_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::bottom_crop_changed, this));
- _ratio->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::ratio_changed, this));
- _filters_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_filters_clicked, this));
- _colour_conversion->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::colour_conversion_changed, this));
+ _frame_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::frame_type_changed, this));
+ _left_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::left_crop_changed, this));
+ _right_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::right_crop_changed, this));
+ _top_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::top_crop_changed, this));
+ _bottom_crop->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&VideoPanel::bottom_crop_changed, this));
+ _ratio->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&VideoPanel::ratio_changed, this));
+ _filters_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_filters_clicked, this));
+ _colour_conversion_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&VideoPanel::edit_colour_conversion_clicked, this));
}
setup_description ();
} else if (property == VideoContentProperty::VIDEO_FRAME_RATE) {
setup_description ();
+ } else if (property == VideoContentProperty::COLOUR_CONVERSION) {
+ optional<size_t> preset = vc ? vc->colour_conversion().preset () : optional<size_t> ();
+ vector<PresetColourConversion> cc = Config::instance()->colour_conversions ();
+ _colour_conversion->SetLabel (preset ? std_to_wx (cc[preset.get()].name) : _("Custom"));
} else if (property == FFmpegContentProperty::FILTERS) {
if (fc) {
pair<string, string> p = Filter::ffmpeg_strings (fc->filters ());
}
void
-VideoPanel::setup_colour_conversions ()
+VideoPanel::edit_colour_conversion_clicked ()
{
- vector<shared_ptr<ColourConversion> > cc = Config::instance()->colour_conversions ();
- for (vector<shared_ptr<ColourConversion> >::iterator i = cc.begin(); i != cc.end(); ++i) {
- _colour_conversion->Append (std_to_wx ((*i)->name));
+ shared_ptr<VideoContent> vc = _editor->selected_video_content ();
+ if (!vc) {
+ return;
}
-}
-void
-VideoPanel::colour_conversion_changed ()
-{
+ ColourConversion conversion = vc->colour_conversion ();
+ ContentColourConversionDialog* d = new ContentColourConversionDialog (this);
+ d->set (conversion);
+ d->ShowModal ();
+ vc->set_colour_conversion (d->get ());
+ d->Destroy ();
}
void edit_filters_clicked ();
void ratio_changed ();
void frame_type_changed ();
- void colour_conversion_changed ();
+ void edit_colour_conversion_clicked ();
void setup_description ();
- void setup_colour_conversions ();
wxChoice* _frame_type;
wxSpinCtrl* _left_crop;
wxStaticText* _description;
wxStaticText* _filters;
wxButton* _filters_button;
- wxChoice* _colour_conversion;
+ wxStaticText* _colour_conversion;
+ wxButton* _colour_conversion_button;
};
audio_mapping_view.cc
audio_panel.cc
audio_plot.cc
- colour_conversion_dialog.cc
+ colour_conversion_editor.cc
config_dialog.cc
+ content_colour_conversion_dialog.cc
content_menu.cc
dci_metadata_dialog.cc
dir_picker_ctrl.cc
film_editor_panel.cc
film_viewer.cc
filter_dialog.cc
- filter_view.cc
+ filter_editor.cc
gain_calculator_dialog.cc
job_manager_view.cc
job_wrapper.cc
new_film_dialog.cc
+ preset_colour_conversion_dialog.cc
properties_dialog.cc
repeat_dialog.cc
server_dialog.cc
using boost::thread;
void
-do_remote_encode (shared_ptr<DCPVideoFrame> frame, shared_ptr<ServerDescription> description, shared_ptr<EncodedData> locally_encoded)
+do_remote_encode (shared_ptr<DCPVideoFrame> frame, ServerDescription description, shared_ptr<EncodedData> locally_encoded)
{
shared_ptr<EncodedData> remotely_encoded;
BOOST_CHECK_NO_THROW (remotely_encoded = frame->encode_remotely (description));
/* Let the server get itself ready */
dcpomatic_sleep (1);
- shared_ptr<ServerDescription> description (new ServerDescription ("localhost", 2));
+ ServerDescription description ("localhost", 2);
list<thread*> threads;
for (int i = 0; i < 8; ++i) {
dcpomatic_setup();
Config::instance()->set_num_local_encoding_threads (1);
- Config::instance()->set_servers (vector<shared_ptr<ServerDescription> > ());
+ Config::instance()->set_servers (vector<ServerDescription> ());
Config::instance()->set_server_port (61920);
Config::instance()->set_default_dci_metadata (DCIMetadata ());
Config::instance()->set_default_container (static_cast<Ratio*> (0));