From aa81915df29d59ac69276a23ce68e599cae64e70 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 3 Oct 2012 11:00:30 +0100 Subject: Allow some error in audio when comparing. --- src/sound_asset.cc | 7 ++----- src/types.h | 7 +++++++ tools/dcpdiff.cc | 2 ++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 9f27a894..833d89dc 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -254,16 +254,13 @@ SoundAsset::equals (shared_ptr other, EqualityOptions opt, list(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 (d)); + if (d > opt.max_audio_sample_error) { + notes.push_back ("PCM data difference of " + lexical_cast (d)); return false; } } - return false; } } diff --git a/src/types.h b/src/types.h index 71ab797b..3acded36 100644 --- a/src/types.h +++ b/src/types.h @@ -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 diff --git a/tools/dcpdiff.cc b/tools/dcpdiff.cc index 9acbfa1a..17c1ff58 100644 --- a/tools/dcpdiff.cc +++ b/tools/dcpdiff.cc @@ -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 notes; bool equals = a->equals (*b, options, notes); -- cgit v1.2.3