Allow some error in audio when comparing.
authorCarl Hetherington <cth@carlh.net>
Wed, 3 Oct 2012 10:00:30 +0000 (11:00 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 3 Oct 2012 10:00:30 +0000 (11:00 +0100)
src/sound_asset.cc
src/types.h
tools/dcpdiff.cc

index 9f27a894dcdc71b489a461c301609699643fc984..833d89dc8c233651b473a997eb2076549fefa8cf 100644 (file)
@@ -254,16 +254,13 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<str
                }
                
                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");
-
                        for (uint32_t i = 0; i < buffer_A.Size(); ++i) {
                                int const d = abs (buffer_A.RoData()[i] - buffer_B.RoData()[i]);
-                               if (d) {
-                                       notes.push_back ("First difference is " + lexical_cast<string> (d));
+                               if (d > opt.max_audio_sample_error) {
+                                       notes.push_back ("PCM data difference of " + lexical_cast<string> (d));
                                        return false;
                                }
                        }
-                       return false;
                }
        }
 
index 71ab797bb380ce38bb06c9d4b2a9178d26e29ee2..3acded369c90e2ec5f9a73aa179ed99a8e4ba28a 100644 (file)
@@ -86,8 +86,15 @@ extern bool operator== (Fraction const & a, Fraction const & b);
 extern bool operator!= (Fraction const & a, Fraction const & b);
        
 struct EqualityOptions {
+       EqualityOptions () 
+               : max_mean_pixel_error (0)
+               , max_std_dev_pixel_error (0)
+               , max_audio_sample_error (0)
+       {}
+
        double max_mean_pixel_error;
        double max_std_dev_pixel_error;
+       int max_audio_sample_error;
 };
 
 class Color
index 9acbfa1a6250d164e19c7aa06575943f6e6eba19..17c1ff58a504e69f9b5713ed2982a835e521d4c3 100644 (file)
@@ -84,6 +84,8 @@ main (int argc, char* argv[])
 
        options.max_mean_pixel_error = 5;
        options.max_std_dev_pixel_error = 5;
+       /* I think this is just below the LSB at 16-bits (ie the 8th most significant bit at 24-bit) */
+       options.max_audio_sample_error = 255;
 
        list<string> notes;
        bool equals = a->equals (*b, options, notes);