43 #include "filesystem.h"
48 #include <asdcp/AS_DCP.h>
54 using std::shared_ptr;
55 using std::dynamic_pointer_cast;
59 StereoJ2KPictureAsset::StereoJ2KPictureAsset (boost::filesystem::path file)
62 Kumu::FileReaderFactory factory;
63 ASDCP::JP2K::MXFSReader reader(factory);
64 auto r = reader.OpenRead(dcp::filesystem::fix_long_path(file).
string().c_str());
65 if (ASDCP_FAILURE(r)) {
66 boost::throw_exception (
MXFFileError(
"could not open MXF file for reading", file.string(), r));
69 ASDCP::JP2K::PictureDescriptor desc;
70 if (ASDCP_FAILURE (reader.FillPictureDescriptor(desc))) {
71 boost::throw_exception (
ReadError(
"could not read video MXF information"));
74 read_picture_descriptor (desc);
76 ASDCP::WriterInfo info;
77 if (ASDCP_FAILURE (reader.FillWriterInfo(info))) {
78 boost::throw_exception (
ReadError(
"could not read video MXF information"));
81 _id = read_writer_info (info);
85 StereoJ2KPictureAsset::StereoJ2KPictureAsset (
Fraction edit_rate, Standard standard)
92 shared_ptr<J2KPictureAssetWriter>
93 StereoJ2KPictureAsset::start_write(boost::filesystem::path file, Behaviour behaviour)
99 shared_ptr<StereoJ2KPictureAssetReader>
100 StereoJ2KPictureAsset::start_read ()
const
107 StereoJ2KPictureAsset::equals(shared_ptr<const Asset> other,
EqualityOptions const& opt, NoteHandler note)
const
109 Kumu::FileReaderFactory factory;
110 ASDCP::JP2K::MXFSReader reader_A(factory);
112 auto r = reader_A.OpenRead(dcp::filesystem::fix_long_path(*
file()).
string().c_str());
113 if (ASDCP_FAILURE (r)) {
114 boost::throw_exception (
MXFFileError (
"could not open MXF file for reading",
file()->
string(), r));
117 ASDCP::JP2K::MXFSReader reader_B(factory);
118 DCP_ASSERT (other->file());
119 r = reader_B.OpenRead(dcp::filesystem::fix_long_path(*other->file()).string().c_str());
120 if (ASDCP_FAILURE (r)) {
121 boost::throw_exception (
MXFFileError (
"could not open MXF file for reading", other->file()->string(), r));
124 ASDCP::JP2K::PictureDescriptor desc_A;
125 if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) {
126 boost::throw_exception (
ReadError (
"could not read video MXF information"));
128 ASDCP::JP2K::PictureDescriptor desc_B;
129 if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) {
130 boost::throw_exception (
ReadError (
"could not read video MXF information"));
133 if (!descriptor_equals (desc_A, desc_B, note)) {
137 auto other_picture = dynamic_pointer_cast<const StereoJ2KPictureAsset> (other);
138 DCP_ASSERT (other_picture);
140 auto reader = start_read ();
141 auto other_reader = other_picture->start_read ();
146 shared_ptr<const StereoJ2KPictureFrame> frame_A;
147 shared_ptr<const StereoJ2KPictureFrame> frame_B;
149 frame_A = reader->get_frame (i);
150 frame_B = other_reader->get_frame (i);
155 note (NoteType::ERROR, e.what ());
159 if (!frame_buffer_equals (
161 frame_A->left()->data(), frame_A->left()->size(),
162 frame_B->left()->data(), frame_B->left()->size()
165 if (!opt.keep_going) {
170 if (!frame_buffer_equals (
172 frame_A->right()->data(), frame_A->right()->size(),
173 frame_B->right()->data(), frame_B->right()->size()
176 if (!opt.keep_going) {
boost::optional< boost::filesystem::path > file() const
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.
boost::optional< Key > key() const
int64_t _intrinsic_duration
Any error that occurs when reading data from a DCP.
A helper class for writing to StereoJ2KPictureAssets.
Class to describe what equality means when calling Asset::equals().
Exceptions thrown by libdcp.
Namespace for everything in libdcp.
StereoJ2KPictureAsset class.
StereoJ2KPictureAssetReader typedef.
StereoJ2KPictureAssetWriter class.
StereoJ2KPictureFrame class.