yading@11: /* yading@11: * copyright (c) 2006 Michael Niedermayer yading@11: * yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #ifndef AVUTIL_CRC_H yading@11: #define AVUTIL_CRC_H yading@11: yading@11: #include yading@11: #include yading@11: #include "attributes.h" yading@11: yading@11: typedef uint32_t AVCRC; yading@11: yading@11: typedef enum { yading@11: AV_CRC_8_ATM, yading@11: AV_CRC_16_ANSI, yading@11: AV_CRC_16_CCITT, yading@11: AV_CRC_32_IEEE, yading@11: AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */ yading@11: AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */ yading@11: }AVCRCId; yading@11: yading@11: /** yading@11: * Initialize a CRC table. yading@11: * @param ctx must be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*1024 yading@11: * @param le If 1, the lowest bit represents the coefficient for the highest yading@11: * exponent of the corresponding polynomial (both for poly and yading@11: * actual CRC). yading@11: * If 0, you must swap the CRC parameter and the result of av_crc yading@11: * if you need the standard representation (can be simplified in yading@11: * most cases to e.g. bswap16): yading@11: * av_bswap32(crc << (32-bits)) yading@11: * @param bits number of bits for the CRC yading@11: * @param poly generator polynomial without the x**bits coefficient, in the yading@11: * representation as specified by le yading@11: * @param ctx_size size of ctx in bytes yading@11: * @return <0 on failure yading@11: */ yading@11: int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size); yading@11: yading@11: /** yading@11: * Get an initialized standard CRC table. yading@11: * @param crc_id ID of a standard CRC yading@11: * @return a pointer to the CRC table or NULL on failure yading@11: */ yading@11: const AVCRC *av_crc_get_table(AVCRCId crc_id); yading@11: yading@11: /** yading@11: * Calculate the CRC of a block. yading@11: * @param crc CRC of previous blocks if any or initial value for CRC yading@11: * @return CRC updated with the data from the given block yading@11: * yading@11: * @see av_crc_init() "le" parameter yading@11: */ yading@11: uint32_t av_crc(const AVCRC *ctx, uint32_t crc, yading@11: const uint8_t *buffer, size_t length) av_pure; yading@11: yading@11: #endif /* AVUTIL_CRC_H */