From e116649cb93e7784601c1c55b2f3c8cf32099abf Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 29 Nov 2020 20:57:57 +0100 Subject: Fix terrible SoundAsset::equals() implementation. It would check individual bytes of samples to see if they differed by more than the threshold. Not only is this almost useless, but the default threshold is 256 so with the default settings it would always say that two assets of the same length (and channels, etc.) were the same, even if the sample data was different. --- src/sound_asset.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 6752d9b1..056471be 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -201,11 +201,13 @@ SoundAsset::equals (shared_ptr other, EqualityOptions opt, NoteHand } if (memcmp (frame_A->data(), frame_B->data(), frame_A->size()) != 0) { - for (int i = 0; i < frame_A->size(); ++i) { - int const d = abs (frame_A->data()[i] - frame_B->data()[i]); - if (d > opt.max_audio_sample_error) { - note (DCP_ERROR, String::compose ("PCM data difference of %1", d)); - return false; + for (int sample= 0; sample < frame_A->samples(); ++sample) { + for (int channel = 0; channel < frame_A->channels(); ++channel) { + int32_t const d = abs(frame_A->get(channel, sample) - frame_B->get(channel, sample)); + if (d > opt.max_audio_sample_error) { + note (DCP_ERROR, String::compose ("PCM data difference of %1", d)); + return false; + } } } } -- cgit v1.2.3