summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-01-21 01:57:06 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-21 01:57:06 +0100
commit76e3325a16cdf6d7220a61e2b5cfdb9c804cc32c (patch)
tree8c1b5e5dc2cec265469a0d8018b6d7396b089432 /src
parent6c3db78c3d20ef064fa2a0ef38e65ca1ae69adb3 (diff)
Use enum class for the things in types.h
Diffstat (limited to 'src')
-rw-r--r--src/asset.cc2
-rw-r--r--src/atmos_asset.cc7
-rw-r--r--src/certificate_chain.cc2
-rw-r--r--src/cpl.cc22
-rw-r--r--src/crypto_context.h2
-rw-r--r--src/dcp.cc34
-rw-r--r--src/dcp_time.cc2
-rw-r--r--src/decrypted_kdm.cc10
-rw-r--r--src/encrypted_kdm.cc8
-rw-r--r--src/interop_subtitle_asset.cc10
-rw-r--r--src/mono_picture_asset.cc2
-rw-r--r--src/mxf.cc6
-rw-r--r--src/picture_asset.cc18
-rw-r--r--src/pkl.cc6
-rw-r--r--src/reel.cc12
-rw-r--r--src/reel_asset.cc12
-rw-r--r--src/reel_closed_caption_asset.cc8
-rw-r--r--src/reel_mxf.cc4
-rw-r--r--src/reel_picture_asset.cc6
-rw-r--r--src/reel_stereo_picture_asset.cc4
-rw-r--r--src/rgb_xyz.cc8
-rw-r--r--src/smpte_subtitle_asset.cc43
-rw-r--r--src/sound_asset.cc26
-rw-r--r--src/sound_asset_writer.cc10
-rw-r--r--src/stereo_picture_asset.cc2
-rw-r--r--src/stereo_picture_asset_writer.cc14
-rw-r--r--src/stereo_picture_frame.cc13
-rw-r--r--src/stereo_picture_frame.h3
-rw-r--r--src/subtitle_asset.cc24
-rw-r--r--src/subtitle_asset_internal.cc24
-rw-r--r--src/subtitle_image.cc22
-rw-r--r--src/types.cc392
-rw-r--r--src/types.h65
-rw-r--r--src/verify.cc16
34 files changed, 488 insertions, 351 deletions
diff --git a/src/asset.cc b/src/asset.cc
index 49ec7251..8ac28afc 100644
--- a/src/asset.cc
+++ b/src/asset.cc
@@ -146,7 +146,7 @@ bool
Asset::equals (std::shared_ptr<const Asset> other, EqualityOptions, NoteHandler note) const
{
if (_hash != other->_hash) {
- note (DCP_ERROR, "Asset: hashes differ");
+ note (NoteType::ERROR, "Asset: hashes differ");
return false;
}
diff --git a/src/atmos_asset.cc b/src/atmos_asset.cc
index 2145d8f8..4b13ab4d 100644
--- a/src/atmos_asset.cc
+++ b/src/atmos_asset.cc
@@ -39,10 +39,11 @@
using std::string;
using std::shared_ptr;
+using std::make_shared;
using namespace dcp;
AtmosAsset::AtmosAsset (Fraction edit_rate, int first_frame, int max_channel_count, int max_object_count, int atmos_version)
- : MXF (SMPTE)
+ : MXF (Standard::SMPTE)
, _edit_rate (edit_rate)
, _intrinsic_duration (0)
, _first_frame (first_frame)
@@ -56,7 +57,7 @@ AtmosAsset::AtmosAsset (Fraction edit_rate, int first_frame, int max_channel_cou
AtmosAsset::AtmosAsset (boost::filesystem::path file)
: Asset (file)
- , MXF (SMPTE)
+ , MXF (Standard::SMPTE)
{
ASDCP::ATMOS::MXFReader reader;
Kumu::Result_t r = reader.OpenRead (file.string().c_str());
@@ -98,7 +99,7 @@ AtmosAsset::static_pkl_type (Standard)
shared_ptr<AtmosAssetReader>
AtmosAsset::start_read () const
{
- return shared_ptr<AtmosAssetReader> (new AtmosAssetReader (this, key(), SMPTE));
+ return make_shared<AtmosAssetReader>(this, key(), Standard::SMPTE);
}
shared_ptr<AtmosAssetWriter>
diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc
index a4da0931..2287a805 100644
--- a/src/certificate_chain.cc
+++ b/src/certificate_chain.cc
@@ -601,7 +601,7 @@ CertificateChain::sign (xmlpp::Element* parent, Standard standard) const
xmlpp::Element* signed_info = signature->add_child ("SignedInfo", "dsig");
signed_info->add_child("CanonicalizationMethod", "dsig")->set_attribute ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
- if (standard == INTEROP) {
+ if (standard == Standard::INTEROP) {
signed_info->add_child("SignatureMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#rsa-sha1");
} else {
signed_info->add_child("SignatureMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
diff --git a/src/cpl.cc b/src/cpl.cc
index a976e072..e932c678 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -89,15 +89,15 @@ CPL::CPL (string annotation_text, ContentKind content_kind)
/** Construct a CPL object from a XML file */
CPL::CPL (boost::filesystem::path file)
: Asset (file)
- , _content_kind (FEATURE)
+ , _content_kind (ContentKind::FEATURE)
{
cxml::Document f ("CompositionPlaylist");
f.read_file (file);
if (f.namespace_uri() == cpl_interop_ns) {
- _standard = INTEROP;
+ _standard = Standard::INTEROP;
} else if (f.namespace_uri() == cpl_smpte_ns) {
- _standard = SMPTE;
+ _standard = Standard::SMPTE;
} else {
boost::throw_exception (XMLError ("Unrecognised CPL namespace " + f.namespace_uri()));
}
@@ -119,7 +119,7 @@ CPL::CPL (boost::filesystem::path file)
)
);
content_version->done ();
- } else if (_standard == SMPTE) {
+ } else if (_standard == Standard::SMPTE) {
/* ContentVersion is required in SMPTE */
throw XMLError ("Missing ContentVersion tag in CPL");
}
@@ -171,7 +171,7 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons
{
xmlpp::Document doc;
xmlpp::Element* root;
- if (standard == INTEROP) {
+ if (standard == Standard::INTEROP) {
root = doc.create_root_node ("CompositionPlaylist", cpl_interop_ns);
} else {
root = doc.create_root_node ("CompositionPlaylist", cpl_smpte_ns);
@@ -207,7 +207,7 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons
bool first = true;
for (auto i: _reels) {
auto asset_list = i->write_to_cpl (reel_list, standard);
- if (first && standard == dcp::SMPTE) {
+ if (first && standard == Standard::SMPTE) {
maybe_write_composition_metadata_asset (asset_list);
first = false;
}
@@ -554,17 +554,17 @@ CPL::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler not
if (_annotation_text != other_cpl->_annotation_text && !opt.cpl_annotation_texts_can_differ) {
string const s = "CPL: annotation texts differ: " + _annotation_text.get_value_or("") + " vs " + other_cpl->_annotation_text.get_value_or("") + "\n";
- note (DCP_ERROR, s);
+ note (NoteType::ERROR, s);
return false;
}
if (_content_kind != other_cpl->_content_kind) {
- note (DCP_ERROR, "CPL: content kinds differ");
+ note (NoteType::ERROR, "CPL: content kinds differ");
return false;
}
if (_reels.size() != other_cpl->_reels.size()) {
- note (DCP_ERROR, String::compose ("CPL: reel counts differ (%1 vs %2)", _reels.size(), other_cpl->_reels.size()));
+ note (NoteType::ERROR, String::compose ("CPL: reel counts differ (%1 vs %2)", _reels.size(), other_cpl->_reels.size()));
return false;
}
@@ -640,9 +640,9 @@ string
CPL::static_pkl_type (Standard standard)
{
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
return "text/xml;asdcpKind=CPL";
- case SMPTE:
+ case Standard::SMPTE:
return "text/xml";
default:
DCP_ASSERT (false);
diff --git a/src/crypto_context.h b/src/crypto_context.h
index b01efce4..263121bf 100644
--- a/src/crypto_context.h
+++ b/src/crypto_context.h
@@ -70,7 +70,7 @@ public:
_hmac = new ASDCP::HMACContext;
ASDCP::LabelSet_t type;
- if (standard == INTEROP) {
+ if (standard == Standard::INTEROP) {
type = ASDCP::LS_MXF_INTEROP;
} else {
type = ASDCP::LS_MXF_SMPTE;
diff --git a/src/dcp.cc b/src/dcp.cc
index 11721b78..d8c8c130 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -124,9 +124,9 @@ DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_m
asset_map.read_file (_asset_map.get());
if (asset_map.namespace_uri() == assetmap_interop_ns) {
- _standard = INTEROP;
+ _standard = Standard::INTEROP;
} else if (asset_map.namespace_uri() == assetmap_smpte_ns) {
- _standard = SMPTE;
+ _standard = Standard::SMPTE;
} else {
boost::throw_exception (XMLError ("Unrecognised Assetmap namespace " + asset_map.namespace_uri()));
}
@@ -143,14 +143,14 @@ DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_m
p = p.substr (7);
}
switch (*_standard) {
- case INTEROP:
+ case Standard::INTEROP:
if (i->optional_node_child("PackingList")) {
pkl_paths.push_back (p);
} else {
paths.insert (make_pair (remove_urn_uuid (i->string_child ("Id")), p));
}
break;
- case SMPTE:
+ case Standard::SMPTE:
{
auto pkl_bool = i->optional_string_child("PackingList");
if (pkl_bool && *pkl_bool == "true") {
@@ -239,7 +239,7 @@ DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_m
}
_cpls.push_back (cpl);
} else if (root == "DCSubtitle") {
- if (_standard && _standard.get() == SMPTE && notes) {
+ if (_standard && _standard.get() == Standard::SMPTE && notes) {
notes->push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::MISMATCHED_STANDARD));
}
other_assets.push_back (make_shared<InteropSubtitleAsset>(path));
@@ -290,7 +290,7 @@ DCP::equals (DCP const & other, EqualityOptions opt, NoteHandler note) const
auto b = other.cpls ();
if (a.size() != b.size()) {
- note (DCP_ERROR, String::compose ("CPL counts differ: %1 vs %2", a.size(), b.size()));
+ note (NoteType::ERROR, String::compose ("CPL counts differ: %1 vs %2", a.size(), b.size()));
return false;
}
@@ -367,12 +367,12 @@ DCP::add (DecryptedKDM const & kdm)
void
DCP::write_volindex (Standard standard) const
{
- boost::filesystem::path p = _directory;
+ auto p = _directory;
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
p /= "VOLINDEX";
break;
- case SMPTE:
+ case Standard::SMPTE:
p /= "VOLINDEX.xml";
break;
default:
@@ -383,10 +383,10 @@ DCP::write_volindex (Standard standard) const
xmlpp::Element* root;
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
root = doc.create_root_node ("VolumeIndex", volindex_interop_ns);
break;
- case SMPTE:
+ case Standard::SMPTE:
root = doc.create_root_node ("VolumeIndex", volindex_smpte_ns);
break;
default:
@@ -406,10 +406,10 @@ DCP::write_assetmap (
auto p = _directory;
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
p /= "ASSETMAP";
break;
- case SMPTE:
+ case Standard::SMPTE:
p /= "ASSETMAP.xml";
break;
default:
@@ -420,10 +420,10 @@ DCP::write_assetmap (
xmlpp::Element* root;
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
root = doc.create_root_node ("AssetMap", assetmap_interop_ns);
break;
- case SMPTE:
+ case Standard::SMPTE:
root = doc.create_root_node ("AssetMap", assetmap_smpte_ns);
break;
default:
@@ -434,13 +434,13 @@ DCP::write_assetmap (
root->add_child("AnnotationText")->add_child_text (annotation_text);
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
root->add_child("VolumeCount")->add_child_text ("1");
root->add_child("IssueDate")->add_child_text (issue_date);
root->add_child("Issuer")->add_child_text (issuer);
root->add_child("Creator")->add_child_text (creator);
break;
- case SMPTE:
+ case Standard::SMPTE:
root->add_child("Creator")->add_child_text (creator);
root->add_child("VolumeCount")->add_child_text ("1");
root->add_child("IssueDate")->add_child_text (issue_date);
diff --git a/src/dcp_time.cc b/src/dcp_time.cc
index 025a4859..7a4a67d6 100644
--- a/src/dcp_time.cc
+++ b/src/dcp_time.cc
@@ -325,7 +325,7 @@ Time::as_string (Standard standard) const
{
char buffer[64];
- if (standard == SMPTE) {
+ if (standard == Standard::SMPTE) {
snprintf (buffer, sizeof(buffer), "%02d:%02d:%02d:%02d", h, m, s, e);
} else {
snprintf (buffer, sizeof(buffer), "%02d:%02d:%02d:%03d", h, m, s, e);
diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc
index dd6def32..10da80e6 100644
--- a/src/decrypted_kdm.cc
+++ b/src/decrypted_kdm.cc
@@ -178,7 +178,7 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key)
/* 93 is not-valid-after (a string) [25 bytes] */
p += 25;
/* 118 is the key [ASDCP::KeyLen bytes] */
- add_key (optional<string>(), key_id, Key (p), cpl_id, INTEROP);
+ add_key (optional<string>(), key_id, Key(p), cpl_id, Standard::INTEROP);
break;
}
case 138:
@@ -200,7 +200,7 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key)
/* 97 is not-valid-after (a string) [25 bytes] */
p += 25;
/* 112 is the key [ASDCP::KeyLen bytes] */
- add_key (key_type, key_id, Key (p), cpl_id, SMPTE);
+ add_key (key_type, key_id, Key(p), cpl_id, Standard::SMPTE);
break;
}
default:
@@ -250,7 +250,7 @@ DecryptedKDM::DecryptedKDM (
, _issue_date (issue_date)
{
for (map<shared_ptr<const ReelMXF>, Key>::const_iterator i = keys.begin(); i != keys.end(); ++i) {
- add_key (i->first->key_type(), i->first->key_id().get(), i->second, cpl_id, SMPTE);
+ add_key (i->first->key_type(), i->first->key_id().get(), i->second, cpl_id, Standard::SMPTE);
}
}
@@ -271,9 +271,9 @@ DecryptedKDM::DecryptedKDM (
{
/* Create DecryptedKDMKey objects for each encryptable asset */
bool did_one = false;
- BOOST_FOREACH(shared_ptr<const ReelMXF> i, cpl->reel_mxfs()) {
+ for (auto i: cpl->reel_mxfs()) {
if (i->key_id()) {
- add_key (i->key_type(), i->key_id().get(), key, cpl->id(), SMPTE);
+ add_key (i->key_type(), i->key_id().get(), key, cpl->id(), Standard::SMPTE);
did_one = true;
}
}
diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc
index a124fdf6..d7326e89 100644
--- a/src/encrypted_kdm.cc
+++ b/src/encrypted_kdm.cc
@@ -612,7 +612,7 @@ EncryptedKDM::EncryptedKDM (
kre.recipient.x509_issuer_serial.x509_serial_number = recipient.serial ();
kre.recipient.x509_subject_name = recipient.subject ();
kre.composition_playlist_id = cpl_id;
- if (formulation == DCI_ANY || formulation == DCI_SPECIFIC) {
+ if (formulation == Formulation::DCI_ANY || formulation == Formulation::DCI_SPECIFIC) {
kre.content_authenticator = signer->leaf().thumbprint ();
}
kre.content_title_text = content_title_text;
@@ -621,7 +621,7 @@ EncryptedKDM::EncryptedKDM (
kre.disable_forensic_marking_picture = disable_forensic_marking_picture;
kre.disable_forensic_marking_audio = disable_forensic_marking_audio;
- if (formulation != MODIFIED_TRANSITIONAL_TEST) {
+ if (formulation != Formulation::MODIFIED_TRANSITIONAL_TEST) {
kre.authorized_device_info = data::AuthorizedDeviceInfo ();
kre.authorized_device_info->device_list_identifier = make_uuid ();
auto n = recipient.subject_common_name ();
@@ -630,10 +630,10 @@ EncryptedKDM::EncryptedKDM (
}
kre.authorized_device_info->device_list_description = n;
- if (formulation == MODIFIED_TRANSITIONAL_1 || formulation == DCI_ANY) {
+ if (formulation == Formulation::MODIFIED_TRANSITIONAL_1 || formulation == Formulation::DCI_ANY) {
/* Use the "assume trust" thumbprint */
kre.authorized_device_info->certificate_thumbprints.push_back ("2jmj7l5rSw0yVb/vlWAYkK/YBwk=");
- } else if (formulation == MULTIPLE_MODIFIED_TRANSITIONAL_1 || formulation == DCI_SPECIFIC) {
+ } else if (formulation == Formulation::MULTIPLE_MODIFIED_TRANSITIONAL_1 || formulation == Formulation::DCI_SPECIFIC) {
if (trusted_devices.empty ()) {
/* Fall back on the "assume trust" thumbprint so we
can generate "modified-transitional-1" KDMs
diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc
index edc51404..f93e7cf4 100644
--- a/src/interop_subtitle_asset.cc
+++ b/src/interop_subtitle_asset.cc
@@ -79,7 +79,7 @@ InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file)
for (xmlpp::Node::NodeList::const_iterator i = c.begin(); i != c.end(); ++i) {
xmlpp::Element const * e = dynamic_cast<xmlpp::Element const *> (*i);
if (e && (e->get_name() == "Font" || e->get_name() == "Subtitle")) {
- parse_subtitles (e, ps, optional<int>(), INTEROP);
+ parse_subtitles (e, ps, optional<int>(), Standard::INTEROP);
}
}
@@ -114,7 +114,7 @@ InteropSubtitleAsset::xml_as_string () const
load_font->set_attribute ("URI", i->uri);
}
- subtitles_as_xml (root, 250, INTEROP);
+ subtitles_as_xml (root, 250, Standard::INTEROP);
return doc.write_to_string ("UTF-8");
}
@@ -145,12 +145,12 @@ InteropSubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptio
while (i != _load_font_nodes.end ()) {
if (j == other->_load_font_nodes.end ()) {
- note (DCP_ERROR, "<LoadFont> nodes differ");
+ note (NoteType::ERROR, "<LoadFont> nodes differ");
return false;
}
if (**i != **j) {
- note (DCP_ERROR, "<LoadFont> nodes differ");
+ note (NoteType::ERROR, "<LoadFont> nodes differ");
return false;
}
@@ -160,7 +160,7 @@ InteropSubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptio
}
if (_movie_title != other->_movie_title) {
- note (DCP_ERROR, "Subtitle movie titles differ");
+ note (NoteType::ERROR, "Subtitle movie titles differ");
return false;
}
diff --git a/src/mono_picture_asset.cc b/src/mono_picture_asset.cc
index 12165f7b..4524c85d 100644
--- a/src/mono_picture_asset.cc
+++ b/src/mono_picture_asset.cc
@@ -158,7 +158,7 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, No
#pragma omp critical
#endif
{
- note (DCP_PROGRESS, String::compose ("Compared video frame %1 of %2", i, _intrinsic_duration));
+ note (NoteType::PROGRESS, String::compose("Compared video frame %1 of %2", i, _intrinsic_duration));
for (list<pair<NoteType, string> >::const_iterator i = notes.begin(); i != notes.end(); ++i) {
note (i->first, i->second);
}
diff --git a/src/mxf.cc b/src/mxf.cc
index b6c11bb8..20cfbaed 100644
--- a/src/mxf.cc
+++ b/src/mxf.cc
@@ -80,7 +80,7 @@ MXF::fill_writer_info (ASDCP::WriterInfo* writer_info, string id) const
writer_info->ProductName = _metadata.product_name;
DCP_ASSERT (_standard);
- if (_standard == INTEROP) {
+ if (_standard == Standard::INTEROP) {
writer_info->LabelSetType = ASDCP::LS_MXF_INTEROP;
} else {
writer_info->LabelSetType = ASDCP::LS_MXF_SMPTE;
@@ -129,10 +129,10 @@ MXF::read_writer_info (ASDCP::WriterInfo const & info)
switch (info.LabelSetType) {
case ASDCP::LS_MXF_INTEROP:
- _standard = INTEROP;
+ _standard = Standard::INTEROP;
break;
case ASDCP::LS_MXF_SMPTE:
- _standard = SMPTE;
+ _standard = Standard::SMPTE;
break;
default:
throw ReadError ("Unrecognised label set type in MXF");
diff --git a/src/picture_asset.cc b/src/picture_asset.cc
index 86741ba6..6b5e9393 100644
--- a/src/picture_asset.cc
+++ b/src/picture_asset.cc
@@ -108,12 +108,12 @@ PictureAsset::descriptor_equals (
// a.QuantizationDefault != b.QuantizationDefault
) {
- note (DCP_ERROR, "video MXF picture descriptors differ");
+ note (NoteType::ERROR, "video MXF picture descriptors differ");
return false;
}
if (a.ContainerDuration != b.ContainerDuration) {
- note (DCP_ERROR, "video container durations differ");
+ note (NoteType::ERROR, "video container durations differ");
}
// for (unsigned int j = 0; j < ASDCP::JP2K::MaxComponents; ++j) {
@@ -132,7 +132,7 @@ PictureAsset::frame_buffer_equals (
) const
{
if (size_A == size_B && memcmp (data_A, data_B, size_A) == 0) {
- note (DCP_NOTE, "J2K identical");
+ note (NoteType::NOTE, "J2K identical");
/* Easy result; the J2K data is identical */
return true;
}
@@ -150,7 +150,7 @@ PictureAsset::frame_buffer_equals (
for (int c = 0; c < 3; ++c) {
if (image_A->size() != image_B->size()) {
- note (DCP_ERROR, String::compose ("image sizes for frame %1 differ", frame));
+ note (NoteType::ERROR, String::compose ("image sizes for frame %1 differ", frame));
return false;
}
@@ -176,11 +176,11 @@ PictureAsset::frame_buffer_equals (
double const std_dev = sqrt (double (total_squared_deviation) / abs_diffs.size());
- note (DCP_NOTE, String::compose ("mean difference %1 deviation %2", mean, std_dev));
+ note (NoteType::NOTE, String::compose("mean difference %1 deviation %2", mean, std_dev));
if (mean > opt.max_mean_pixel_error) {
note (
- DCP_ERROR,
+ NoteType::ERROR,
String::compose ("mean %1 out of range %2 in frame %3", mean, opt.max_mean_pixel_error, frame)
);
@@ -189,7 +189,7 @@ PictureAsset::frame_buffer_equals (
if (std_dev > opt.max_std_dev_pixel_error) {
note (
- DCP_ERROR,
+ NoteType::ERROR,
String::compose ("standard deviation %1 out of range %2 in frame %3", std_dev, opt.max_std_dev_pixel_error, frame)
);
@@ -203,9 +203,9 @@ string
PictureAsset::static_pkl_type (Standard standard)
{
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
return "application/x-smpte-mxf;asdcpKind=Picture";
- case SMPTE:
+ case Standard::SMPTE:
return "application/mxf";
default:
DCP_ASSERT (false);
diff --git a/src/pkl.cc b/src/pkl.cc
index 2a5b8b7d..b439e8bd 100644
--- a/src/pkl.cc
+++ b/src/pkl.cc
@@ -56,9 +56,9 @@ PKL::PKL (boost::filesystem::path file)
pkl.read_file (file);
if (pkl.namespace_uri() == pkl_interop_ns) {
- _standard = INTEROP;
+ _standard = Standard::INTEROP;
} else if (pkl.namespace_uri() == pkl_smpte_ns) {
- _standard = SMPTE;
+ _standard = Standard::SMPTE;
} else {
boost::throw_exception (XMLError ("Unrecognised packing list namesapce " + pkl.namespace_uri()));
}
@@ -85,7 +85,7 @@ PKL::write (boost::filesystem::path file, shared_ptr<const CertificateChain> sig
{
xmlpp::Document doc;
xmlpp::Element* pkl;
- if (_standard == INTEROP) {
+ if (_standard == Standard::INTEROP) {
pkl = doc.create_root_node("PackingList", pkl_interop_ns);
} else {
pkl = doc.create_root_node("PackingList", pkl_smpte_ns);
diff --git a/src/reel.cc b/src/reel.cc
index a05a7b36..efb161bb 100644
--- a/src/reel.cc
+++ b/src/reel.cc
@@ -160,7 +160,7 @@ bool
Reel::equals (std::shared_ptr<const Reel> other, EqualityOptions opt, NoteHandler note) const
{
if ((_main_picture && !other->_main_picture) || (!_main_picture && other->_main_picture)) {
- note (DCP_ERROR, "Reel: picture assets differ");
+ note (NoteType::ERROR, "Reel: picture assets differ");
return false;
}
@@ -169,7 +169,7 @@ Reel::equals (std::shared_ptr<const Reel> other, EqualityOptions opt, NoteHandle
}
if ((_main_sound && !other->_main_sound) || (!_main_sound && other->_main_sound)) {
- note (DCP_ERROR, "Reel: sound assets differ");
+ note (NoteType::ERROR, "Reel: sound assets differ");
return false;
}
@@ -178,7 +178,7 @@ Reel::equals (std::shared_ptr<const Reel> other, EqualityOptions opt, NoteHandle
}
if ((_main_subtitle && !other->_main_subtitle) || (!_main_subtitle && other->_main_subtitle)) {
- note (DCP_ERROR, "Reel: subtitle assets differ");
+ note (NoteType::ERROR, "Reel: subtitle assets differ");
return false;
}
@@ -187,12 +187,12 @@ Reel::equals (std::shared_ptr<const Reel> other, EqualityOptions opt, NoteHandle
}
if ((_main_markers && !other->_main_markers) || (!_main_markers && other->_main_markers)) {
- note (DCP_ERROR, "Reel: one has markers and the other does not");
+ note (NoteType::ERROR, "Reel: one has markers and the other does not");
return false;
}
if (_main_markers && !_main_markers->equals(other->_main_markers, opt, note)) {
- note (DCP_ERROR, "Reel: marker assets differ");
+ note (NoteType::ERROR, "Reel: marker assets differ");
return false;
}
@@ -211,7 +211,7 @@ Reel::equals (std::shared_ptr<const Reel> other, EqualityOptions opt, NoteHandle
}
if ((_atmos && !other->_atmos) || (!_atmos && other->_atmos)) {
- note (DCP_ERROR, "Reel: atmos assets differ");
+ note (NoteType::ERROR, "Reel: atmos assets differ");
return false;
}
diff --git a/src/reel_asset.cc b/src/reel_asset.cc
index bb2cd5b7..4d26e4f4 100644
--- a/src/reel_asset.cc
+++ b/src/reel_asset.cc
@@ -123,30 +123,30 @@ ReelAsset::asset_equals (shared_ptr<const ReelAsset> other, EqualityOptions opt,
if (_annotation_text != other->_annotation_text) {
string const s = "Reel: annotation texts differ (" + _annotation_text + " vs " + other->_annotation_text + ")\n";
if (!opt.reel_annotation_texts_can_differ) {
- note (DCP_ERROR, s);
+ note (NoteType::ERROR, s);
return false;
} else {
- note (DCP_NOTE, s);
+ note (NoteType::NOTE, s);
}
}
if (_edit_rate != other->_edit_rate) {
- note (DCP_ERROR, "Reel: edit rates differ");
+ note (NoteType::ERROR, "Reel: edit rates differ");
return false;
}
if (_intrinsic_duration != other->_intrinsic_duration) {
- note (DCP_ERROR, String::compose ("Reel: intrinsic durations differ (%1 vs %2)", _intrinsic_duration, other->_intrinsic_duration));
+ note (NoteType::ERROR, String::compose ("Reel: intrinsic durations differ (%1 vs %2)", _intrinsic_duration, other->_intrinsic_duration));
return false;
}
if (_entry_point != other->_entry_point) {
- note (DCP_ERROR, "Reel: entry points differ");
+ note (NoteType::ERROR, "Reel: entry points differ");
return false;
}
if (_duration != other->_duration) {
- note (DCP_ERROR, "Reel: durations differ");
+ note (NoteType::ERROR, "Reel: durations differ");
return false;
}
diff --git a/src/reel_closed_caption_asset.cc b/src/reel_closed_caption_asset.cc
index 45e83933..2aa13ead 100644
--- a/src/reel_closed_caption_asset.cc
+++ b/src/reel_closed_caption_asset.cc
@@ -68,9 +68,9 @@ string
ReelClosedCaptionAsset::cpl_node_name (Standard standard) const
{
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
return "cc-cpl:MainClosedCaption";
- case SMPTE:
+ case Standard::SMPTE:
return "tt:ClosedCaption";
}
@@ -81,9 +81,9 @@ pair<string, string>
ReelClosedCaptionAsset::cpl_node_namespace (Standard standard) const
{
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
return make_pair ("http://www.digicine.com/PROTO-ASDCP-CC-CPL-20070926#", "cc-cpl");
- case SMPTE:
+ case Standard::SMPTE:
return make_pair ("http://www.smpte-ra.org/schemas/429-12/2008/TT", "tt");
}
diff --git a/src/reel_mxf.cc b/src/reel_mxf.cc
index 71b47836..24442691 100644
--- a/src/reel_mxf.cc
+++ b/src/reel_mxf.cc
@@ -66,10 +66,10 @@ ReelMXF::mxf_equals (shared_ptr<const ReelMXF> other, EqualityOptions opt, NoteH
{
if (_hash != other->_hash) {
if (!opt.reel_hashes_can_differ) {
- note (DCP_ERROR, "Reel: hashes differ");
+ note (NoteType::ERROR, "Reel: hashes differ");
return false;
} else {
- note (DCP_NOTE, "Reel: hashes differ");
+ note (NoteType::NOTE, "Reel: hashes differ");
}
}
diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc
index 6e6cd035..2b3c3db0 100644
--- a/src/reel_picture_asset.cc
+++ b/src/reel_picture_asset.cc
@@ -85,7 +85,7 @@ ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
xmlpp::Node* asset = write_to_cpl_asset (node, standard, hash());
asset->add_child("FrameRate")->add_child_text(String::compose("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
- if (standard == INTEROP) {
+ if (standard == Standard::INTEROP) {
/* Allowed values for this tag from the standard */
float allowed[] = { 1.33, 1.66, 1.77, 1.85, 2.00, 2.39 };
@@ -139,12 +139,12 @@ ReelPictureAsset::equals (shared_ptr<const ReelPictureAsset> other, EqualityOpti
}
if (_frame_rate != rpa->_frame_rate) {
- note (DCP_ERROR, "frame rates differ in reel");
+ note (NoteType::ERROR, "frame rates differ in reel");
return false;
}
if (_screen_aspect_ratio != rpa->_screen_aspect_ratio) {
- note (DCP_ERROR, "screen aspect ratios differ in reel");
+ note (NoteType::ERROR, "screen aspect ratios differ in reel");
return false;
}
diff --git a/src/reel_stereo_picture_asset.cc b/src/reel_stereo_picture_asset.cc
index 06c57c66..958f8393 100644
--- a/src/reel_stereo_picture_asset.cc
+++ b/src/reel_stereo_picture_asset.cc
@@ -67,9 +67,9 @@ pair<string, string>
ReelStereoPictureAsset::cpl_node_attribute (Standard standard) const
{
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
return make_pair ("xmlns:msp-cpl", "http://www.digicine.com/schemas/437-Y/2007/Main-Stereo-Picture-CPL");
- case SMPTE:
+ case Standard::SMPTE:
return make_pair ("xmlns:msp-cpl", "http://www.smpte-ra.org/schemas/429-10/2008/Main-Stereo-Picture-CPL");
}
diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc
index d7c9ae6f..4b3a5620 100644
--- a/src/rgb_xyz.cc
+++ b/src/rgb_xyz.cc
@@ -193,21 +193,21 @@ dcp::xyz_to_rgb (
if (cx < 0 || cx > 4095) {
if (note) {
- note.get() (DCP_NOTE, String::compose ("XYZ value %1 out of range", cx));
+ note.get()(NoteType::NOTE, String::compose("XYZ value %1 out of range", cx));
}
cx = max (min (cx, 4095), 0);
}
if (cy < 0 || cy > 4095) {
if (note) {
- note.get() (DCP_NOTE, String::compose ("XYZ value %1 out of range", cy));
+ note.get()(NoteType::NOTE, String::compose("XYZ value %1 out of range", cy));
}
cy = max (min (cy, 4095), 0);
}
if (cz < 0 || cz > 4095) {
if (note) {
- note.get() (DCP_NOTE, String::compose ("XYZ value %1 out of range", cz));
+ note.get()(NoteType::NOTE, String::compose("XYZ value %1 out of range", cz));
}
cz = max (min (cz, 4095), 0);
}
@@ -343,7 +343,7 @@ dcp::rgb_to_xyz (
}
if (clamped && note) {
- note.get() (DCP_NOTE, String::compose ("%1 XYZ value(s) clamped", clamped));
+ note.get()(NoteType::NOTE, String::compose("%1 XYZ value(s) clamped", clamped));
}
return xyz;
diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc
index 7604fd39..49ccc5a9 100644
--- a/src/smpte_subtitle_asset.cc
+++ b/src/smpte_subtitle_asset.cc
@@ -57,10 +57,11 @@ using std::list;
using std::vector;
using std::map;
using std::shared_ptr;
+using std::dynamic_pointer_cast;
+using std::make_shared;
using boost::split;
using boost::is_any_of;
using boost::shared_array;
-using std::dynamic_pointer_cast;
using boost::optional;
using boost::starts_with;
using namespace dcp;
@@ -68,7 +69,7 @@ using namespace dcp;
static string const subtitle_smpte_ns = "http://www.smpte-ra.org/schemas/428-7/2010/DCST";
SMPTESubtitleAsset::SMPTESubtitleAsset ()
- : MXF (SMPTE)
+ : MXF (Standard::SMPTE)
, _intrinsic_duration (0)
, _edit_rate (24, 1)
, _time_code_rate (24)
@@ -101,7 +102,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
reader->ReadTimedTextResource (_raw_xml);
xml->read_string (_raw_xml);
parse_xml (xml);
- read_mxf_descriptor (reader, shared_ptr<DecryptionContext> (new DecryptionContext (optional<Key>(), SMPTE)));
+ read_mxf_descriptor (reader, shared_ptr<DecryptionContext> (new DecryptionContext (optional<Key>(), Standard::SMPTE)));
}
} else {
/* Plain XML */
@@ -140,7 +141,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
}
}
}
- _standard = dcp::SMPTE;
+ _standard = Standard::SMPTE;
}
/* Check that all required image data have been found */
@@ -188,7 +189,7 @@ SMPTESubtitleAsset::parse_xml (shared_ptr<cxml::Document> xml)
for (xmlpp::Node::NodeList::const_iterator i = c.begin(); i != c.end(); ++i) {
xmlpp::Element const * e = dynamic_cast<xmlpp::Element const *> (*i);
if (e && e->get_name() == "SubtitleList") {
- parse_subtitles (e, ps, _time_code_rate, SMPTE);
+ parse_subtitles (e, ps, _time_code_rate, Standard::SMPTE);
}
}
@@ -283,7 +284,7 @@ SMPTESubtitleAsset::set_key (Key key)
);
}
- shared_ptr<DecryptionContext> dec (new DecryptionContext (key, SMPTE));
+ auto dec = make_shared<DecryptionContext>(key, Standard::SMPTE);
reader->ReadTimedTextResource (_raw_xml, dec->context(), dec->hmac());
shared_ptr<cxml::Document> xml (new cxml::Document ("SubtitleReel"));
xml->read_string (_raw_xml);
@@ -332,7 +333,7 @@ SMPTESubtitleAsset::xml_as_string () const
root->add_child("EditRate", "dcst")->add_child_text (_edit_rate.as_string ());
root->add_child("TimeCodeRate", "dcst")->add_child_text (raw_convert<string> (_time_code_rate));
if (_start_time) {
- root->add_child("StartTime", "dcst")->add_child_text (_start_time.get().as_string (SMPTE));
+ root->add_child("StartTime", "dcst")->add_child_text(_start_time.get().as_string(Standard::SMPTE));
}
BOOST_FOREACH (shared_ptr<SMPTELoadFontNode> i, _load_font_nodes) {
@@ -341,7 +342,7 @@ SMPTESubtitleAsset::xml_as_string () const
load_font->set_attribute ("ID", i->id);
}
- subtitles_as_xml (root->add_child ("SubtitleList", "dcst"), _time_code_rate, SMPTE);
+ subtitles_as_xml (root->add_child("SubtitleList", "dcst"), _time_code_rate, Standard::SMPTE);
return doc.write_to_string ("UTF-8");
}
@@ -350,7 +351,7 @@ SMPTESubtitleAsset::xml_as_string () const
void
SMPTESubtitleAsset::write (boost::filesystem::path p) const
{
- EncryptionContext enc (key(), SMPTE);
+ EncryptionContext enc (key(), Standard::SMPTE);
ASDCP::WriterInfo writer_info;
fill_writer_info (&writer_info, _id);
@@ -458,7 +459,7 @@ SMPTESubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptions
shared_ptr<const SMPTESubtitleAsset> other = dynamic_pointer_cast<const SMPTESubtitleAsset> (other_asset);
if (!other) {
- note (DCP_ERROR, "Subtitles are in different standards");
+ note (NoteType::ERROR, "Subtitles are in different standards");
return false;
}
@@ -467,12 +468,12 @@ SMPTESubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptions
while (i != _load_font_nodes.end ()) {
if (j == other->_load_font_nodes.end ()) {
- note (DCP_ERROR, "<LoadFont> nodes differ");
+ note (NoteType::ERROR, "<LoadFont> nodes differ");
return false;
}
if ((*i)->id != (*j)->id) {
- note (DCP_ERROR, "<LoadFont> nodes differ");
+ note (NoteType::ERROR, "<LoadFont> nodes differ");
return false;
}
@@ -481,46 +482,46 @@ SMPTESubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptions
}
if (_content_title_text != other->_content_title_text) {
- note (DCP_ERROR, "Subtitle content title texts differ");
+ note (NoteType::ERROR, "Subtitle content title texts differ");
return false;
}
if (_language != other->_language) {
- note (DCP_ERROR, String::compose("Subtitle languages differ (`%1' vs `%2')", _language.get_value_or("[none]"), other->_language.get_value_or("[none]")));
+ note (NoteType::ERROR, String::compose("Subtitle languages differ (`%1' vs `%2')", _language.get_value_or("[none]"), other->_language.get_value_or("[none]")));
return false;
}
if (_annotation_text != other->_annotation_text) {
- note (DCP_ERROR, "Subtitle annotation texts differ");
+ note (NoteType::ERROR, "Subtitle annotation texts differ");
return false;
}
if (_issue_date != other->_issue_date) {
if (options.issue_dates_can_differ) {
- note (DCP_NOTE, "Subtitle issue dates differ");
+ note (NoteType::NOTE, "Subtitle issue dates differ");
} else {
- note (DCP_ERROR, "Subtitle issue dates differ");
+ note (NoteType::ERROR, "Subtitle issue dates differ");
return false;
}
}
if (_reel_number != other->_reel_number) {
- note (DCP_ERROR, "Subtitle reel numbers differ");
+ note (NoteType::ERROR, "Subtitle reel numbers differ");
return false;
}
if (_edit_rate != other->_edit_rate) {
- note (DCP_ERROR, "Subtitle edit rates differ");
+ note (NoteType::ERROR, "Subtitle edit rates differ");
return false;
}
if (_time_code_rate != other->_time_code_rate) {
- note (DCP_ERROR, "Subtitle time code rates differ");
+ note (NoteType::ERROR, "Subtitle time code rates differ");
return false;
}
if (_start_time != other->_start_time) {
- note (DCP_ERROR, "Subtitle start times differ");
+ note (NoteType::ERROR, "Subtitle start times differ");
return false;
}
diff --git a/src/sound_asset.cc b/src/sound_asset.cc
index ea44e806..9d42e76d 100644
--- a/src/sound_asset.cc
+++ b/src/sound_asset.cc
@@ -143,7 +143,7 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHand
if (desc_A.EditRate != desc_B.EditRate) {
note (
- DCP_ERROR,
+ NoteType::ERROR,
String::compose (
"audio edit rates differ: %1/%2 cf %3/%4",
desc_A.EditRate.Numerator, desc_A.EditRate.Denominator, desc_B.EditRate.Numerator, desc_B.EditRate.Denominator
@@ -152,7 +152,7 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHand
return false;
} else if (desc_A.AudioSamplingRate != desc_B.AudioSamplingRate) {
note (
- DCP_ERROR,
+ NoteType::ERROR,
String::compose (
"audio sampling rates differ: %1 cf %2",
desc_A.AudioSamplingRate.Numerator, desc_A.AudioSamplingRate.Denominator,
@@ -161,25 +161,25 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHand
);
return false;
} else if (desc_A.Locked != desc_B.Locked) {
- note (DCP_ERROR, String::compose ("audio locked flags differ: %1 cf %2", desc_A.Locked, desc_B.Locked));
+ note (NoteType::ERROR, String::compose ("audio locked flags differ: %1 cf %2", desc_A.Locked, desc_B.Locked));
return false;
} else if (desc_A.ChannelCount != desc_B.ChannelCount) {
- note (DCP_ERROR, String::compose ("audio channel counts differ: %1 cf %2", desc_A.ChannelCount, desc_B.ChannelCount));
+ note (NoteType::ERROR, String::compose ("audio channel counts differ: %1 cf %2", desc_A.ChannelCount, desc_B.ChannelCount));
return false;
} else if (desc_A.QuantizationBits != desc_B.QuantizationBits) {
- note (DCP_ERROR, String::compose ("audio bits per sample differ: %1 cf %2", desc_A.QuantizationBits, desc_B.QuantizationBits));
+ note (NoteType::ERROR, String::compose ("audio bits per sample differ: %1 cf %2", desc_A.QuantizationBits, desc_B.QuantizationBits));
return false;
} else if (desc_A.BlockAlign != desc_B.BlockAlign) {
- note (DCP_ERROR, String::compose ("audio bytes per sample differ: %1 cf %2", desc_A.BlockAlign, desc_B.BlockAlign));
+ note (NoteType::ERROR, String::compose ("audio bytes per sample differ: %1 cf %2", desc_A.BlockAlign, desc_B.BlockAlign));
return false;
} else if (desc_A.AvgBps != desc_B.AvgBps) {
- note (DCP_ERROR, String::compose ("audio average bps differ: %1 cf %2", desc_A.AvgBps, desc_B.AvgBps));
+ note (NoteType::ERROR, String::compose ("audio average bps differ: %1 cf %2", desc_A.AvgBps, desc_B.AvgBps));
return false;
} else if (desc_A.LinkedTrackID != desc_B.LinkedTrackID) {
- note (DCP_ERROR, String::compose ("audio linked track IDs differ: %1 cf %2", desc_A.LinkedTrackID, desc_B.LinkedTrackID));
+ note (NoteType::ERROR, String::compose ("audio linked track IDs differ: %1 cf %2", desc_A.LinkedTrackID, desc_B.LinkedTrackID));
return false;
} else if (desc_A.ContainerDuration != desc_B.ContainerDuration) {
- note (DCP_ERROR, String::compose ("audio container durations differ: %1 cf %2", desc_A.ContainerDuration, desc_B.ContainerDuration));
+ note (NoteType::ERROR, String::compose ("audio container durations differ: %1 cf %2", desc_A.ContainerDuration, desc_B.ContainerDuration));
return false;
} else if (desc_A.ChannelFormat != desc_B.ChannelFormat) {
/* XXX */
@@ -196,7 +196,7 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHand
shared_ptr<const SoundFrame> frame_B = other_reader->get_frame (i);
if (frame_A->size() != frame_B->size()) {
- note (DCP_ERROR, String::compose ("sizes of audio data for frame %1 differ", i));
+ note (NoteType::ERROR, String::compose ("sizes of audio data for frame %1 differ", i));
return false;
}
@@ -205,7 +205,7 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHand
for (int channel = 0; channel < frame_A->channels(); ++channel) {
int32_t const d = abs(frame_A->get(channel, sample) - frame_B->get(channel, sample));
if (d > opt.max_audio_sample_error) {
- note (DCP_ERROR, String::compose ("PCM data difference of %1", d));
+ note (NoteType::ERROR, String::compose ("PCM data difference of %1", d));
return false;
}
}
@@ -236,9 +236,9 @@ string
SoundAsset::static_pkl_type (Standard standard)
{
switch (standard) {
- case INTEROP:
+ case Standard::INTEROP:
return "application/x-smpte-mxf;asdcpKind=Sound";
- case SMPTE:
+ case Standard::SMPTE:
return "application/mxf";
default:
DCP_ASSERT (false);
diff --git a/src/sound_asset_writer.cc b/src/sound_asset_writer.cc
index 092acf0c..87de1b18 100644
--- a/src/sound_asset_writer.cc
+++ b/src/sound_asset_writer.cc
@@ -69,7 +69,7 @@ SoundAssetWriter::SoundAssetWriter (SoundAsset* asset, boost::filesystem::path f
, _active_channels (active_channels)
{
DCP_ASSERT (!_sync || _asset->channels() >= 14);
- DCP_ASSERT (!_sync || _asset->standard() == SMPTE);
+ DCP_ASSERT (!_sync || _asset->standard() == Standard::SMPTE);
/* Derived from ASDCP::Wav::SimpleWaveHeader::FillADesc */
_state->desc.EditRate = ASDCP::Rational (_asset->edit_rate().numerator, _asset->edit_rate().denominator);
@@ -80,7 +80,7 @@ SoundAssetWriter::SoundAssetWriter (SoundAsset* asset, boost::filesystem::path f
_state->desc.BlockAlign = 3 * _asset->channels();
_state->desc.AvgBps = _asset->sampling_rate() * _state->desc.BlockAlign;
_state->desc.LinkedTrackID = 0;
- if (asset->standard() == INTEROP) {
+ if (asset->standard() == Standard::INTEROP) {
_state->desc.ChannelFormat = ASDCP::PCM::CF_NONE;
} else {
/* Just use WTF ("wild track format") for SMPTE for now; searches suggest that this
@@ -114,7 +114,7 @@ SoundAssetWriter::start ()
boost::throw_exception (FileError ("could not open audio MXF for writing", _file.string(), r));
}
- if (_asset->standard() == dcp::SMPTE && !_active_channels.empty()) {
+ if (_asset->standard() == Standard::SMPTE && !_active_channels.empty()) {
ASDCP::MXF::WaveAudioDescriptor* essence_descriptor = 0;
_state->mxf_writer.OP1aHeader().GetMDObjectByType(
@@ -127,9 +127,9 @@ SoundAssetWriter::start ()
GenRandomValue (soundfield->MCALinkID);
soundfield->RFC5646SpokenLanguage = _asset->language();
- const MCASoundField field = _asset->channels() > 10 ? SEVEN_POINT_ONE : FIVE_POINT_ONE;
+ const MCASoundField field = _asset->channels() > 10 ? MCASoundField::SEVEN_POINT_ONE : MCASoundField::FIVE_POINT_ONE;
- if (field == SEVEN_POINT_ONE) {
+ if (field == MCASoundField::SEVEN_POINT_ONE) {
soundfield->MCATagSymbol = "sg71";
soundfield->MCATagName = "7.1DS";
soundfield->MCALabelDictionaryID = asdcp_smpte_dict->ul(ASDCP::MDD_DCAudioSoundfield_71);
diff --git a/src/stereo_picture_asset.cc b/src/stereo_picture_asset.cc
index 0dfba553..231af538 100644
--- a/src/stereo_picture_asset.cc
+++ b/src/stereo_picture_asset.cc
@@ -136,7 +136,7 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt,
/* If there was a problem reading the frame data we'll just assume
the two frames are not equal.
*/
- note (DCP_ERROR, e.what ());
+ note (NoteType::ERROR, e.what ());
return false;
}
diff --git a/src/stereo_picture_asset_writer.cc b/src/stereo_picture_asset_writer.cc
index 124d0185..6245873d 100644
--- a/src/stereo_picture_asset_writer.cc
+++ b/src/stereo_picture_asset_writer.cc
@@ -53,7 +53,7 @@ struct StereoPictureAssetWriter::ASDCPState : public ASDCPStateBase
StereoPictureAssetWriter::StereoPictureAssetWriter (PictureAsset* mxf, boost::filesystem::path file, bool overwrite)
: PictureAssetWriter (mxf, file, overwrite)
, _state (new StereoPictureAssetWriter::ASDCPState)
- , _next_eye (EYE_LEFT)
+ , _next_eye (Eye::LEFT)
{
}
@@ -87,7 +87,7 @@ StereoPictureAssetWriter::write (uint8_t const * data, int size)
string hash;
Kumu::Result_t r = _state->mxf_writer.WriteFrame (
_state->frame_buffer,
- _next_eye == EYE_LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT,
+ _next_eye == Eye::LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT,
_crypto_context->context(),
_crypto_context->hmac(),
&hash
@@ -97,9 +97,9 @@ StereoPictureAssetWriter::write (uint8_t const * data, int size)
boost::throw_exception (MXFFileError ("error in writing video MXF", _file.string(), r));
}
- _next_eye = _next_eye == EYE_LEFT ? EYE_RIGHT : EYE_LEFT;
+ _next_eye = _next_eye == Eye::LEFT ? Eye::RIGHT : Eye::LEFT;
- if (_next_eye == EYE_LEFT) {
+ if (_next_eye == Eye::LEFT) {
++_frames_written;
}
@@ -112,13 +112,13 @@ StereoPictureAssetWriter::fake_write (int size)
DCP_ASSERT (_started);
DCP_ASSERT (!_finalized);
- Kumu::Result_t r = _state->mxf_writer.FakeWriteFrame (size, _next_eye == EYE_LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT);
+ Kumu::Result_t r = _state->mxf_writer.FakeWriteFrame (size, _next_eye == Eye::LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT);
if (ASDCP_FAILURE (r)) {
boost::throw_exception (MXFFileError ("error in writing video MXF", _file.string(), r));
}
- _next_eye = _next_eye == EYE_LEFT ? EYE_RIGHT : EYE_LEFT;
- if (_next_eye == EYE_LEFT) {
+ _next_eye = _next_eye == Eye::LEFT ? Eye::RIGHT : Eye::LEFT;
+ if (_next_eye == Eye::LEFT) {
++_frames_written;
}
}
diff --git a/src/stereo_picture_frame.cc b/src/stereo_picture_frame.cc
index 36c26602..8508dc3e 100644
--- a/src/stereo_picture_frame.cc
+++ b/src/stereo_picture_frame.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -44,6 +44,7 @@
using std::string;
using std::shared_ptr;
+using std::make_shared;
using namespace dcp;
@@ -58,7 +59,7 @@ StereoPictureFrame::Part::Part (shared_ptr<ASDCP::JP2K::SFrameBuffer> buffer, Ey
ASDCP::JP2K::FrameBuffer &
StereoPictureFrame::Part::mono () const
{
- return _eye == EYE_LEFT ? _buffer->Left : _buffer->Right;
+ return _eye == Eye::LEFT ? _buffer->Left : _buffer->Right;
}
@@ -112,9 +113,9 @@ shared_ptr<OpenJPEGImage>
StereoPictureFrame::xyz_image (Eye eye, int reduce) const
{
switch (eye) {
- case EYE_LEFT:
+ case Eye::LEFT:
return decompress_j2k (const_cast<uint8_t*> (_buffer->Left.RoData()), _buffer->Left.Size(), reduce);
- case EYE_RIGHT:
+ case Eye::RIGHT:
return decompress_j2k (const_cast<uint8_t*> (_buffer->Right.RoData()), _buffer->Right.Size(), reduce);
}
@@ -125,14 +126,14 @@ StereoPictureFrame::xyz_image (Eye eye, int reduce) const
shared_ptr<StereoPictureFrame::Part>
StereoPictureFrame::right () const
{
- return shared_ptr<Part>(new Part(_buffer, EYE_RIGHT));
+ return make_shared<Part>(_buffer, Eye::RIGHT);
}
shared_ptr<StereoPictureFrame::Part>
StereoPictureFrame::left () const
{
- return shared_ptr<Part>(new Part(_buffer, EYE_LEFT));
+ return make_shared<Part>(_buffer, Eye::LEFT);
}
diff --git a/src/stereo_picture_frame.h b/src/stereo_picture_frame.h
index 13c02232..3d334d34 100644
--- a/src/stereo_picture_frame.h
+++ b/src/stereo_picture_frame.h
@@ -68,6 +68,8 @@ public:
class Part : public Data
{
public:
+ Part (std::shared_ptr<ASDCP::JP2K::SFrameBuffer> buffer, Eye eye);
+
uint8_t const * data () const;
uint8_t * data ();
int size () const;
@@ -75,7 +77,6 @@ public:
private:
friend class StereoPictureFrame;
- Part (std::shared_ptr<ASDCP::JP2K::SFrameBuffer> buffer, Eye eye);
ASDCP::JP2K::FrameBuffer& mono () const;
std::shared_ptr<ASDCP::JP2K::SFrameBuffer> _buffer;
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc
index fc9b972a..37b381ae 100644
--- a/src/subtitle_asset.cc
+++ b/src/subtitle_asset.cc
@@ -124,7 +124,7 @@ SubtitleAsset::font_node_state (xmlpp::Element const * node, Standard standard)
{
ParseState ps;
- if (standard == INTEROP) {
+ if (standard == Standard::INTEROP) {
ps.font_id = optional_string_attribute (node, "Id");
} else {
ps.font_id = optional_string_attribute (node, "ID");
@@ -133,7 +133,7 @@ SubtitleAsset::font_node_state (xmlpp::Element const * node, Standard standard)
ps.aspect_adjust = optional_number_attribute<float> (node, "AspectAdjust");
ps.italic = optional_bool_attribute (node, "Italic");
ps.bold = optional_string_attribute(node, "Weight").get_value_or("normal") == "bold";
- if (standard == INTEROP) {
+ if (standard == Standard::INTEROP) {
ps.underline = optional_bool_attribute (node, "Underlined");
} else {
ps.underline = optional_bool_attribute (node, "Underline");
@@ -374,12 +374,12 @@ SubtitleAsset::maybe_add_subtitle (string text, vector<ParseState> const & parse
ps.in.get(),
ps.out.get(),
ps.h_position.get_value_or(0),
- ps.h_align.get_value_or(HALIGN_CENTER),
+ ps.h_align.get_value_or(HAlign::CENTER),
ps.v_position.get_value_or(0),
- ps.v_align.get_value_or(VALIGN_CENTER),
- ps.direction.get_value_or (DIRECTION_LTR),
+ ps.v_align.get_value_or(VAlign::CENTER),
+ ps.direction.get_value_or (Direction::LTR),
text,
- ps.effect.get_value_or (NONE),
+ ps.effect.get_value_or (Effect::NONE),
ps.effect_colour.get_value_or (dcp::Colour (0, 0, 0)),
ps.fade_up_time.get_value_or(Time()),
ps.fade_down_time.get_value_or(Time())
@@ -393,13 +393,13 @@ SubtitleAsset::maybe_add_subtitle (string text, vector<ParseState> const & parse
shared_ptr<Subtitle> (
new SubtitleImage (
ArrayData (),
- standard == INTEROP ? text.substr(0, text.size() - 4) : text,
+ standard == Standard::INTEROP ? text.substr(0, text.size() - 4) : text,
ps.in.get(),
ps.out.get(),
ps.h_position.get_value_or(0),
- ps.h_align.get_value_or(HALIGN_CENTER),
+ ps.h_align.get_value_or(HAlign::CENTER),
ps.v_position.get_value_or(0),
- ps.v_align.get_value_or(VALIGN_CENTER),
+ ps.v_align.get_value_or(VAlign::CENTER),
ps.fade_up_time.get_value_or(Time()),
ps.fade_down_time.get_value_or(Time())
)
@@ -487,7 +487,7 @@ SubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptions opti
}
if (_subtitles.size() != other->_subtitles.size()) {
- note (DCP_ERROR, String::compose("different number of subtitles: %1 vs %2", _subtitles.size(), other->_subtitles.size()));
+ note (NoteType::ERROR, String::compose("different number of subtitles: %1 vs %2", _subtitles.size(), other->_subtitles.size()));
return false;
}
@@ -501,12 +501,12 @@ SubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptions opti
shared_ptr<SubtitleImage> image_j = dynamic_pointer_cast<SubtitleImage> (*j);
if ((string_i && !string_j) || (image_i && !image_j)) {
- note (DCP_ERROR, "subtitles differ: string vs. image");
+ note (NoteType::ERROR, "subtitles differ: string vs. image");
return false;
}
if (string_i && *string_i != *string_j) {
- note (DCP_ERROR, String::compose("subtitles differ in text or metadata: %1 vs %2", string_i->text(), string_j->text()));
+ note (NoteType::ERROR, String::compose("subtitles differ in text or metadata: %1 vs %2", string_i->text(), string_j->text()));
return false;
}
diff --git a/src/subtitle_asset_internal.cc b/src/subtitle_asset_internal.cc
index ae5893de..25a41944 100644
--- a/src/subtitle_asset_internal.cc
+++ b/src/subtitle_asset_internal.cc
@@ -44,13 +44,13 @@ using namespace dcp;
string
order::Context::xmlns () const
{
- return standard == SMPTE ? "dcst" : "";
+ return standard == Standard::SMPTE ? "dcst" : "";
}
order::Font::Font (shared_ptr<SubtitleString> s, Standard standard)
{
if (s->font()) {
- if (standard == SMPTE) {
+ if (standard == Standard::SMPTE) {
_values["ID"] = s->font().get ();
} else {
_values["Id"] = s->font().get ();
@@ -63,7 +63,7 @@ order::Font::Font (shared_ptr<SubtitleString> s, Standard standard)
_values["Effect"] = effect_to_string (s->effect());
_values["EffectColor"] = s->effect_colour().to_argb_string();
_values["Script"] = "normal";
- if (standard == SMPTE) {
+ if (standard == Standard::SMPTE) {
_values["Underline"] = s->underline() ? "yes" : "no";
} else {
_values["Underlined"] = s->underline() ? "yes" : "no";
@@ -149,8 +149,8 @@ order::Part::write_xml (xmlpp::Element* parent, order::Context& context) const
static void
position_align (xmlpp::Element* e, order::Context& context, HAlign h_align, float h_position, VAlign v_align, float v_position)
{
- if (h_align != HALIGN_CENTER) {
- if (context.standard == SMPTE) {
+ if (h_align != HAlign::CENTER) {
+ if (context.standard == Standard::SMPTE) {
e->set_attribute ("Halign", halign_to_string (h_align));
} else {
e->set_attribute ("HAlign", halign_to_string (h_align));
@@ -158,27 +158,27 @@ position_align (xmlpp::Element* e, order::Context& context, HAlign h_align, floa
}
if (fabs(h_position) > ALIGN_EPSILON) {
- if (context.standard == SMPTE) {
+ if (context.standard == Standard::SMPTE) {
e->set_attribute ("Hposition", raw_convert<string> (h_position * 100, 6));
} else {
e->set_attribute ("HPosition", raw_convert<string> (h_position * 100, 6));
}
}
- if (context.standard == SMPTE) {
+ if (context.standard == Standard::SMPTE) {
e->set_attribute ("Valign", valign_to_string (v_align));
} else {
e->set_attribute ("VAlign", valign_to_string (v_align));
}
if (fabs(v_position) > ALIGN_EPSILON) {
- if (context.standard == SMPTE) {
+ if (context.standard == Standard::SMPTE) {
e->set_attribute ("Vposition", raw_convert<string> (v_position * 100, 6));
} else {
e->set_attribute ("VPosition", raw_convert<string> (v_position * 100, 6));
}
} else {
- if (context.standard == SMPTE) {
+ if (context.standard == Standard::SMPTE) {
e->set_attribute ("Vposition", "0");
} else {
e->set_attribute ("VPosition", "0");
@@ -196,7 +196,7 @@ order::Text::as_xml (xmlpp::Element* parent, Context& context) const
/* Interop only supports "horizontal" or "vertical" for direction, so only write this
for SMPTE.
*/
- if (_direction != DIRECTION_LTR && context.standard == SMPTE) {
+ if (_direction != Direction::LTR && context.standard == Standard::SMPTE) {
e->set_attribute ("Direction", direction_to_string (_direction));
}
@@ -210,7 +210,7 @@ order::Subtitle::as_xml (xmlpp::Element* parent, Context& context) const
e->set_attribute ("SpotNumber", raw_convert<string> (context.spot_number++));
e->set_attribute ("TimeIn", _in.rebase(context.time_code_rate).as_string(context.standard));
e->set_attribute ("TimeOut", _out.rebase(context.time_code_rate).as_string(context.standard));
- if (context.standard == SMPTE) {
+ if (context.standard == Standard::SMPTE) {
e->set_attribute ("FadeUpTime", _fade_up.rebase(context.time_code_rate).as_string(context.standard));
e->set_attribute ("FadeDownTime", _fade_down.rebase(context.time_code_rate).as_string(context.standard));
} else {
@@ -238,7 +238,7 @@ order::Image::as_xml (xmlpp::Element* parent, Context& context) const
xmlpp::Element* e = parent->add_child ("Image", context.xmlns());
position_align (e, context, _h_align, _h_position, _v_align, _v_position);
- if (context.standard == SMPTE) {
+ if (context.standard == Standard::SMPTE) {
e->add_child_text (_id);
} else {
e->add_child_text (_id + ".png");
diff --git a/src/subtitle_image.cc b/src/subtitle_image.cc
index 99d63d27..7bfc4b86 100644
--- a/src/subtitle_image.cc
+++ b/src/subtitle_image.cc
@@ -117,16 +117,16 @@ bool
SubtitleImage::equals (shared_ptr<SubtitleImage> other, EqualityOptions options, NoteHandler note)
{
if (png_image() != other->png_image()) {
- note (DCP_ERROR, "subtitle image PNG data differs");
+ note (NoteType::ERROR, "subtitle image PNG data differs");
if (options.export_differing_subtitles) {
string const base = "dcpdiff_subtitle_";
if (boost::filesystem::exists(base + "A.png")) {
- note (DCP_ERROR, "could not export subtitle as " + base + "A.png already exists");
+ note (NoteType::ERROR, "could not export subtitle as " + base + "A.png already exists");
} else {
png_image().write(base + "A.png");
}
if (boost::filesystem::exists(base + "B.png")) {
- note (DCP_ERROR, "could not export subtitle as " + base + "B.png already exists");
+ note (NoteType::ERROR, "could not export subtitle as " + base + "B.png already exists");
} else {
other->png_image().write(base + "B.png");
}
@@ -136,42 +136,42 @@ SubtitleImage::equals (shared_ptr<SubtitleImage> other, EqualityOptions options,
}
if (in() != other->in()) {
- note (DCP_ERROR, "subtitle in times differ");
+ note (NoteType::ERROR, "subtitle in times differ");
return false;
}
if (out() != other->out()) {
- note (DCP_ERROR, "subtitle out times differ");
+ note (NoteType::ERROR, "subtitle out times differ");
return false;
}
if (h_position() != other->h_position()) {
- note (DCP_ERROR, "subtitle horizontal positions differ");
+ note (NoteType::ERROR, "subtitle horizontal positions differ");
return false;
}
if (h_align() != other->h_align()) {
- note (DCP_ERROR, "subtitle horizontal alignments differ");
+ note (NoteType::ERROR, "subtitle horizontal alignments differ");
return false;
}
if (v_position() != other->v_position()) {
- note (DCP_ERROR, "subtitle vertical positions differ");
+ note (NoteType::ERROR, "subtitle vertical positions differ");
return false;
}
if (v_align() != other->v_align()) {
- note (DCP_ERROR, "subtitle vertical alignments differ");
+ note (NoteType::ERROR, "subtitle vertical alignments differ");
return false;
}
if (fade_up_time() != other->fade_up_time()) {
- note (DCP_ERROR, "subtitle fade-up times differ");
+ note (NoteType::ERROR, "subtitle fade-up times differ");
return false;
}
if (fade_down_time() != other->fade_down_time()) {
- note (DCP_ERROR, "subtitle fade-down times differ");
+ note (NoteType::ERROR, "subtitle fade-down times differ");
return false;
}
diff --git a/src/types.cc b/src/types.cc
index 0ff65abd..9484939c 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -191,11 +191,11 @@ string
dcp::effect_to_string (Effect e)
{
switch (e) {
- case NONE:
+ case Effect::NONE:
return "none";
- case BORDER:
+ case Effect::BORDER:
return "border";
- case SHADOW:
+ case Effect::SHADOW:
return "shadow";
}
@@ -206,25 +206,34 @@ Effect
dcp::string_to_effect (string s)
{
if (s == "none") {
- return NONE;
+ return Effect::NONE;
} else if (s == "border") {
- return BORDER;
+ return Effect::BORDER;
} else if (s == "shadow") {
- return SHADOW;
+ return Effect::SHADOW;
}
boost::throw_exception (ReadError ("unknown subtitle effect type"));
}
+
+std::ostream&
+dcp::operator<< (std::ostream& s, Effect e)
+{
+ s << effect_to_string(e);
+ return s;
+}
+
+
string
dcp::halign_to_string (HAlign h)
{
switch (h) {
- case HALIGN_LEFT:
+ case HAlign::LEFT:
return "left";
- case HALIGN_CENTER:
+ case HAlign::CENTER:
return "center";
- case HALIGN_RIGHT:
+ case HAlign::RIGHT:
return "right";
}
@@ -235,11 +244,11 @@ HAlign
dcp::string_to_halign (string s)
{
if (s == "left") {
- return HALIGN_LEFT;
+ return HAlign::LEFT;
} else if (s == "center") {
- return HALIGN_CENTER;
+ return HAlign::CENTER;
} else if (s == "right") {
- return HALIGN_RIGHT;
+ return HAlign::RIGHT;
}
boost::throw_exception (ReadError ("unknown subtitle halign type"));
@@ -249,11 +258,11 @@ string
dcp::valign_to_string (VAlign v)
{
switch (v) {
- case VALIGN_TOP:
+ case VAlign::TOP:
return "top";
- case VALIGN_CENTER:
+ case VAlign::CENTER:
return "center";
- case VALIGN_BOTTOM:
+ case VAlign::BOTTOM:
return "bottom";
}
@@ -264,11 +273,11 @@ VAlign
dcp::string_to_valign (string s)
{
if (s == "top") {
- return VALIGN_TOP;
+ return VAlign::TOP;
} else if (s == "center") {
- return VALIGN_CENTER;
+ return VAlign::CENTER;
} else if (s == "bottom") {
- return VALIGN_BOTTOM;
+ return VAlign::BOTTOM;
}
boost::throw_exception (ReadError ("unknown subtitle valign type"));
@@ -278,13 +287,13 @@ string
dcp::direction_to_string (Direction v)
{
switch (v) {
- case DIRECTION_LTR:
+ case Direction::LTR:
return "ltr";
- case DIRECTION_RTL:
+ case Direction::RTL:
return "rtl";
- case DIRECTION_TTB:
+ case Direction::TTB:
return "ttb";
- case DIRECTION_BTT:
+ case Direction::BTT:
return "btt";
}
@@ -295,13 +304,13 @@ Direction
dcp::string_to_direction (string s)
{
if (s == "ltr" || s == "horizontal") {
- return DIRECTION_LTR;
+ return Direction::LTR;
} else if (s == "rtl") {
- return DIRECTION_RTL;
+ return Direction::RTL;
} else if (s == "ttb" || s == "vertical") {
- return DIRECTION_TTB;
+ return Direction::TTB;
} else if (s == "btt") {
- return DIRECTION_BTT;
+ return Direction::BTT;
}
boost::throw_exception (ReadError ("unknown subtitle direction type"));
@@ -316,29 +325,29 @@ string
dcp::content_kind_to_string (ContentKind kind)
{
switch (kind) {
- case FEATURE:
+ case ContentKind::FEATURE:
return "feature";
- case SHORT:
+ case ContentKind::SHORT:
return "short";
- case TRAILER:
+ case ContentKind::TRAILER:
return "trailer";
- case TEST:
+ case ContentKind::TEST:
return "test";
- case TRANSITIONAL:
+ case ContentKind::TRANSITIONAL:
return "transitional";
- case RATING:
+ case ContentKind::RATING:
return "rating";
- case TEASER:
+ case ContentKind::TEASER:
return "teaser";
- case POLICY:
+ case ContentKind::POLICY:
return "policy";
- case PUBLIC_SERVICE_ANNOUNCEMENT:
+ case ContentKind::PUBLIC_SERVICE_ANNOUNCEMENT:
return "psa";
- case ADVERTISEMENT:
+ case ContentKind::ADVERTISEMENT:
return "advertisement";
- case EPISODE:
+ case ContentKind::EPISODE:
return "episode";
- case PROMO:
+ case ContentKind::PROMO:
return "promo";
}
@@ -356,34 +365,43 @@ dcp::content_kind_from_string (string kind)
transform (kind.begin(), kind.end(), kind.begin(), ::tolower);
if (kind == "feature") {
- return FEATURE;
+ return ContentKind::FEATURE;
} else if (kind == "short") {
- return SHORT;
+ return ContentKind::SHORT;
} else if (kind == "trailer") {
- return TRAILER;
+ return ContentKind::TRAILER;
} else if (kind == "test") {
- return TEST;
+ return ContentKind::TEST;
} else if (kind == "transitional") {
- return TRANSITIONAL;
+ return ContentKind::TRANSITIONAL;
} else if (kind == "rating") {
- return RATING;
+ return ContentKind::RATING;
} else if (kind == "teaser") {
- return TEASER;
+ return ContentKind::TEASER;
} else if (kind == "policy") {
- return POLICY;
+ return ContentKind::POLICY;
} else if (kind == "psa") {
- return PUBLIC_SERVICE_ANNOUNCEMENT;
+ return ContentKind::PUBLIC_SERVICE_ANNOUNCEMENT;
} else if (kind == "advertisement") {
- return ADVERTISEMENT;
+ return ContentKind::ADVERTISEMENT;
} else if (kind == "episode") {
- return EPISODE;
+ return ContentKind::EPISODE;
} else if (kind == "promo") {
- return PROMO;
+ return ContentKind::PROMO;
}
throw BadContentKindError (kind);
}
+
+ostream&
+dcp::operator<< (ostream& s, ContentKind c)
+{
+ s << content_kind_to_string(c);
+ return s;
+}
+
+
string
dcp::marker_to_string (dcp::Marker m)
{
@@ -538,9 +556,9 @@ string
Luminance::unit_to_string (Unit u)
{
switch (u) {
- case CANDELA_PER_SQUARE_METRE:
+ case Unit::CANDELA_PER_SQUARE_METRE:
return "candela-per-square-metre";
- case FOOT_LAMBERT:
+ case Unit::FOOT_LAMBERT:
return "foot-lambert";
default:
DCP_ASSERT (false);
@@ -579,9 +597,9 @@ MainSoundConfiguration::MainSoundConfiguration (string s)
}
if (parts[0] == "51") {
- _field = FIVE_POINT_ONE;
+ _field = MCASoundField::FIVE_POINT_ONE;
} else if (parts[0] == "71") {
- _field = SEVEN_POINT_ONE;
+ _field = MCASoundField::SEVEN_POINT_ONE;
} else {
throw MainSoundConfigurationError (s);
}
@@ -614,13 +632,13 @@ string
MainSoundConfiguration::to_string () const
{
string c;
- if (_field == FIVE_POINT_ONE) {
+ if (_field == MCASoundField::FIVE_POINT_ONE) {
c = "51/";
} else {
c = "71/";
}
- BOOST_FOREACH (optional<Channel> i, _channels) {
+ for (auto i: _channels) {
if (!i) {
c += "-,";
} else {
@@ -656,11 +674,11 @@ string
dcp::status_to_string (Status s)
{
switch (s) {
- case FINAL:
+ case Status::FINAL:
return "final";
- case TEMP:
+ case Status::TEMP:
return "temp";
- case PRE:
+ case Status::PRE:
return "pre";
default:
DCP_ASSERT (false);
@@ -673,46 +691,105 @@ Status
dcp::string_to_status (string s)
{
if (s == "final") {
- return FINAL;
+ return Status::FINAL;
} else if (s == "temp") {
- return TEMP;
+ return Status::TEMP;
} else if (s == "pre") {
- return PRE;
+ return Status::PRE;
}
DCP_ASSERT (false);
}
+ostream&
+dcp::operator<<(ostream& s, Status t)
+{
+ s << status_to_string(t);
+ return s;
+}
+
+
+ostream&
+dcp::operator<<(ostream& s, dcp::Channel c)
+{
+ switch (c) {
+ case Channel::LEFT:
+ s << "left(0)";
+ break;
+ case Channel::RIGHT:
+ s << "right(1)";
+ break;
+ case Channel::CENTRE:
+ s << "centre(2)";
+ break;
+ case Channel::LFE:
+ s << "lfe(3)";
+ break;
+ case Channel::LS:
+ s << "ls(4)";
+ break;
+ case Channel::RS:
+ s << "rs(5)";
+ break;
+ case Channel::HI:
+ s << "hi(6)";
+ break;
+ case Channel::VI:
+ s << "vi(7)";
+ break;
+ case Channel::BSL:
+ s << "bsl(10)";
+ break;
+ case Channel::BSR:
+ s << "bsr(11)";
+ break;
+ case Channel::MOTION_DATA:
+ s << "motion_data(12)";
+ break;
+ case Channel::SYNC_SIGNAL:
+ s << "sync_signal(13)";
+ break;
+ case Channel::SIGN_LANGUAGE:
+ s << "sign_language(14)";
+ break;
+ case Channel::CHANNEL_COUNT:
+ s << "(16)";
+ break;
+ }
+ return s;
+}
+
+
Channel
dcp::mca_id_to_channel (string id)
{
if (id == "L") {
- return LEFT;
+ return Channel::LEFT;
} else if (id == "R") {
- return RIGHT;
+ return Channel::RIGHT;
} else if (id == "C") {
- return CENTRE;
+ return Channel::CENTRE;
} else if (id == "LFE") {
- return LFE;
+ return Channel::LFE;
} else if (id == "Ls" || id == "Lss") {
- return LS;
+ return Channel::LS;
} else if (id == "Rs" || id == "Rss") {
- return RS;
+ return Channel::RS;
} else if (id == "HI") {
- return HI;
+ return Channel::HI;
} else if (id == "VIN") {
- return VI;
+ return Channel::VI;
} else if (id == "Lrs") {
- return BSL;
+ return Channel::BSL;
} else if (id == "Rrs") {
- return BSR;
+ return Channel::BSR;
} else if (id == "DBOX") {
- return MOTION_DATA;
+ return Channel::MOTION_DATA;
} else if (id == "FSKSync") {
- return SYNC_SIGNAL;
+ return Channel::SYNC_SIGNAL;
} else if (id == "SLVS") {
- return SIGN_LANGUAGE;
+ return Channel::SIGN_LANGUAGE;
}
throw UnknownChannelIdError (id);
@@ -723,31 +800,31 @@ string
dcp::channel_to_mca_id (Channel c, MCASoundField field)
{
switch (c) {
- case LEFT:
+ case Channel::LEFT:
return "L";
- case RIGHT:
+ case Channel::RIGHT:
return "R";
- case CENTRE:
+ case Channel::CENTRE:
return "C";
- case LFE:
+ case Channel::LFE:
return "LFE";
- case LS:
- return field == FIVE_POINT_ONE ? "Ls" : "Lss";
- case RS:
- return field == FIVE_POINT_ONE ? "Rs" : "Rss";
- case HI:
+ case Channel::LS:
+ return field == MCASoundField::FIVE_POINT_ONE ? "Ls" : "Lss";
+ case Channel::RS:
+ return field == MCASoundField::FIVE_POINT_ONE ? "Rs" : "Rss";
+ case Channel::HI:
return "HI";
- case VI:
+ case Channel::VI:
return "VIN";
- case BSL:
+ case Channel::BSL:
return "Lrs";
- case BSR:
+ case Channel::BSR:
return "Rrs";
- case MOTION_DATA:
+ case Channel::MOTION_DATA:
return "DBOX";
- case SYNC_SIGNAL:
+ case Channel::SYNC_SIGNAL:
return "FSKSync";
- case SIGN_LANGUAGE:
+ case Channel::SIGN_LANGUAGE:
return "SLVS";
default:
break;
@@ -761,31 +838,31 @@ string
dcp::channel_to_mca_name (Channel c, MCASoundField field)
{
switch (c) {
- case LEFT:
+ case Channel::LEFT:
return "Left";
- case RIGHT:
+ case Channel::RIGHT:
return "Right";
- case CENTRE:
+ case Channel::CENTRE:
return "Center";
- case LFE:
+ case Channel::LFE:
return "LFE";
- case LS:
- return field == FIVE_POINT_ONE ? "Left Surround" : "Left Side Surround";
- case RS:
- return field == FIVE_POINT_ONE ? "Right Surround" : "Right Side Surround";
- case HI:
+ case Channel::LS:
+ return field == MCASoundField::FIVE_POINT_ONE ? "Left Surround" : "Left Side Surround";
+ case Channel::RS:
+ return field == MCASoundField::FIVE_POINT_ONE ? "Right Surround" : "Right Side Surround";
+ case Channel::HI:
return "Hearing Impaired";
- case VI:
+ case Channel::VI:
return "Visually Impaired-Narrative";
- case BSL:
+ case Channel::BSL:
return "Left Rear Surround";
- case BSR:
+ case Channel::BSR:
return "Right Rear Surround";
- case MOTION_DATA:
+ case Channel::MOTION_DATA:
return "D-BOX Motion Code Primary Stream";
- case SYNC_SIGNAL:
+ case Channel::SYNC_SIGNAL:
return "FSK Sync";
- case SIGN_LANGUAGE:
+ case Channel::SIGN_LANGUAGE:
return "Sign Language Video Stream";
default:
break;
@@ -807,31 +884,31 @@ dcp::channel_to_mca_universal_label (Channel c, MCASoundField field, ASDCP::Dict
};
switch (c) {
- case LEFT:
+ case Channel::LEFT:
return dict->ul(ASDCP::MDD_DCAudioChannel_L);
- case RIGHT:
+ case Channel::RIGHT:
return dict->ul(ASDCP::MDD_DCAudioChannel_R);
- case CENTRE:
+ case Channel::CENTRE:
return dict->ul(ASDCP::MDD_DCAudioChannel_C);
- case LFE:
+ case Channel::LFE:
return dict->ul(ASDCP::MDD_DCAudioChannel_LFE);
- case LS:
- return dict->ul(field == FIVE_POINT_ONE ? ASDCP::MDD_DCAudioChannel_Ls : ASDCP::MDD_DCAudioChannel_Lss);
- case RS:
- return dict->ul(field == FIVE_POINT_ONE ? ASDCP::MDD_DCAudioChannel_Rs : ASDCP::MDD_DCAudioChannel_Rss);
- case HI:
+ case Channel::LS:
+ return dict->ul(field == MCASoundField::FIVE_POINT_ONE ? ASDCP::MDD_DCAudioChannel_Ls : ASDCP::MDD_DCAudioChannel_Lss);
+ case Channel::RS:
+ return dict->ul(field == MCASoundField::FIVE_POINT_ONE ? ASDCP::MDD_DCAudioChannel_Rs : ASDCP::MDD_DCAudioChannel_Rss);
+ case Channel::HI:
return dict->ul(ASDCP::MDD_DCAudioChannel_HI);
- case VI:
+ case Channel::VI:
return dict->ul(ASDCP::MDD_DCAudioChannel_VIN);
- case BSL:
+ case Channel::BSL:
return dict->ul(ASDCP::MDD_DCAudioChannel_Lrs);
- case BSR:
+ case Channel::BSR:
return dict->ul(ASDCP::MDD_DCAudioChannel_Rrs);
- case MOTION_DATA:
+ case Channel::MOTION_DATA:
return dict->ul(ASDCP::MDD_DBOXMotionCodePrimaryStream);
- case SYNC_SIGNAL:
+ case Channel::SYNC_SIGNAL:
return ASDCP::UL(sync_signal);
- case SIGN_LANGUAGE:
+ case Channel::SIGN_LANGUAGE:
return ASDCP::UL(sign_language);
default:
break;
@@ -844,20 +921,67 @@ dcp::channel_to_mca_universal_label (Channel c, MCASoundField field, ASDCP::Dict
vector<dcp::Channel>
dcp::used_audio_channels ()
{
- vector<dcp::Channel> c;
- c.push_back (LEFT);
- c.push_back (RIGHT);
- c.push_back (CENTRE);
- c.push_back (LFE);
- c.push_back (LS);
- c.push_back (RS);
- c.push_back (HI);
- c.push_back (VI);
- c.push_back (BSL);
- c.push_back (BSR);
- c.push_back (MOTION_DATA);
- c.push_back (SYNC_SIGNAL);
- c.push_back (SIGN_LANGUAGE);
+ vector<Channel> c;
+ c.push_back (Channel::LEFT);
+ c.push_back (Channel::RIGHT);
+ c.push_back (Channel::CENTRE);
+ c.push_back (Channel::LFE);
+ c.push_back (Channel::LS);
+ c.push_back (Channel::RS);
+ c.push_back (Channel::HI);
+ c.push_back (Channel::VI);
+ c.push_back (Channel::BSL);
+ c.push_back (Channel::BSR);
+ c.push_back (Channel::MOTION_DATA);
+ c.push_back (Channel::SYNC_SIGNAL);
+ c.push_back (Channel::SIGN_LANGUAGE);
return c;
}
+
+ostream&
+dcp::operator<< (ostream& s, NoteType t)
+{
+ switch (t) {
+ case NoteType::PROGRESS:
+ s << "progress";
+ break;
+ case NoteType::ERROR:
+ s << "error";
+ break;
+ case NoteType::NOTE:
+ s << "note";
+ break;
+ }
+ return s;
+}
+
+
+ostream&
+dcp::operator<< (ostream& s, MCASoundField f)
+{
+ switch (f) {
+ case MCASoundField::FIVE_POINT_ONE:
+ s << "5.1";
+ break;
+ case MCASoundField::SEVEN_POINT_ONE:
+ s << "7.1";
+ break;
+ }
+ return s;
+}
+
+
+ostream&
+dcp::operator<< (ostream& s, Standard t)
+{
+ switch (t) {
+ case Standard::INTEROP:
+ s << "interop";
+ break;
+ case Standard::SMPTE:
+ s << "smpte";
+ break;
+ }
+ return s;
+}
diff --git a/src/types.h b/src/types.h
index 7f9c3e8b..1f74f7ab 100644
--- a/src/types.h
+++ b/src/types.h
@@ -79,7 +79,7 @@ extern bool operator!= (Size const & a, Size const & b);
extern std::ostream& operator<< (std::ostream& s, Size const & a);
/** Identifier for a sound channel */
-enum Channel {
+enum class Channel {
LEFT = 0, ///< left
RIGHT = 1, ///< right
CENTRE = 2, ///< centre
@@ -99,9 +99,10 @@ enum Channel {
};
std::vector<dcp::Channel> used_audio_channels ();
+std::ostream& operator<< (std::ostream& s, Channel c);
-enum MCASoundField
+enum class MCASoundField
{
FIVE_POINT_ONE,
SEVEN_POINT_ONE
@@ -112,9 +113,10 @@ extern std::string channel_to_mca_id (Channel c, MCASoundField field);
extern Channel mca_id_to_channel (std::string);
extern std::string channel_to_mca_name (Channel c, MCASoundField field);
extern ASDCP::UL channel_to_mca_universal_label (Channel c, MCASoundField field, ASDCP::Dictionary const* dict);
+std::ostream& operator<< (std::ostream& s, MCASoundField f);
-enum ContentKind
+enum class ContentKind
{
FEATURE,
SHORT,
@@ -132,8 +134,9 @@ enum ContentKind
extern std::string content_kind_to_string (ContentKind kind);
extern ContentKind content_kind_from_string (std::string kind);
+std::ostream& operator<<(std::ostream& s, ContentKind c);
-enum Effect
+enum class Effect
{
NONE,
BORDER,
@@ -142,43 +145,44 @@ enum Effect
extern std::string effect_to_string (Effect e);
extern Effect string_to_effect (std::string s);
+std::ostream& operator<< (std::ostream& s, Effect e);
-enum HAlign
+enum class HAlign
{
- HALIGN_LEFT, ///< horizontal position is distance from left of screen to left of subtitle
- HALIGN_CENTER, ///< horizontal position is distance from centre of screen to centre of subtitle
- HALIGN_RIGHT, ///< horizontal position is distance from right of screen to right of subtitle
+ LEFT, ///< horizontal position is distance from left of screen to left of subtitle
+ CENTER, ///< horizontal position is distance from centre of screen to centre of subtitle
+ RIGHT, ///< horizontal position is distance from right of screen to right of subtitle
};
extern std::string halign_to_string (HAlign a);
extern HAlign string_to_halign (std::string s);
-enum VAlign
+enum class VAlign
{
- VALIGN_TOP, ///< vertical position is distance from top of screen to top of subtitle
- VALIGN_CENTER, ///< vertical position is distance from centre of screen to centre of subtitle
- VALIGN_BOTTOM ///< vertical position is distance from bottom of screen to bottom of subtitle
+ TOP, ///< vertical position is distance from top of screen to top of subtitle
+ CENTER, ///< vertical position is distance from centre of screen to centre of subtitle
+ BOTTOM ///< vertical position is distance from bottom of screen to bottom of subtitle
};
extern std::string valign_to_string (VAlign a);
extern VAlign string_to_valign (std::string s);
/** Direction for subtitle test */
-enum Direction
+enum class Direction
{
- DIRECTION_LTR, ///< left-to-right
- DIRECTION_RTL, ///< right-to-left
- DIRECTION_TTB, ///< top-to-bottom
- DIRECTION_BTT ///< bottom-to-top
+ LTR, ///< left-to-right
+ RTL, ///< right-to-left
+ TTB, ///< top-to-bottom
+ BTT ///< bottom-to-top
};
extern std::string direction_to_string (Direction a);
extern Direction string_to_direction (std::string s);
-enum Eye
+enum class Eye
{
- EYE_LEFT,
- EYE_RIGHT
+ LEFT,
+ RIGHT
};
/** @class Fraction
@@ -257,18 +261,22 @@ struct EqualityOptions
/* I've been unable to make mingw happy with ERROR as a symbol, so
I'm using a DCP_ prefix here.
*/
-enum NoteType {
- DCP_PROGRESS,
- DCP_ERROR,
- DCP_NOTE
+enum class NoteType {
+ PROGRESS,
+ ERROR,
+ NOTE
};
-enum Standard {
+std::ostream& operator<< (std::ostream& s, NoteType t);
+
+enum class Standard {
INTEROP,
SMPTE
};
-enum Formulation {
+std::ostream& operator<< (std::ostream& s, Standard t);
+
+enum class Formulation {
MODIFIED_TRANSITIONAL_1,
MULTIPLE_MODIFIED_TRANSITIONAL_1,
DCI_ANY,
@@ -349,7 +357,7 @@ extern bool operator== (Rating const & a, Rating const & b);
extern std::ostream& operator<< (std::ostream& s, Rating const & r);
-enum Status
+enum class Status
{
FINAL, ///< final version
TEMP, ///< temporary version (picture/sound unfinished)
@@ -359,6 +367,7 @@ enum Status
extern std::string status_to_string (Status s);
extern Status string_to_status (std::string s);
+std::ostream& operator<< (std::ostream& s, Status t);
class ContentVersion
@@ -385,7 +394,7 @@ public:
class Luminance
{
public:
- enum Unit {
+ enum class Unit {
CANDELA_PER_SQUARE_METRE,
FOOT_LAMBERT
};
diff --git a/src/verify.cc b/src/verify.cc
index 3e584ba0..0696541f 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -844,11 +844,11 @@ verify_text_lines_and_characters (
auto position = [](shared_ptr<const SubtitleString> sub) {
switch (sub->v_align()) {
- case VALIGN_TOP:
+ case VAlign::TOP:
return lrintf(sub->v_position() * 100);
- case VALIGN_CENTER:
+ case VAlign::CENTER:
return lrintf((0.5f + sub->v_position()) * 100);
- case VALIGN_BOTTOM:
+ case VAlign::BOTTOM:
return lrintf((1.0f - sub->v_position()) * 100);
}
@@ -1065,7 +1065,7 @@ dcp::verify (
notes.push_back ({VerificationNote::VERIFY_ERROR, VerificationNote::FAILED_READ, string(e.what())});
}
- if (dcp->standard() != SMPTE) {
+ if (dcp->standard() != Standard::SMPTE) {
notes.push_back ({VerificationNote::VERIFY_BV21_ERROR, VerificationNote::INVALID_STANDARD});
}
@@ -1095,7 +1095,7 @@ dcp::verify (
}
}
- if (dcp->standard() == SMPTE) {
+ if (dcp->standard() == Standard::SMPTE) {
if (!cpl->annotation_text()) {
notes.push_back ({VerificationNote::VERIFY_BV21_ERROR, VerificationNote::MISSING_CPL_ANNOTATION_TEXT, cpl->id(), cpl->file().get()});
} else if (cpl->annotation_text().get() != cpl->content_title_text()) {
@@ -1158,7 +1158,7 @@ dcp::verify (
}
}
- if (dcp->standard() == SMPTE) {
+ if (dcp->standard() == Standard::SMPTE) {
boost::optional<int64_t> duration;
for (auto i: reel->assets()) {
if (!duration) {
@@ -1224,7 +1224,7 @@ dcp::verify (
most_closed_captions = std::max (most_closed_captions, reel->closed_captions().size());
}
- if (dcp->standard() == SMPTE) {
+ if (dcp->standard() == Standard::SMPTE) {
if (have_main_subtitle && have_no_main_subtitle) {
notes.push_back ({VerificationNote::VERIFY_BV21_ERROR, VerificationNote::MISSING_MAIN_SUBTITLE_FROM_SOME_REELS});
@@ -1234,7 +1234,7 @@ dcp::verify (
notes.push_back ({VerificationNote::VERIFY_BV21_ERROR, VerificationNote::MISMATCHED_CLOSED_CAPTION_ASSET_COUNTS});
}
- if (cpl->content_kind() == FEATURE) {
+ if (cpl->content_kind() == ContentKind::FEATURE) {
if (markers_seen.find(Marker::FFEC) == markers_seen.end()) {
notes.push_back ({VerificationNote::VERIFY_BV21_ERROR, VerificationNote::MISSING_FFEC_IN_FEATURE});
}