Code Coverage Report for src/decode/crc32.h


Hit Total Coverage
Lines: 2 2 100.0%
Branches: 0 0 -----

1 /*
2 * libnogg: a decoder library for Ogg Vorbis streams
3 * Copyright (c) 2014-2019 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 #ifndef NOGG_SRC_DECODE_CRC32_H
11 #define NOGG_SRC_DECODE_CRC32_H
12
13 /*************************************************************************/
14 /*************************************************************************/
15
16 /* CRC32 lookup table. For internal use only. */
17 extern uint32_t crc_table[256];
18
19 /**
20 * crc32_init: Initialize the CRC32 lookup table. This function may be
21 * safely called from multiple threads.
22 */
23 #define crc32_init INTERNAL(crc32_init)
24 extern void crc32_init(void);
25
26 /**
27 * crc32_update: Update a CRC32 value for a byte of input and return the
28 * updated value.
29 *
30 * [Parameters]
31 * crc: Current CRC32 value.
32 * byte: New input byte.
33 * [Return value]
34 * New CRC32 value.
35 */
36 static inline UNUSED CONST_FUNCTION uint32_t crc32_update(
37 uint32_t crc, uint8_t byte)
38 {
39 return (crc << 8) ^ crc_table[byte ^ (crc >> 24)];
40 }
41
42 /*************************************************************************/
43 /*************************************************************************/
44
45 #endif // NOGG_SRC_DECODE_CRC32_H