summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-01-26 22:51:54 +0000
committerCarl Hetherington <cth@carlh.net>2013-01-26 22:51:54 +0000
commitb1873c51b2e8265a01a8f0eced7fc3465f1677dc (patch)
treed0eb1d779f6f9e145e57693162af06a2390e84fb /src/lib
parent494b6ee180e531358bab39e72f6123e90f9314e5 (diff)
parentd641aee73077e93ca17b30acd5b9ed82f1e14cb9 (diff)
Merge master into direct-mxf.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/config.cc6
-rw-r--r--src/lib/config.h11
-rw-r--r--src/lib/dci_metadata.cc55
-rw-r--r--src/lib/dci_metadata.h40
-rw-r--r--src/lib/film.cc128
-rw-r--r--src/lib/film.h55
-rw-r--r--src/lib/format.cc9
-rw-r--r--src/lib/format.h3
-rw-r--r--src/lib/subtitle.cc2
-rw-r--r--src/lib/wscript3
10 files changed, 156 insertions, 156 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