summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/asset.cc20
-rw-r--r--src/asset.h4
-rw-r--r--src/picture_asset.cc84
-rw-r--r--src/picture_asset.h2
-rw-r--r--src/types.h2
5 files changed, 98 insertions, 14 deletions
diff --git a/src/asset.cc b/src/asset.cc
index 4b02774c..8063603a 100644
--- a/src/asset.cc
+++ b/src/asset.cc
@@ -110,12 +110,14 @@ Asset::equals (shared_ptr<const Asset> other, EqualityFlags flags) const
if (_length != other->_length) {
notes.push_back ("MXF lengths differ");
}
- if (_digest != other->_digest) {
- notes.push_back ("MXF digests differ");
- }
}
if (flags & MXF_BITWISE) {
+
+ if (_digest != other->_digest) {
+ notes.push_back ("MXF digests differ");
+ }
+
if (filesystem::file_size (mxf_path()) != filesystem::file_size (other->mxf_path())) {
notes.push_back (mxf_path().string() + " and " + other->mxf_path().string() + " sizes differ");
return notes;
@@ -135,20 +137,14 @@ Asset::equals (shared_ptr<const Asset> other, EqualityFlags flags) const
a.read (abuffer, t);
b.read (bbuffer, t);
- for (int i = 0; i < t; ++i) {
- if (abuffer[i] != bbuffer[i]) {
- notes.push_back (mxf_path().string() + " and " + other->mxf_path().string() + " content differs");
- return notes;
- }
+ if (memcmp (abuffer, bbuffer, t) != 0) {
+ notes.push_back (mxf_path().string() + " and " + other->mxf_path().string() + " content differs");
+ return notes;
}
n -= t;
}
}
- if (flags & MXF_INSPECT) {
-
- }
-
return notes;
}
diff --git a/src/asset.h b/src/asset.h
index 4d26a4bc..e078f44b 100644
--- a/src/asset.h
+++ b/src/asset.h
@@ -66,9 +66,11 @@ public:
*/
void write_to_assetmap (std::ostream& s) const;
- std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags) const;
+ virtual std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags) const;
protected:
+ friend class PictureAsset;
+
/** Fill in a ADSCP::WriteInfo struct.
* @param w struct to fill in.
*/
diff --git a/src/picture_asset.cc b/src/picture_asset.cc
index 7ff525b9..c3bf39e8 100644
--- a/src/picture_asset.cc
+++ b/src/picture_asset.cc
@@ -26,6 +26,7 @@
#include <iostream>
#include <sstream>
#include <boost/filesystem.hpp>
+#include <boost/lexical_cast.hpp>
#include "AS_DCP.h"
#include "KM_fileio.h"
#include "picture_asset.h"
@@ -140,3 +141,86 @@ PictureAsset::write_to_cpl (ostream& s) const
<< " <ScreenAspectRatio>" << _width << " " << _height << "</ScreenAspectRatio>\n"
<< " </MainPicture>\n";
}
+
+list<string>
+PictureAsset::equals (shared_ptr<const Asset> other, EqualityFlags flags) const
+{
+ list<string> notes = Asset::equals (other, flags);
+
+ if (flags & MXF_INSPECT) {
+ ASDCP::JP2K::MXFReader reader_A;
+ if (ASDCP_FAILURE (reader_A.OpenRead (mxf_path().c_str()))) {
+ throw FileError ("could not open MXF file for reading", mxf_path().string());
+ }
+
+ ASDCP::JP2K::MXFReader reader_B;
+ if (ASDCP_FAILURE (reader_B.OpenRead (other->mxf_path().c_str()))) {
+ throw FileError ("could not open MXF file for reading", mxf_path().string());
+ }
+
+ ASDCP::JP2K::PictureDescriptor desc_A;
+ if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) {
+ throw DCPReadError ("could not read video MXF information");
+ }
+ ASDCP::JP2K::PictureDescriptor desc_B;
+ if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) {
+ throw DCPReadError ("could not read video MXF information");
+ }
+
+ if (
+ desc_A.EditRate != desc_B.EditRate ||
+ desc_A.ContainerDuration != desc_B.ContainerDuration ||
+ desc_A.SampleRate != desc_B.SampleRate ||
+ desc_A.StoredWidth != desc_B.StoredWidth ||
+ desc_A.StoredHeight != desc_B.StoredHeight ||
+ desc_A.AspectRatio != desc_B.AspectRatio ||
+ desc_A.Rsize != desc_B.Rsize ||
+ desc_A.Xsize != desc_B.Xsize ||
+ desc_A.Ysize != desc_B.Ysize ||
+ desc_A.XOsize != desc_B.XOsize ||
+ desc_A.YOsize != desc_B.YOsize ||
+ desc_A.XTsize != desc_B.XTsize ||
+ desc_A.YTsize != desc_B.YTsize ||
+ desc_A.XTOsize != desc_B.XTOsize ||
+ desc_A.YTOsize != desc_B.YTOsize ||
+ desc_A.Csize != desc_B.Csize
+// desc_A.CodingStyleDefault != desc_B.CodingStyleDefault ||
+// desc_A.QuantizationDefault != desc_B.QuantizationDefault
+ ) {
+
+ notes.push_back ("video MXF picture descriptors differ");
+ }
+
+// for (unsigned int j = 0; j < ASDCP::JP2K::MaxComponents; ++j) {
+// if (desc_A.ImageComponents[j] != desc_B.ImageComponents[j]) {
+// notes.pack_start ("video MXF picture descriptors differ");
+// }
+// }
+
+
+ ASDCP::JP2K::FrameBuffer buffer_A (4 * Kumu::Megabyte);
+ ASDCP::JP2K::FrameBuffer buffer_B (4 * Kumu::Megabyte);
+
+ for (int i = 0; i < _length; ++i) {
+ if (ASDCP_FAILURE (reader_A.ReadFrame (0, buffer_A))) {
+ throw DCPReadError ("could not read video frame");
+ }
+
+ if (ASDCP_FAILURE (reader_B.ReadFrame (0, buffer_B))) {
+ throw DCPReadError ("could not read video frame");
+ }
+
+ if (buffer_A.Size() != buffer_B.Size()) {
+ notes.push_back ("sizes of video data for frame " + lexical_cast<string>(i) + " differ");
+ continue;
+ }
+
+ if (memcmp (buffer_A.RoData(), buffer_B.RoData(), buffer_A.Size()) != 0) {
+ notes.push_back ("J2K data for frame " + lexical_cast<string>(i) + " differ");
+ continue;
+ }
+ }
+ }
+
+ return notes;
+}
diff --git a/src/picture_asset.h b/src/picture_asset.h
index 9fa4f99e..cccea0f3 100644
--- a/src/picture_asset.h
+++ b/src/picture_asset.h
@@ -81,6 +81,8 @@ public:
*/
void write_to_cpl (std::ostream& s) const;
+ std::list<std::string> equals (boost::shared_ptr<const Asset> other, EqualityFlags flags) const;
+
private:
std::string path_from_list (int f, std::vector<std::string> const & files) const;
void construct (sigc::slot<std::string, int>);
diff --git a/src/types.h b/src/types.h
index 019f93a7..ee3edaef 100644
--- a/src/types.h
+++ b/src/types.h
@@ -65,7 +65,7 @@ public:
enum EqualityFlags {
LIBDCP_METADATA = 0x1,
MXF_BITWISE = 0x2,
- MXF_INSPECT
+ MXF_INSPECT = 0x4
};
}