diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-11-29 20:57:57 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-11-29 20:57:57 +0100 |
| commit | e116649cb93e7784601c1c55b2f3c8cf32099abf (patch) | |
| tree | fa7083326332e9a0cb7c6e6795f98396b25f4f86 /src | |
| parent | 54d45efaa9913191806144d99868a6edbe8c488c (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sound_asset.cc | 12 |
1 files changed, 7 insertions, 5 deletions
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<const Asset> 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; + } } } } |
