/*1* copyright (c) 2006 Michael Niedermayer <[email protected]>2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920#ifndef AVUTIL_CRC_H21#define AVUTIL_CRC_H2223#include <stdint.h>24#include <stddef.h>25#include "attributes.h"26#include "version.h"2728/**29* @defgroup lavu_crc32 CRC3230* @ingroup lavu_crypto31* @{32*/3334typedef uint32_t AVCRC;3536typedef enum {37AV_CRC_8_ATM,38AV_CRC_16_ANSI,39AV_CRC_16_CCITT,40AV_CRC_32_IEEE,41AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */42AV_CRC_16_ANSI_LE, /*< reversed bitorder version of AV_CRC_16_ANSI */43#if FF_API_CRC_BIG_TABLE44AV_CRC_24_IEEE = 12,45#else46AV_CRC_24_IEEE,47#endif /* FF_API_CRC_BIG_TABLE */48AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */49}AVCRCId;5051/**52* Initialize a CRC table.53* @param ctx must be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*102454* @param le If 1, the lowest bit represents the coefficient for the highest55* exponent of the corresponding polynomial (both for poly and56* actual CRC).57* If 0, you must swap the CRC parameter and the result of av_crc58* if you need the standard representation (can be simplified in59* most cases to e.g. bswap16):60* av_bswap32(crc << (32-bits))61* @param bits number of bits for the CRC62* @param poly generator polynomial without the x**bits coefficient, in the63* representation as specified by le64* @param ctx_size size of ctx in bytes65* @return <0 on failure66*/67int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size);6869/**70* Get an initialized standard CRC table.71* @param crc_id ID of a standard CRC72* @return a pointer to the CRC table or NULL on failure73*/74const AVCRC *av_crc_get_table(AVCRCId crc_id);7576/**77* Calculate the CRC of a block.78* @param crc CRC of previous blocks if any or initial value for CRC79* @return CRC updated with the data from the given block80*81* @see av_crc_init() "le" parameter82*/83uint32_t av_crc(const AVCRC *ctx, uint32_t crc,84const uint8_t *buffer, size_t length) av_pure;8586/**87* @}88*/8990#endif /* AVUTIL_CRC_H */919293