Improved error messages; better equals() with corrupted MXFs.
authorCarl Hetherington <cth@carlh.net>
Wed, 27 May 2015 09:24:22 +0000 (10:24 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 27 May 2015 09:24:22 +0000 (10:24 +0100)
src/stereo_picture_frame.cc
src/stereo_picture_mxf.cc

index ac7d7bf19acd8095eb1fc5da12f0a7026018dd85..3ee08303f42f25c7512cadb8b288d191a616d523 100644 (file)
@@ -24,6 +24,7 @@
 #include "colour_conversion.h"
 #include "AS_DCP.h"
 #include "KM_fileio.h"
+#include "compose.hpp"
 #include <openjpeg.h>
 
 #define DCI_GAMMA 2.6
@@ -48,7 +49,7 @@ StereoPictureFrame::StereoPictureFrame (boost::filesystem::path mxf_path, int n)
        _buffer = new ASDCP::JP2K::SFrameBuffer (4 * Kumu::Megabyte);
 
        if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer))) {
-               boost::throw_exception (DCPReadError ("could not read video frame"));
+               boost::throw_exception (DCPReadError (String::compose ("could not read video frame %1 of %2", n, mxf_path.string())));
        }
 }
 
index e68921e3f9e9a605b80011deab3104fd5b9b610a..2ca007620b37335196e905c5a6823e7f80daf67a 100644 (file)
@@ -110,8 +110,18 @@ StereoPictureMXF::equals (shared_ptr<const Asset> other, EqualityOptions opt, No
        DCP_ASSERT (other_picture);
 
        for (int i = 0; i < _intrinsic_duration; ++i) {
-               shared_ptr<const StereoPictureFrame> frame_A = get_frame (i);
-               shared_ptr<const StereoPictureFrame> frame_B = other_picture->get_frame (i);
+               shared_ptr<const StereoPictureFrame> frame_A;
+               shared_ptr<const StereoPictureFrame> frame_B;
+               try {
+                       frame_A = get_frame (i);
+                       frame_B = other_picture->get_frame (i);
+               } catch (DCPReadError& e) {
+                       /* If there was a problem reading the frame data we'll just assume
+                          the two frames are not equal.
+                       */
+                       note (DCP_ERROR, e.what ());
+                       return false;
+               }
                
                if (!frame_buffer_equals (
                            i, opt, note,