40 #include "compose.hpp"
44 #include "filesystem.h"
49 #include <asdcp/AS_DCP.h>
50 #include <asdcp/KM_fileio.h>
51 #include <boost/bind/bind.hpp>
54 using std::dynamic_pointer_cast;
56 using std::make_shared;
58 using std::shared_ptr;
61 #if BOOST_VERSION >= 106100
62 using namespace boost::placeholders;
67 MonoJ2KPictureAsset::MonoJ2KPictureAsset (boost::filesystem::path file)
70 Kumu::FileReaderFactory factory;
71 ASDCP::JP2K::MXFReader reader(factory);
72 auto r = reader.OpenRead(dcp::filesystem::fix_long_path(
file).
string().c_str());
73 if (ASDCP_FAILURE(r)) {
74 boost::throw_exception (
MXFFileError(
"could not open MXF file for reading",
file.string(), r));
77 ASDCP::JP2K::PictureDescriptor desc;
78 if (ASDCP_FAILURE (reader.FillPictureDescriptor(desc))) {
79 boost::throw_exception (
ReadError(
"could not read video MXF information"));
82 read_picture_descriptor (desc);
84 ASDCP::WriterInfo info;
85 if (ASDCP_FAILURE (reader.FillWriterInfo (info))) {
86 boost::throw_exception (
ReadError(
"could not read video MXF information"));
101 storing_note_handler (list<pair<NoteType, string>>& notes, NoteType t,
string s)
103 notes.push_back (make_pair (t, s));
108 MonoJ2KPictureAsset::equals(shared_ptr<const Asset> other,
EqualityOptions const& opt, NoteHandler note)
const
110 if (!dynamic_pointer_cast<const MonoJ2KPictureAsset>(other)) {
114 Kumu::FileReaderFactory factory;
115 ASDCP::JP2K::MXFReader reader_A(factory);
117 auto r = reader_A.OpenRead(dcp::filesystem::fix_long_path(*_file).string().c_str());
118 if (ASDCP_FAILURE(r)) {
119 boost::throw_exception (
MXFFileError(
"could not open MXF file for reading",
_file->string(), r));
122 ASDCP::JP2K::MXFReader reader_B(factory);
123 DCP_ASSERT (other->file ());
124 r = reader_B.OpenRead(dcp::filesystem::fix_long_path(*other->file()).string().c_str());
125 if (ASDCP_FAILURE (r)) {
126 boost::throw_exception (
MXFFileError (
"could not open MXF file for reading", other->file()->string(), r));
129 ASDCP::JP2K::PictureDescriptor desc_A;
130 if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) {
131 boost::throw_exception (
ReadError (
"could not read video MXF information"));
133 ASDCP::JP2K::PictureDescriptor desc_B;
134 if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) {
135 boost::throw_exception (
ReadError (
"could not read video MXF information"));
138 if (!descriptor_equals (desc_A, desc_B, note)) {
142 auto other_picture = dynamic_pointer_cast<const MonoJ2KPictureAsset> (other);
143 DCP_ASSERT (other_picture);
147 auto reader = start_read ();
148 auto other_reader = other_picture->start_read ();
151 #pragma omp parallel for
155 if (i >= other_picture->intrinsic_duration()) {
159 if (result || opt.keep_going) {
161 auto frame_A = reader->get_frame (i);
162 auto frame_B = other_reader->get_frame (i);
164 list<pair<NoteType, string>> notes;
166 if (!frame_buffer_equals (
167 i, opt, bind (&storing_note_handler, boost::ref(notes), _1, _2),
168 frame_A->data(), frame_A->size(),
169 frame_B->data(), frame_B->size()
178 note (NoteType::PROGRESS, String::compose(
"Compared video frame %1 of %2", i,
_intrinsic_duration));
179 for (
auto const& i: notes) {
180 note (i.first, i.second);
190 shared_ptr<J2KPictureAssetWriter>
197 shared_ptr<MonoJ2KPictureAssetReader>
198 MonoJ2KPictureAsset::start_read ()
const
206 MonoJ2KPictureAsset::cpl_node_name ()
const
208 return "MainPicture";
boost::optional< boost::filesystem::path > file() const
boost::optional< boost::filesystem::path > _file
A class to describe what "equality" means for a particular test.
A fraction (i.e. a thing with an integer numerator and an integer denominator).
An asset made up of JPEG2000 data.
An exception related to an MXF file.
std::string read_writer_info(ASDCP::WriterInfo const &)
boost::optional< Key > key() const
A helper class for writing to MonoJ2KPictureAssets.
MonoJ2KPictureAsset(boost::filesystem::path file)
std::shared_ptr< J2KPictureAssetWriter > start_write(boost::filesystem::path file, Behaviour behaviour) override
int64_t _intrinsic_duration
Any error that occurs when reading data from a DCP.
Class to describe what equality means when calling Asset::equals().
Exceptions thrown by libdcp.
MonoJ2KPictureAsset class.
MonoJ2KPictureAssetReader typedef.
MonoJ2KPictureAssetWriter class.
MonoJ2KPictureFrame class.
Namespace for everything in libdcp.