@@ -7,6 +7,26 @@ namespace hud::hash_algorithm
77 struct crc32
88 {
99
10+ /* *
11+ * CRC-32 polynomial
12+ * Use by ( Source : Wikipedia https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Commonly_used_and_standardized_CRCs ) :
13+ * ISO 3309 (HDLC), ANSI X3.66 (ADCCP), FIPS PUB 71, FED-STD-1003, ITU-type_t V.42, ISO/IEC/IEEE 802-3 (Ethernet), SATA, MPEG-2, PKZIP, Gzip, Bzip2, POSIX cksum,PNG, ZMODEM, many others
14+ */
15+ static constexpr u32 POLYNOMIAL = 0x04c11db7 ;
16+
17+ /* *
18+ * CRC-32 reversed polynomial
19+ * Use by ( Source : Wikipedia https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Commonly_used_and_standardized_CRCs ) :
20+ * ISO 3309 (HDLC), ANSI X3.66 (ADCCP), FIPS PUB 71, FED-STD-1003, ITU-type_t V.42, ISO/IEC/IEEE 802-3 (Ethernet), SATA, MPEG-2, PKZIP, Gzip, Bzip2, POSIX cksum,PNG, ZMODEM, many others
21+ */
22+ static constexpr u32 REFLECTED_POLYNOMIAL = 0xedb88320 ;
23+
24+ /* * LookUpTable generated with polynomial 0xedb88320 */
25+ static const u32 CRC32_LOOKUP[8 ][256 ];
26+
27+ /* * Table used for combine */
28+ static const u32 X2N_TABLE[32 ];
29+
1030 /* *
1131 * CRC32 hash based on Intel slice-by-8 algorithm
1232 * Polynomial used is 0x04C11DB7
@@ -15,14 +35,15 @@ namespace hud::hash_algorithm
1535 * @param seed The seed to use. Default is 0.
1636 * @return The CRC32 of the buffer
1737 */
18- [[nodiscard]] static HD_CORE_DLL u32 hash (const u8 *buffer, usize count, const u32 seed = 0 ) noexcept ;
38+ [[nodiscard]] static HD_CORE_DLL u32
39+ hash (const u8 *buffer, usize count, const u32 seed = 0 ) noexcept ;
1940
2041 /* *
21- * Check that the CRC32 lookup table have correct values
22- * Intent to be used only for test validation
42+ * Combine 2 crc32 hash
43+ * @param crc1 The first crc
44+ * @param crc2 The second crc
45+ * @param count_crc2 The count of bytes used to compute the crc2
2346 */
24- [[nodiscard]] static HD_CORE_DLL bool is_lookup_table_values_correct () noexcept ;
25-
2647 [[nodiscard]] static HD_CORE_DLL u32 combine (u32 crc1, u32 crc2, usize count_crc2) noexcept ;
2748 };
2849
0 commit comments