}
bool
-MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<string>& notes) const
+MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions, list<string>& notes) const
{
shared_ptr<const MXFAsset> other_mxf = dynamic_pointer_cast<const MXFAsset> (other);
if (!other_mxf) {
notes.push_back ("MXF lengths differ");
return false;
}
-
- if (opt.bitwise) {
-
- if (digest() != other_mxf->digest()) {
- notes.push_back ("MXF digests differ");
- return false;
- }
-
- if (filesystem::file_size (path()) != filesystem::file_size (other_mxf->path())) {
- notes.push_back (path().string() + " and " + other_mxf->path().string() + " sizes differ");
- return false;
- }
-
- ifstream a (path().string().c_str(), ios::binary);
- ifstream b (other_mxf->path().string().c_str(), ios::binary);
-
- int buffer_size = 65536;
- char abuffer[buffer_size];
- char bbuffer[buffer_size];
-
- int n = filesystem::file_size (path ());
-
- while (n) {
- int const t = min (n, buffer_size);
- a.read (abuffer, t);
- b.read (bbuffer, t);
-
- if (memcmp (abuffer, bbuffer, t) != 0) {
- notes.push_back (path().string() + " and " + other_mxf->path().string() + " content differs");
- return false;
- }
-
- n -= t;
- }
- }
return true;
}
return false;
}
- if (!opt.bitwise) {
- ASDCP::JP2K::MXFReader reader_A;
- if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) {
- throw MXFFileError ("could not open MXF file for reading", path().string());
- }
-
- ASDCP::JP2K::MXFReader reader_B;
- if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) {
- throw MXFFileError ("could not open MXF file for reading", 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
- ) {
+ ASDCP::JP2K::MXFReader reader_A;
+ if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) {
+ throw MXFFileError ("could not open MXF file for reading", path().string());
+ }
+
+ ASDCP::JP2K::MXFReader reader_B;
+ if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) {
+ throw MXFFileError ("could not open MXF file for reading", 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");
- }
+ notes.push_back ("video MXF picture descriptors differ");
+ return false;
+ }
// 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");
// }
// }
- }
return true;
}
shared_ptr<const MonoPictureAsset> other_picture = dynamic_pointer_cast<const MonoPictureAsset> (other);
assert (other_picture);
- if (!opt.bitwise) {
- for (int i = 0; i < _length; ++i) {
- shared_ptr<const MonoPictureFrame> frame_A = get_frame (i);
- shared_ptr<const MonoPictureFrame> frame_B = other_picture->get_frame (i);
-
- if (!frame_buffer_equals (
- i, opt, notes,
- frame_A->j2k_frame()->RoData(), frame_A->j2k_frame()->Size(),
- frame_B->j2k_frame()->RoData(), frame_B->j2k_frame()->Size()
- )) {
- return false;
- }
+ for (int i = 0; i < _length; ++i) {
+ shared_ptr<const MonoPictureFrame> frame_A = get_frame (i);
+ shared_ptr<const MonoPictureFrame> frame_B = other_picture->get_frame (i);
+
+ if (!frame_buffer_equals (
+ i, opt, notes,
+ frame_A->j2k_frame()->RoData(), frame_A->j2k_frame()->Size(),
+ frame_B->j2k_frame()->RoData(), frame_B->j2k_frame()->Size()
+ )) {
+ return false;
}
}
shared_ptr<const StereoPictureAsset> other_picture = dynamic_pointer_cast<const StereoPictureAsset> (other);
assert (other_picture);
- if (!opt.bitwise) {
-
- for (int i = 0; i < _length; ++i) {
- shared_ptr<const StereoPictureFrame> frame_A = get_frame (i);
- shared_ptr<const StereoPictureFrame> frame_B = other_picture->get_frame (i);
-
- if (!frame_buffer_equals (
- i, opt, notes,
- frame_A->j2k_frame()->Left.RoData(), frame_A->j2k_frame()->Left.Size(),
- frame_B->j2k_frame()->Left.RoData(), frame_B->j2k_frame()->Left.Size()
- )) {
- return false;
- }
-
- if (!frame_buffer_equals (
- i, opt, notes,
- frame_A->j2k_frame()->Right.RoData(), frame_A->j2k_frame()->Right.Size(),
- frame_B->j2k_frame()->Right.RoData(), frame_B->j2k_frame()->Right.Size()
- )) {
- return false;
- }
+ for (int i = 0; i < _length; ++i) {
+ shared_ptr<const StereoPictureFrame> frame_A = get_frame (i);
+ shared_ptr<const StereoPictureFrame> frame_B = other_picture->get_frame (i);
+
+ if (!frame_buffer_equals (
+ i, opt, notes,
+ frame_A->j2k_frame()->Left.RoData(), frame_A->j2k_frame()->Left.Size(),
+ frame_B->j2k_frame()->Left.RoData(), frame_B->j2k_frame()->Left.Size()
+ )) {
+ return false;
+ }
+
+ if (!frame_buffer_equals (
+ i, opt, notes,
+ frame_A->j2k_frame()->Right.RoData(), frame_A->j2k_frame()->Right.Size(),
+ frame_B->j2k_frame()->Right.RoData(), frame_B->j2k_frame()->Right.Size()
+ )) {
+ return false;
}
}
return false;
}
- if (!opt.bitwise) {
- ASDCP::PCM::MXFReader reader_A;
- if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) {
- throw MXFFileError ("could not open MXF file for reading", path().string());
- }
+ ASDCP::PCM::MXFReader reader_A;
+ if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) {
+ throw MXFFileError ("could not open MXF file for reading", path().string());
+ }
- ASDCP::PCM::MXFReader reader_B;
- if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) {
- throw MXFFileError ("could not open MXF file for reading", path().string());
- }
+ ASDCP::PCM::MXFReader reader_B;
+ if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) {
+ throw MXFFileError ("could not open MXF file for reading", path().string());
+ }
- ASDCP::PCM::AudioDescriptor desc_A;
- if (ASDCP_FAILURE (reader_A.FillAudioDescriptor (desc_A))) {
- throw DCPReadError ("could not read audio MXF information");
+ ASDCP::PCM::AudioDescriptor desc_A;
+ if (ASDCP_FAILURE (reader_A.FillAudioDescriptor (desc_A))) {
+ throw DCPReadError ("could not read audio MXF information");
+ }
+ ASDCP::PCM::AudioDescriptor desc_B;
+ if (ASDCP_FAILURE (reader_B.FillAudioDescriptor (desc_B))) {
+ throw DCPReadError ("could not read audio MXF information");
+ }
+
+ if (
+ desc_A.EditRate != desc_B.EditRate ||
+ desc_A.AudioSamplingRate != desc_B.AudioSamplingRate ||
+ desc_A.Locked != desc_B.Locked ||
+ desc_A.ChannelCount != desc_B.ChannelCount ||
+ desc_A.QuantizationBits != desc_B.QuantizationBits ||
+ desc_A.BlockAlign != desc_B.BlockAlign ||
+ desc_A.AvgBps != desc_B.AvgBps ||
+ desc_A.LinkedTrackID != desc_B.LinkedTrackID ||
+ desc_A.ContainerDuration != desc_B.ContainerDuration
+// desc_A.ChannelFormat != desc_B.ChannelFormat ||
+ ) {
+
+ notes.push_back ("audio MXF picture descriptors differ");
+ return false;
+ }
+
+ ASDCP::PCM::FrameBuffer buffer_A (1 * Kumu::Megabyte);
+ ASDCP::PCM::FrameBuffer buffer_B (1 * Kumu::Megabyte);
+
+ for (int i = 0; i < _length; ++i) {
+ if (ASDCP_FAILURE (reader_A.ReadFrame (i, buffer_A))) {
+ throw DCPReadError ("could not read audio frame");
}
- ASDCP::PCM::AudioDescriptor desc_B;
- if (ASDCP_FAILURE (reader_B.FillAudioDescriptor (desc_B))) {
- throw DCPReadError ("could not read audio MXF information");
+
+ if (ASDCP_FAILURE (reader_B.ReadFrame (i, buffer_B))) {
+ throw DCPReadError ("could not read audio frame");
}
-
- if (
- desc_A.EditRate != desc_B.EditRate ||
- desc_A.AudioSamplingRate != desc_B.AudioSamplingRate ||
- desc_A.Locked != desc_B.Locked ||
- desc_A.ChannelCount != desc_B.ChannelCount ||
- desc_A.QuantizationBits != desc_B.QuantizationBits ||
- desc_A.BlockAlign != desc_B.BlockAlign ||
- desc_A.AvgBps != desc_B.AvgBps ||
- desc_A.LinkedTrackID != desc_B.LinkedTrackID ||
- desc_A.ContainerDuration != desc_B.ContainerDuration
-// desc_A.ChannelFormat != desc_B.ChannelFormat ||
- ) {
- notes.push_back ("audio MXF picture descriptors differ");
+ if (buffer_A.Size() != buffer_B.Size()) {
+ notes.push_back ("sizes of audio data for frame " + lexical_cast<string>(i) + " differ");
return false;
}
-
- ASDCP::PCM::FrameBuffer buffer_A (1 * Kumu::Megabyte);
- ASDCP::PCM::FrameBuffer buffer_B (1 * Kumu::Megabyte);
-
- for (int i = 0; i < _length; ++i) {
- if (ASDCP_FAILURE (reader_A.ReadFrame (i, buffer_A))) {
- throw DCPReadError ("could not read audio frame");
- }
-
- if (ASDCP_FAILURE (reader_B.ReadFrame (i, buffer_B))) {
- throw DCPReadError ("could not read audio frame");
- }
-
- if (buffer_A.Size() != buffer_B.Size()) {
- notes.push_back ("sizes of audio data for frame " + lexical_cast<string>(i) + " differ");
- return false;
- }
-
- if (memcmp (buffer_A.RoData(), buffer_B.RoData(), buffer_A.Size()) != 0) {
- notes.push_back ("PCM data for MXF frame " + lexical_cast<string>(i) + " differ");
- return false;
- }
+
+ if (memcmp (buffer_A.RoData(), buffer_B.RoData(), buffer_A.Size()) != 0) {
+ notes.push_back ("PCM data for MXF frame " + lexical_cast<string>(i) + " differ");
+ return false;
}
}
extern bool operator!= (Fraction const & a, Fraction const & b);
struct EqualityOptions {
- /** true to do a bitwise comparison.
- * false to compare PCM and image data, possibly allowing
- * some variation in values.
- */
- bool bitwise;
double max_mean_pixel_error;
double max_std_dev_pixel_error;
};
help (string n)
{
cerr << "Syntax: " << n << " [OPTION] <DCP> <DCP>\n"
- << " -b, --bitwise bitwise check\n"
<< " -v, --version show libdcp version\n"
<< " -h, --help show this help\n"
<< "\n"
<< "The <DCP>s are the DCP directories to compare.\n"
- << "Default is to compare metadata and content, ignoring timestamps\n"
- << "and differing UUIDs. Pass -b to perform a bitwise comparison.\n";
+ << "Comparison is of metadata and content, ignoring timestamps\n"
+ << "and differing UUIDs.\n";
}
int
main (int argc, char* argv[])
{
EqualityOptions options;
- options.bitwise = false;
int option_index = 0;
while (1) {
static struct option long_options[] = {
- { "bitwise", no_argument, 0, 'b'},
{ "version", no_argument, 0, 'v'},
{ "help", no_argument, 0, 'h'},
{ 0, 0, 0, 0 }
};
- int c = getopt_long (argc, argv, "bvhd", long_options, &option_index);
+ int c = getopt_long (argc, argv, "vh", long_options, &option_index);
if (c == -1) {
break;
}
switch (c) {
- case 'b':
- options.bitwise = true;
- break;
case 'v':
cout << "dcpdiff version " << LIBDCP_VERSION << "\n";
exit (EXIT_SUCCESS);