summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-01-12 01:37:59 +0000
committerCarl Hetherington <cth@carlh.net>2013-01-12 01:37:59 +0000
commitae118502865c95f15317716aef8d26641b9e9c3f (patch)
treefb72e4985b8260f490860da84875fd7c6d6d8dae /src/lib
parent69d6f62af925aca5706136c5eb5f4194d8d1be3e (diff)
Try to move J2K bandwidth and colour LUT to be per-film (#23).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/config.cc8
-rw-r--r--src/lib/config.h29
-rw-r--r--src/lib/dcp_video_frame.cc30
-rw-r--r--src/lib/dcp_video_frame.h4
-rw-r--r--src/lib/encoder.cc2
-rw-r--r--src/lib/film.cc32
-rw-r--r--src/lib/film.h27
7 files changed, 75 insertions, 57 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index d19adc2a4..65d01bf00 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -40,8 +40,6 @@ Config* Config::_instance = 0;
Config::Config ()
: _num_local_encoding_threads (2)
, _server_port (6192)
- , _colour_lut_index (0)
- , _j2k_bandwidth (250000000)
, _reference_scaler (Scaler::from_id ("bicubic"))
, _tms_path (".")
, _sound_processor (SoundProcessor::from_id ("dolby_cp750"))
@@ -71,10 +69,6 @@ Config::Config ()
_default_directory = v;
} else if (k == "server_port") {
_server_port = atoi (v.c_str ());
- } else if (k == "colour_lut_index") {
- _colour_lut_index = atoi (v.c_str ());
- } else if (k == "j2k_bandwidth") {
- _j2k_bandwidth = atoi (v.c_str ());
} else if (k == "reference_scaler") {
_reference_scaler = Scaler::from_id (v);
} else if (k == "reference_filter") {
@@ -124,8 +118,6 @@ Config::write () const
f << "num_local_encoding_threads " << _num_local_encoding_threads << "\n"
<< "default_directory " << _default_directory << "\n"
<< "server_port " << _server_port << "\n"
- << "colour_lut_index " << _colour_lut_index << "\n"
- << "j2k_bandwidth " << _j2k_bandwidth << "\n"
<< "reference_scaler " << _reference_scaler->id () << "\n";
for (vector<Filter const *>::const_iterator i = _reference_filters.begin(); i != _reference_filters.end(); ++i) {
diff --git a/src/lib/config.h b/src/lib/config.h
index 4575cb54d..c84ce76b5 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -56,19 +56,6 @@ public:
return _server_port;
}
- /** @return index of colour LUT to use when converting RGB to XYZ.
- * 0: sRGB
- * 1: Rec 709
- */
- int colour_lut_index () const {
- return _colour_lut_index;
- }
-
- /** @return bandwidth for J2K files in bits per second */
- int j2k_bandwidth () const {
- return _j2k_bandwidth;
- }
-
/** @return J2K encoding servers to use */
std::vector<ServerDescription*> servers () const {
return _servers;
@@ -121,16 +108,6 @@ public:
_server_port = p;
}
- /** @param i New colour LUT index */
- void set_colour_lut_index (int i) {
- _colour_lut_index = i;
- }
-
- /** @param b New J2K bandwidth */
- void set_j2k_bandwidth (int b) {
- _j2k_bandwidth = b;
- }
-
/** @param s New list of servers */
void set_servers (std::vector<ServerDescription*> s) {
_servers = s;
@@ -178,12 +155,6 @@ private:
std::string _default_directory;
/** port to use for J2K encoding servers */
int _server_port;
- /** index of colour LUT to use when converting RGB to XYZ
- * (see colour_lut_index ())
- */
- int _colour_lut_index;
- /** bandwidth for J2K files in bits per second */
- int _j2k_bandwidth;
/** J2K encoding servers to use */
std::vector<ServerDescription *> _servers;
diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc
index 8b70b0aa4..c6b29ba41 100644
--- a/src/lib/dcp_video_frame.cc
+++ b/src/lib/dcp_video_frame.cc
@@ -88,7 +88,7 @@ DCPVideoFrame::DCPVideoFrame (
, _frame (f)
, _frames_per_second (dcp_frame_rate(fps).frames_per_second)
, _post_process (pp)
- , _colour_lut_index (clut)
+ , _colour_lut (clut)
, _j2k_bandwidth (bw)
, _log (l)
, _image (0)
@@ -188,22 +188,22 @@ DCPVideoFrame::encode_locally ()
for (int x = 0; x < _out_size.width; ++x) {
/* In gamma LUT (converting 8-bit input to 12-bit) */
- s.r = lut_in[_colour_lut_index][*p++ << 4];
- s.g = lut_in[_colour_lut_index][*p++ << 4];
- s.b = lut_in[_colour_lut_index][*p++ << 4];
+ s.r = lut_in[_colour_lut][*p++ << 4];
+ s.g = lut_in[_colour_lut][*p++ << 4];
+ s.b = lut_in[_colour_lut][*p++ << 4];
/* RGB to XYZ Matrix */
- d.x = ((s.r * color_matrix[_colour_lut_index][0][0]) +
- (s.g * color_matrix[_colour_lut_index][0][1]) +
- (s.b * color_matrix[_colour_lut_index][0][2]));
+ d.x = ((s.r * color_matrix[_colour_lut][0][0]) +
+ (s.g * color_matrix[_colour_lut][0][1]) +
+ (s.b * color_matrix[_colour_lut][0][2]));
- d.y = ((s.r * color_matrix[_colour_lut_index][1][0]) +
- (s.g * color_matrix[_colour_lut_index][1][1]) +
- (s.b * color_matrix[_colour_lut_index][1][2]));
+ d.y = ((s.r * color_matrix[_colour_lut][1][0]) +
+ (s.g * color_matrix[_colour_lut][1][1]) +
+ (s.b * color_matrix[_colour_lut][1][2]));
- d.z = ((s.r * color_matrix[_colour_lut_index][2][0]) +
- (s.g * color_matrix[_colour_lut_index][2][1]) +
- (s.b * color_matrix[_colour_lut_index][2][2]));
+ d.z = ((s.r * color_matrix[_colour_lut][2][0]) +
+ (s.g * color_matrix[_colour_lut][2][1]) +
+ (s.b * color_matrix[_colour_lut][2][2]));
/* DCI companding */
d.x = d.x * DCI_COEFFICENT * (DCI_LUT_SIZE - 1);
@@ -334,8 +334,8 @@ DCPVideoFrame::encode_remotely (ServerDescription const * serv)
s << "post_process " << _post_process << "\n";
}
- s << "colour_lut " << Config::instance()->colour_lut_index () << "\n"
- << "j2k_bandwidth " << Config::instance()->j2k_bandwidth () << "\n";
+ s << "colour_lut " << _colour_lut << "\n"
+ << "j2k_bandwidth " << _j2k_bandwidth << "\n";
if (_subtitle) {
s << "subtitle_x " << _subtitle->position().x << "\n"
diff --git a/src/lib/dcp_video_frame.h b/src/lib/dcp_video_frame.h
index 57e7e6203..134720da8 100644
--- a/src/lib/dcp_video_frame.h
+++ b/src/lib/dcp_video_frame.h
@@ -133,8 +133,8 @@ private:
SourceFrame _frame; ///< frame index within the Film's source
int _frames_per_second; ///< Frames per second that we will use for the DCP (rounded)
std::string _post_process; ///< FFmpeg post-processing string to use
- int _colour_lut_index; ///< Colour look-up table to use (see Config::colour_lut_index ())
- int _j2k_bandwidth; ///< J2K bandwidth to use (see Config::j2k_bandwidth ())
+ int _colour_lut; ///< Colour look-up table to use
+ int _j2k_bandwidth; ///< J2K bandwidth to use
Log* _log; ///< log
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index 693bd5bc8..efedfcfef 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -325,7 +325,7 @@ Encoder::process_video (shared_ptr<Image> image, bool same, boost::shared_ptr<Su
new DCPVideoFrame (
image, sub, _opt->out_size, _opt->padding, _film->subtitle_offset(), _film->subtitle_scale(),
_film->scaler(), _video_frame, _film->frames_per_second(), s.second,
- Config::instance()->colour_lut_index (), Config::instance()->j2k_bandwidth (),
+ _film->colour_lut(), _film->j2k_bandwidth(),
_film->log()
)
));
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 8fd8efc3a..4e48a0e73 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -99,6 +99,8 @@ Film::Film (string d, bool must_exist)
, _with_subtitles (false)
, _subtitle_offset (0)
, _subtitle_scale (1)
+ , _colour_lut (0)
+ , _j2k_bandwidth (200000000)
, _frames_per_second (0)
, _dirty (false)
{
@@ -166,6 +168,8 @@ Film::Film (Film const & o)
, _with_subtitles (o._with_subtitles)
, _subtitle_offset (o._subtitle_offset)
, _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)
@@ -249,7 +253,7 @@ Film::make_dcp (bool transcode)
log()->log (String::compose ("Content length %1", length()));
log()->log (String::compose ("Content digest %1", content_digest()));
log()->log (String::compose ("%1 threads", Config::instance()->num_local_encoding_threads()));
- log()->log (String::compose ("J2K bandwidth %1", Config::instance()->j2k_bandwidth()));
+ log()->log (String::compose ("J2K bandwidth %1", j2k_bandwidth()));
}
if (format() == 0) {
@@ -423,6 +427,8 @@ Film::write_metadata () const
f << "with_subtitles " << _with_subtitles << "\n";
f << "subtitle_offset " << _subtitle_offset << "\n";
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";
@@ -548,6 +554,10 @@ Film::read_metadata ()
_subtitle_offset = atoi (v.c_str ());
} else if (k == "subtitle_scale") {
_subtitle_scale = atof (v.c_str ());
+ } else if (k == "colour_lut") {
+ _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") {
@@ -1194,6 +1204,26 @@ Film::set_subtitle_scale (float s)
}
void
+Film::set_colour_lut (int i)
+{
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ _colour_lut = i;
+ }
+ signal_changed (COLOUR_LUT);
+}
+
+void
+Film::set_j2k_bandwidth (int b)
+{
+ {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ _j2k_bandwidth = b;
+ }
+ signal_changed (J2K_BANDWIDTH);
+}
+
+void
Film::set_audio_language (string l)
{
{
diff --git a/src/lib/film.h b/src/lib/film.h
index eb199784e..467573ae1 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -124,6 +124,8 @@ public:
WITH_SUBTITLES,
SUBTITLE_OFFSET,
SUBTITLE_SCALE,
+ COLOUR_LUT,
+ J2K_BANDWIDTH,
DCI_METADATA,
SIZE,
LENGTH,
@@ -250,6 +252,21 @@ public:
return _subtitle_scale;
}
+ /** @return index of colour LUT to use when converting RGB to XYZ.
+ * 0: sRGB
+ * 1: Rec 709
+ */
+ int colour_lut () const {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ return _colour_lut;
+ }
+
+ /** @return bandwidth for J2K files in bits per second */
+ int j2k_bandwidth () const {
+ boost::mutex::scoped_lock lm (_state_mutex);
+ return _j2k_bandwidth;
+ }
+
std::string audio_language () const {
boost::mutex::scoped_lock lm (_state_mutex);
return _audio_language;
@@ -351,6 +368,8 @@ public:
void set_with_subtitles (bool);
void set_subtitle_offset (int);
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);
@@ -444,7 +463,13 @@ private:
int _subtitle_offset;
/** scale factor to apply to subtitles */
float _subtitle_scale;
-
+ /** index of colour LUT to use when converting RGB to XYZ
+ * (see colour_lut ())
+ */
+ 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;