summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-06-06 21:16:54 +0200
committerCarl Hetherington <cth@carlh.net>2024-06-06 21:16:54 +0200
commitcfa0a559a8feec79d1e8acd20d4b11ef8cd01513 (patch)
treeee0b1bd5b6621046693cc530c94a87844b43fee7
parentc3fc0d69e0563099d40e0a4ab787c0d3264f865b (diff)
Store the video encoding of a DCP in the metadata (J2K/MPEG2).
-rw-r--r--src/lib/dcp_content.cc7
-rw-r--r--src/lib/dcp_content.h7
-rw-r--r--src/lib/dcp_examiner.cc3
-rw-r--r--src/lib/dcp_examiner.h5
4 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index 465eff706..5fb532d03 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -139,6 +139,11 @@ DCPContent::DCPContent (cxml::ConstNodePtr node, int version)
DCPOMATIC_ASSERT (false);
}
}
+
+ if (auto encoding = node->optional_string_child("VideoEncoding")) {
+ _video_encoding = video_encoding_from_string(*encoding);
+ }
+
_three_d = node->optional_bool_child("ThreeD").get_value_or (false);
auto ck = node->optional_string_child("ContentKind");
@@ -306,6 +311,7 @@ DCPContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
_needs_assets = examiner->needs_assets ();
_kdm_valid = examiner->kdm_valid ();
_standard = examiner->standard ();
+ _video_encoding = examiner->video_encoding();
_three_d = examiner->three_d ();
_content_kind = examiner->content_kind ();
_cpl = examiner->cpl ();
@@ -407,6 +413,7 @@ DCPContent::as_xml(xmlpp::Element* element, bool with_paths) const
DCPOMATIC_ASSERT (false);
}
}
+ cxml::add_text_child(element, "VideoEncoding", video_encoding_to_string(_video_encoding));
cxml::add_text_child(element, "ThreeD", _three_d ? "1" : "0");
if (_content_kind) {
cxml::add_text_child(element, "ContentKind", _content_kind->name());
diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h
index 995e0b681..be2c72002 100644
--- a/src/lib/dcp_content.h
+++ b/src/lib/dcp_content.h
@@ -32,6 +32,7 @@
#include "enum_indexed_vector.h"
#include "font.h"
#include "resolution.h"
+#include "video_encoding.h"
#include <libcxml/cxml.h>
#include <dcp/content_kind.h>
#include <dcp/encrypted_kdm.h>
@@ -160,6 +161,11 @@ public:
return _standard.get ();
}
+ VideoEncoding video_encoding() const {
+ boost::mutex::scoped_lock lm (_mutex);
+ return _video_encoding;
+ }
+
std::map<dcp::Marker, dcpomatic::ContentTime> markers () const {
return _markers;
}
@@ -213,6 +219,7 @@ private:
EnumIndexedVector<bool, TextType> _reference_text;
boost::optional<dcp::Standard> _standard;
+ VideoEncoding _video_encoding;
boost::optional<dcp::ContentKind> _content_kind;
bool _three_d;
/** ID of the CPL to use; older metadata might not specify this: in that case
diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc
index ae885c140..a7af9feca 100644
--- a/src/lib/dcp_examiner.cc
+++ b/src/lib/dcp_examiner.cc
@@ -308,15 +308,18 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
auto reader = j2k_mono->start_read();
reader->set_check_hmac (false);
reader->get_frame(0)->xyz_image();
+ _video_encoding = VideoEncoding::JPEG2000;
} else if (j2k_stereo) {
auto reader = j2k_stereo->start_read();
reader->set_check_hmac (false);
reader->get_frame(0)->xyz_image(dcp::Eye::LEFT);
+ _video_encoding = VideoEncoding::JPEG2000;
} else if (mpeg2_mono) {
auto reader = mpeg2_mono->start_read();
reader->set_check_hmac(false);
dcp::MPEG2Decompressor decompressor;
decompressor.decompress_frame(reader->get_frame(0));
+ _video_encoding = VideoEncoding::MPEG2;
}
}
diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h
index d6baf7d50..28b59ee2f 100644
--- a/src/lib/dcp_examiner.h
+++ b/src/lib/dcp_examiner.h
@@ -130,6 +130,10 @@ public:
return _standard;
}
+ VideoEncoding video_encoding() const {
+ return _video_encoding;
+ }
+
bool three_d () const {
return _three_d;
}
@@ -200,6 +204,7 @@ private:
bool _needs_assets = false;
bool _kdm_valid = false;
boost::optional<dcp::Standard> _standard;
+ VideoEncoding _video_encoding = VideoEncoding::JPEG2000;
bool _three_d = false;
boost::optional<dcp::ContentKind> _content_kind;
std::string _cpl;