Code Coverage Report for src/decode/crc32.c


Hit Total Coverage
Lines: 7 7 100.0%
Branches: 54 54 100.0%

1 /*
2 * libnogg: a decoder library for Ogg Vorbis streams
3 * Copyright (c) 2014-2023 Andrew Church <achurch@achurch.org>
4 *
5 * This software may be copied and redistributed under certain conditions;
6 * see the file "COPYING" in the source code distribution for details.
7 * NO WARRANTY is provided with this software.
8 */
9
10 #include "include/nogg.h"
11 #include "src/common.h"
12 #include "src/decode/crc32.h"
13
14 /*************************************************************************/
15 /*************************************************************************/
16
17 #define CRC32_POLY 0x04c11db7 // From the Vorbis specification.
18
19 uint32_t crc_table[256];
20
21 /*-----------------------------------------------------------------------*/
22
23 void crc32_init(void)
24 {
25 (18/18) for (uint32_t i = 0; i < 256; i++) {
26 uint32_t s = i << 24;
27 (18/18) for (int j = 0; j < 8; j++) {
28 (18/18) s = (s << 1) ^ (s >= (UINT32_C(1)<<31) ? CRC32_POLY : 0);
29 }
30 crc_table[i] = s;
31 }
32 }
33
34 /*************************************************************************/
35 /*************************************************************************/