From: <sv...@op...> - 2024-05-04 13:08:23
|
Author: sagamusix Date: Sat May 4 15:08:16 2024 New Revision: 20704 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20704 Log: [Fix] mpt/crypto is not available in library builds. Use CRC64 for sample data hashes instead. [Ref] Silence more warnings. Modified: trunk/OpenMPT/soundlib/OPL.cpp trunk/OpenMPT/test/PlaybackTest.cpp Modified: trunk/OpenMPT/soundlib/OPL.cpp ============================================================================== --- trunk/OpenMPT/soundlib/OPL.cpp Sat May 4 11:56:28 2024 (r20703) +++ trunk/OpenMPT/soundlib/OPL.cpp Sat May 4 15:08:16 2024 (r20704) @@ -370,7 +370,7 @@ if(regLo >= FNUM_LOW && regLo <= FEEDBACK_CONNECTION) return baseCh + static_cast<uint8>(reg & 0x0F); if(regLo >= AM_VIB && regLo <= WAVE_SELECT) - return baseCh + static_cast<uint8>((reg & 0x07) % 3u + ((reg & 0x1F) >> 3) * 3); + return static_cast<uint8>(baseCh + (reg & 0x07) % 3u + ((reg & 0x1F) >> 3) * 3); return 0xFF; } @@ -383,7 +383,7 @@ if(regLo >= FNUM_LOW && regLo <= FEEDBACK_CONNECTION) return (reg & 0xF0); if(regLo >= AM_VIB && regLo <= WAVE_SELECT) - return regLo + static_cast<OPL::Register>((reg & 0x07) >= 3 ? 3 : 0); + return static_cast<OPL::Register>(regLo + ((reg & 0x07) >= 3 ? 3 : 0)); return reg; } Modified: trunk/OpenMPT/test/PlaybackTest.cpp ============================================================================== --- trunk/OpenMPT/test/PlaybackTest.cpp Sat May 4 11:56:28 2024 (r20703) +++ trunk/OpenMPT/test/PlaybackTest.cpp Sat May 4 15:08:16 2024 (r20704) @@ -18,7 +18,7 @@ #include "mpt/base/bit.hpp" #include "mpt/binary/hex.hpp" -#include "mpt/crypto/hash.hpp" +#include "mpt/crc/crc.hpp" #include "mpt/io/io.hpp" #include "mpt/io/io_stdstream.hpp" #include "openmpt/base/Endian.hpp" @@ -105,8 +105,8 @@ MPT_BINARY_STRUCT(TestDataChannel, 44) -using SampleDataHashAlgorithm = mpt::crypto::hash::SHA256; -using SampleDataHash = decltype(SampleDataHashAlgorithm{}.result()); +using SampleDataHashAlgorithm = mpt::crc64_jones; +using SampleDataHash = mpt::packed<decltype(SampleDataHashAlgorithm{}.result()), mpt::endian::little>; struct PlaybackTestData @@ -411,7 +411,7 @@ "\nSample data hashes:\n"; for(SAMPLEINDEX smp = 1; smp <= header.numSamples; smp++) - output << mpt::ToCharset(mpt::Charset::UTF8, mpt::encode_hex(mpt::as_span(m_testData->sampleDataHashes[smp - 1]))) << "\t" << smp << "\n"; + output << mpt::ToCharset(mpt::Charset::UTF8, mpt::encode_hex(mpt::as_raw_memory(m_testData->sampleDataHashes[smp - 1]))) << "\t" << smp << "\n"; output << "\nChannel data:\n" "index\torder\trow\ttick\tglobalVolume\ttickLength\tchannel\tsample\tleftVol\trightVol\tsurround\tspeed\tposition\tfilterType\tfilterA0\tfilterB0\tfilterB1\tsrcMode\toplRegisters\n"; @@ -525,7 +525,7 @@ for(size_t smp = 0; smp < std::min(m_testData->sampleDataHashes.size(), other.sampleDataHashes.size()); smp++) { if(m_testData->sampleDataHashes[smp] != other.sampleDataHashes[smp]) - errors.push_back(MPT_UFORMAT("Sample hash in slot {} differs: {} vs {}")(smp + 1, mpt::encode_hex(mpt::as_span(m_testData->sampleDataHashes[smp])), mpt::encode_hex(mpt::as_span(other.sampleDataHashes[smp])))); + errors.push_back(MPT_UFORMAT("Sample hash in slot {} differs: {} vs {}")(smp + 1, mpt::encode_hex(mpt::as_raw_memory(m_testData->sampleDataHashes[smp])), mpt::encode_hex(mpt::as_raw_memory(other.sampleDataHashes[smp])))); } uint64 lDuration = 0, rDuration = 0; @@ -675,7 +675,9 @@ const auto s = std::move(ss).str(); hasher.process(mpt::byte_cast<mpt::const_byte_span>(mpt::as_span(s))); } - testData.sampleDataHashes.push_back(hasher.result()); + SampleDataHash result; + result.set(hasher.result()); + testData.sampleDataHashes.push_back(result); } for(const auto &song : GetAllSubSongs()) |