FFmpeg
Files | Typedefs | Enumerations | Functions

CRC (Cyclic Redundancy Check) hash function implementation. More...

Files

file  crc.h
 Public header for CRC hash function implementation.
 

Typedefs

typedef uint32_t AVCRC
 

Enumerations

enum  AVCRCId {
  AV_CRC_8_ATM, AV_CRC_16_ANSI, AV_CRC_16_CCITT, AV_CRC_32_IEEE,
  AV_CRC_32_IEEE_LE, AV_CRC_16_ANSI_LE, AV_CRC_24_IEEE, AV_CRC_8_EBU,
  AV_CRC_MAX
}
 

Functions

int av_crc_init (AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size)
 Initialize a CRC table. More...
 
const AVCRC * av_crc_get_table (AVCRCId crc_id)
 Get an initialized standard CRC table. More...
 
uint32_t av_crc (const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length) av_pure
 Calculate the CRC of a block. More...
 

Detailed Description

CRC (Cyclic Redundancy Check) hash function implementation.

This module supports numerous CRC polynomials, in addition to the most widely used CRC-32-IEEE. See AVCRCId for a list of available polynomials.

Function Documentation

§ av_crc()

uint32_t av_crc ( const AVCRC *  ctx,
uint32_t  crc,
const uint8_t *  buffer,
size_t  length 
)

Calculate the CRC of a block.

Parameters
crcCRC of previous blocks if any or initial value for CRC
Returns
CRC updated with the data from the given block
See also
av_crc_init() "le" parameter

§ av_crc_get_table()

const AVCRC* av_crc_get_table ( AVCRCId  crc_id)

Get an initialized standard CRC table.

Parameters
crc_idID of a standard CRC
Returns
a pointer to the CRC table or NULL on failure

§ av_crc_init()

int av_crc_init ( AVCRC *  ctx,
int  le,
int  bits,
uint32_t  poly,
int  ctx_size 
)

Initialize a CRC table.

Parameters
ctxmust be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*1024
leIf 1, the lowest bit represents the coefficient for the highest exponent of the corresponding polynomial (both for poly and actual CRC). If 0, you must swap the CRC parameter and the result of av_crc if you need the standard representation (can be simplified in most cases to e.g. bswap16): av_bswap32(crc << (32-bits))
bitsnumber of bits for the CRC
polygenerator polynomial without the x**bits coefficient, in the representation as specified by le
ctx_sizesize of ctx in bytes
Returns
<0 on failure