Remove bitwise DCP comparison, which I think is fairly useless (just use diff, no?)
authorCarl Hetherington <cth@carlh.net>
Tue, 2 Oct 2012 20:55:37 +0000 (21:55 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 2 Oct 2012 20:55:37 +0000 (21:55 +0100)
src/mxf_asset.cc
src/picture_asset.cc
src/sound_asset.cc
src/types.h
tools/dcpdiff.cc

index d0e02c8bfd12718379707ab56428549492805501..ead97b9e5b261876482a15bfc8f3be9051b59bbf 100644 (file)
@@ -58,7 +58,7 @@ MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info) const
 }
 
 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) {
@@ -80,41 +80,6 @@ MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<strin
                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;
 }
index 898fe75b64fd4ad8e883c2940df3c9cd13626291..12dfd1aa5e87745746d06109191437866f482640 100644 (file)
@@ -70,56 +70,55 @@ PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<s
                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;
 }
@@ -241,18 +240,16 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, li
        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;
                }
        }
 
@@ -269,27 +266,24 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt,
        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;
                }
        }
 
index 9395a48765a31cfe8a320a0e7dd47dceae62bba7..7a3d44152b4b27ff15844ae19c97866ef41dc1b5 100644 (file)
@@ -200,64 +200,62 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<str
                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;
                }
        }
 
index 7c98a3b352ff4b7d588975b0c268174e23fc4bf0..71ab797bb380ce38bb06c9d4b2a9178d26e29ee2 100644 (file)
@@ -86,11 +86,6 @@ extern bool operator== (Fraction const & a, Fraction const & b);
 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;
 };
index c9139e7ba36b74e0d7bec2fcd95d56897009d815..9acbfa1a6250d164e19c7aa06575943f6e6eba19 100644 (file)
@@ -12,40 +12,34 @@ static void
 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);