annotate ffmpeg/libavutil/crc.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
yading@11 3 *
yading@11 4 * This file is part of FFmpeg.
yading@11 5 *
yading@11 6 * FFmpeg is free software; you can redistribute it and/or
yading@11 7 * modify it under the terms of the GNU Lesser General Public
yading@11 8 * License as published by the Free Software Foundation; either
yading@11 9 * version 2.1 of the License, or (at your option) any later version.
yading@11 10 *
yading@11 11 * FFmpeg is distributed in the hope that it will be useful,
yading@11 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 14 * Lesser General Public License for more details.
yading@11 15 *
yading@11 16 * You should have received a copy of the GNU Lesser General Public
yading@11 17 * License along with FFmpeg; if not, write to the Free Software
yading@11 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 19 */
yading@11 20
yading@11 21 #ifndef AVUTIL_CRC_H
yading@11 22 #define AVUTIL_CRC_H
yading@11 23
yading@11 24 #include <stdint.h>
yading@11 25 #include <stddef.h>
yading@11 26 #include "attributes.h"
yading@11 27
yading@11 28 typedef uint32_t AVCRC;
yading@11 29
yading@11 30 typedef enum {
yading@11 31 AV_CRC_8_ATM,
yading@11 32 AV_CRC_16_ANSI,
yading@11 33 AV_CRC_16_CCITT,
yading@11 34 AV_CRC_32_IEEE,
yading@11 35 AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */
yading@11 36 AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */
yading@11 37 }AVCRCId;
yading@11 38
yading@11 39 /**
yading@11 40 * Initialize a CRC table.
yading@11 41 * @param ctx must be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*1024
yading@11 42 * @param le If 1, the lowest bit represents the coefficient for the highest
yading@11 43 * exponent of the corresponding polynomial (both for poly and
yading@11 44 * actual CRC).
yading@11 45 * If 0, you must swap the CRC parameter and the result of av_crc
yading@11 46 * if you need the standard representation (can be simplified in
yading@11 47 * most cases to e.g. bswap16):
yading@11 48 * av_bswap32(crc << (32-bits))
yading@11 49 * @param bits number of bits for the CRC
yading@11 50 * @param poly generator polynomial without the x**bits coefficient, in the
yading@11 51 * representation as specified by le
yading@11 52 * @param ctx_size size of ctx in bytes
yading@11 53 * @return <0 on failure
yading@11 54 */
yading@11 55 int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size);
yading@11 56
yading@11 57 /**
yading@11 58 * Get an initialized standard CRC table.
yading@11 59 * @param crc_id ID of a standard CRC
yading@11 60 * @return a pointer to the CRC table or NULL on failure
yading@11 61 */
yading@11 62 const AVCRC *av_crc_get_table(AVCRCId crc_id);
yading@11 63
yading@11 64 /**
yading@11 65 * Calculate the CRC of a block.
yading@11 66 * @param crc CRC of previous blocks if any or initial value for CRC
yading@11 67 * @return CRC updated with the data from the given block
yading@11 68 *
yading@11 69 * @see av_crc_init() "le" parameter
yading@11 70 */
yading@11 71 uint32_t av_crc(const AVCRC *ctx, uint32_t crc,
yading@11 72 const uint8_t *buffer, size_t length) av_pure;
yading@11 73
yading@11 74 #endif /* AVUTIL_CRC_H */