Public Member Functions | Private Attributes | List of all members
mcap::internal::CRC32Table< Polynomial, NumTables > Struct Template Reference

#include <crc32.hpp>

Public Member Functions

constexpr CRC32Table ()
 
constexpr uint32_t operator[] (size_t index) const
 

Private Attributes

std::array< uint32_t, 256 *NumTables > table = {}
 

Detailed Description

template<size_t Polynomial, size_t NumTables>
struct mcap::internal::CRC32Table< Polynomial, NumTables >

Compute CRC32 lookup tables as described at: https://github.com/komrad36/CRC#option-6-1-byte-tabular

An iteration of CRC computation can be performed on 8 bits of input at once. By pre-computing a table of the values of CRC(?) for all 2^8 = 256 possible byte values, during the final computation we can replace a loop over 8 bits with a single lookup in the table.

For further speedup, we can also pre-compute the values of CRC(?0) for all possible bytes when a zero byte is appended. Then we can process two bytes of input at once by computing CRC(AB) = CRC(A0) ^ CRC(B), using one lookup in the CRC(?0) table and one lookup in the CRC(?) table.

The same technique applies for any number of bytes to be processed at once, although the speed improvements diminish.

Parameters
PolynomialThe binary representation of the polynomial to use (reversed, i.e. most significant bit represents x^0).
NumTablesThe number of bytes of input that will be processed at once.

Definition at line 27 of file crc32.hpp.

Constructor & Destructor Documentation

◆ CRC32Table()

template<size_t Polynomial, size_t NumTables>
constexpr mcap::internal::CRC32Table< Polynomial, NumTables >::CRC32Table ( )
inlineconstexpr

Definition at line 32 of file crc32.hpp.

Member Function Documentation

◆ operator[]()

template<size_t Polynomial, size_t NumTables>
constexpr uint32_t mcap::internal::CRC32Table< Polynomial, NumTables >::operator[] ( size_t  index) const
inlineconstexpr

Definition at line 51 of file crc32.hpp.

Member Data Documentation

◆ table

template<size_t Polynomial, size_t NumTables>
std::array<uint32_t, 256 * NumTables> mcap::internal::CRC32Table< Polynomial, NumTables >::table = {}
private

Definition at line 29 of file crc32.hpp.


The documentation for this struct was generated from the following file:


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:31