mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Also move colorutil.cpp/h linking build fix experiment Delete a bunch of unused CMakeLists.txt files CMakeLists.txt linking fix Don't include NativeApp.h from any headers. Android.mk buildfix Half of the UWP fix Buildfix Minor project file cleanup Buildfixes Guess what? More buildfixes!
37 lines
852 B
C++
37 lines
852 B
C++
#include <cstdint>
|
|
#include "Common/Data/Hash/Hash.h"
|
|
|
|
namespace hash {
|
|
|
|
// Implementation from Wikipedia
|
|
#define MOD_ADLER 65521
|
|
// data: Pointer to the data to be summed; len is in bytes
|
|
uint32_t Adler32(const uint8_t *data, size_t len) {
|
|
uint32_t a = 1, b = 0;
|
|
while (len) {
|
|
size_t tlen = len > 5550 ? 5550 : len;
|
|
len -= tlen;
|
|
do {
|
|
a += *data++;
|
|
b += a;
|
|
} while (--tlen);
|
|
|
|
a = (a & 0xffff) + (a >> 16) * (65536 - MOD_ADLER);
|
|
b = (b & 0xffff) + (b >> 16) * (65536 - MOD_ADLER);
|
|
}
|
|
|
|
// It can be shown that a <= 0x1013a here, so a single subtract will do.
|
|
if (a >= MOD_ADLER) {
|
|
a -= MOD_ADLER;
|
|
}
|
|
|
|
// It can be shown that b can reach 0xfff87 here.
|
|
b = (b & 0xffff) + (b >> 16) * (65536 - MOD_ADLER);
|
|
|
|
if (b >= MOD_ADLER) {
|
|
b -= MOD_ADLER;
|
|
}
|
|
return (b << 16) | a;
|
|
}
|
|
|
|
} // namespace hash
|