Try to fix comparison of 3D DCPs.
authorCarl Hetherington <cth@carlh.net>
Wed, 9 Oct 2013 14:26:06 +0000 (15:26 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 9 Oct 2013 14:26:06 +0000 (15:26 +0100)
src/mono_picture_asset.cc
src/picture_asset.cc
src/picture_asset.h
src/stereo_picture_asset.cc

index 81508065eadaca5982c8d9e8e767b0b61a0b3176..1a724127b5e32ba0ac4babdac2d2d44eb78c7b03 100644 (file)
@@ -121,7 +121,30 @@ MonoPictureAsset::get_frame (int n) const
 bool
 MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
 {
-       if (!PictureAsset::equals (other, opt, note)) {
+       if (!MXFAsset::equals (other, opt, note)) {
+               return false;
+       }
+
+       ASDCP::JP2K::MXFReader reader_A;
+       if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) {
+               boost::throw_exception (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()))) {
+               boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string()));
+       }
+       
+       ASDCP::JP2K::PictureDescriptor desc_A;
+       if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) {
+               boost::throw_exception (DCPReadError ("could not read video MXF information"));
+       }
+       ASDCP::JP2K::PictureDescriptor desc_B;
+       if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) {
+               boost::throw_exception (DCPReadError ("could not read video MXF information"));
+       }
+       
+       if (!descriptor_equals (desc_A, desc_B, note)) {
                return false;
        }
 
index 12032328522c20be17c95ba8f50152337f23e8a7..63f59638ef9140e7f26d9cfbc3293f44f5a3367f 100644 (file)
@@ -81,61 +81,40 @@ PictureAsset::write_to_cpl (xmlpp::Element* node, bool interop) const
 }
 
 bool
-PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
+PictureAsset::descriptor_equals (
+       ASDCP::JP2K::PictureDescriptor const & a, ASDCP::JP2K::PictureDescriptor const & b, boost::function<void (NoteType, string)> note
+       ) const
 {
-       if (!MXFAsset::equals (other, opt, note)) {
-               return false;
-       }
-                    
-       ASDCP::JP2K::MXFReader reader_A;
-       if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) {
-               boost::throw_exception (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()))) {
-               boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string()));
-       }
-       
-       ASDCP::JP2K::PictureDescriptor desc_A;
-       if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) {
-               boost::throw_exception (DCPReadError ("could not read video MXF information"));
-       }
-       ASDCP::JP2K::PictureDescriptor desc_B;
-       if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) {
-               boost::throw_exception (DCPReadError ("could not read video MXF information"));
-       }
-       
        if (
-               desc_A.EditRate != desc_B.EditRate ||
-               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
+               a.EditRate != b.EditRate ||
+               a.SampleRate != b.SampleRate ||
+               a.StoredWidth != b.StoredWidth ||
+               a.StoredHeight != b.StoredHeight ||
+               a.AspectRatio != b.AspectRatio ||
+               a.Rsize != b.Rsize ||
+               a.Xsize != b.Xsize ||
+               a.Ysize != b.Ysize ||
+               a.XOsize != b.XOsize ||
+               a.YOsize != b.YOsize ||
+               a.XTsize != b.XTsize ||
+               a.YTsize != b.YTsize ||
+               a.XTOsize != b.XTOsize ||
+               a.YTOsize != b.YTOsize ||
+               a.Csize != b.Csize
+//             a.CodingStyleDefault != b.CodingStyleDefault ||
+//             a.QuantizationDefault != b.QuantizationDefault
                ) {
                
                note (ERROR, "video MXF picture descriptors differ");
                return false;
        }
 
-       if (desc_A.ContainerDuration != desc_B.ContainerDuration) {
+       if (a.ContainerDuration != b.ContainerDuration) {
                note (ERROR, "video container durations differ");
        }
        
 //             for (unsigned int j = 0; j < ASDCP::JP2K::MaxComponents; ++j) {
-//                     if (desc_A.ImageComponents[j] != desc_B.ImageComponents[j]) {
+//                     if (a.ImageComponents[j] != b.ImageComponents[j]) {
 //                             notes.pack_start ("video MXF picture descriptors differ");
 //                     }
 //             }
index 53231418ace0c90558898e8a51484db1fc9c8d1e..7d669eb34d336e3366ce46b108df2341e87fac6e 100644 (file)
 #include "util.h"
 #include "metadata.h"
 
+namespace ASDCP {
+       namespace JP2K {
+               class PictureDescriptor;
+       }
+}
+
 namespace libdcp
 {
 
@@ -57,8 +63,6 @@ public:
        virtual void create (std::vector<boost::filesystem::path> const &) {}
        virtual void create (boost::function<boost::filesystem::path (int)>) {}
        
-       bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
-
        Size size () const {
                return _size;
        }
@@ -76,6 +80,10 @@ protected:
                uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
                ) const;
 
+       bool descriptor_equals (
+               ASDCP::JP2K::PictureDescriptor const & a, ASDCP::JP2K::PictureDescriptor const & b, boost::function<void (NoteType, std::string)>
+               ) const;
+
        /** picture size in pixels */
        Size _size;
 
index 433659f49fe697e2b87d5b01696d7ebe290ba8dc..2490fca0663bfd130f9a7939a950c7eeb70d74aa 100644 (file)
@@ -33,7 +33,30 @@ using namespace libdcp;
 bool
 StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
 {
-       if (!PictureAsset::equals (other, opt, note)) {
+       if (!MXFAsset::equals (other, opt, note)) {
+               return false;
+       }
+
+       ASDCP::JP2K::MXFSReader reader_A;
+       if (ASDCP_FAILURE (reader_A.OpenRead (path().string().c_str()))) {
+               boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string()));
+       }
+       
+       ASDCP::JP2K::MXFSReader reader_B;
+       if (ASDCP_FAILURE (reader_B.OpenRead (other->path().string().c_str()))) {
+               boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string()));
+       }
+       
+       ASDCP::JP2K::PictureDescriptor desc_A;
+       if (ASDCP_FAILURE (reader_A.FillPictureDescriptor (desc_A))) {
+               boost::throw_exception (DCPReadError ("could not read video MXF information"));
+       }
+       ASDCP::JP2K::PictureDescriptor desc_B;
+       if (ASDCP_FAILURE (reader_B.FillPictureDescriptor (desc_B))) {
+               boost::throw_exception (DCPReadError ("could not read video MXF information"));
+       }
+       
+       if (!descriptor_equals (desc_A, desc_B, note)) {
                return false;
        }