SDL Library

Dependents:   H261_decoder

Committer:
miruga27
Date:
Thu Sep 22 00:03:09 2016 +0000
Revision:
0:7fb6877b5d7c
SDL

Who changed what in which revision?

UserRevisionLine numberNew contents of line
miruga27 0:7fb6877b5d7c 1 /*
miruga27 0:7fb6877b5d7c 2 Simple DirectMedia Layer
miruga27 0:7fb6877b5d7c 3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
miruga27 0:7fb6877b5d7c 4
miruga27 0:7fb6877b5d7c 5 This software is provided 'as-is', without any express or implied
miruga27 0:7fb6877b5d7c 6 warranty. In no event will the authors be held liable for any damages
miruga27 0:7fb6877b5d7c 7 arising from the use of this software.
miruga27 0:7fb6877b5d7c 8
miruga27 0:7fb6877b5d7c 9 Permission is granted to anyone to use this software for any purpose,
miruga27 0:7fb6877b5d7c 10 including commercial applications, and to alter it and redistribute it
miruga27 0:7fb6877b5d7c 11 freely, subject to the following restrictions:
miruga27 0:7fb6877b5d7c 12
miruga27 0:7fb6877b5d7c 13 1. The origin of this software must not be misrepresented; you must not
miruga27 0:7fb6877b5d7c 14 claim that you wrote the original software. If you use this software
miruga27 0:7fb6877b5d7c 15 in a product, an acknowledgment in the product documentation would be
miruga27 0:7fb6877b5d7c 16 appreciated but is not required.
miruga27 0:7fb6877b5d7c 17 2. Altered source versions must be plainly marked as such, and must not be
miruga27 0:7fb6877b5d7c 18 misrepresented as being the original software.
miruga27 0:7fb6877b5d7c 19 3. This notice may not be removed or altered from any source distribution.
miruga27 0:7fb6877b5d7c 20 */
miruga27 0:7fb6877b5d7c 21
miruga27 0:7fb6877b5d7c 22 /**
miruga27 0:7fb6877b5d7c 23 * \file SDL_test_crc32.h
miruga27 0:7fb6877b5d7c 24 *
miruga27 0:7fb6877b5d7c 25 * Include file for SDL test framework.
miruga27 0:7fb6877b5d7c 26 *
miruga27 0:7fb6877b5d7c 27 * This code is a part of the SDL2_test library, not the main SDL library.
miruga27 0:7fb6877b5d7c 28 */
miruga27 0:7fb6877b5d7c 29
miruga27 0:7fb6877b5d7c 30 /*
miruga27 0:7fb6877b5d7c 31
miruga27 0:7fb6877b5d7c 32 Implements CRC32 calculations (default output is Perl String::CRC32 compatible).
miruga27 0:7fb6877b5d7c 33
miruga27 0:7fb6877b5d7c 34 */
miruga27 0:7fb6877b5d7c 35
miruga27 0:7fb6877b5d7c 36 #ifndef _SDL_test_crc32_h
miruga27 0:7fb6877b5d7c 37 #define _SDL_test_crc32_h
miruga27 0:7fb6877b5d7c 38
miruga27 0:7fb6877b5d7c 39 #include "begin_code.h"
miruga27 0:7fb6877b5d7c 40 /* Set up for C function definitions, even when using C++ */
miruga27 0:7fb6877b5d7c 41 #ifdef __cplusplus
miruga27 0:7fb6877b5d7c 42 extern "C" {
miruga27 0:7fb6877b5d7c 43 #endif
miruga27 0:7fb6877b5d7c 44
miruga27 0:7fb6877b5d7c 45
miruga27 0:7fb6877b5d7c 46 /* ------------ Definitions --------- */
miruga27 0:7fb6877b5d7c 47
miruga27 0:7fb6877b5d7c 48 /* Definition shared by all CRC routines */
miruga27 0:7fb6877b5d7c 49
miruga27 0:7fb6877b5d7c 50 #ifndef CrcUint32
miruga27 0:7fb6877b5d7c 51 #define CrcUint32 unsigned int
miruga27 0:7fb6877b5d7c 52 #endif
miruga27 0:7fb6877b5d7c 53 #ifndef CrcUint8
miruga27 0:7fb6877b5d7c 54 #define CrcUint8 unsigned char
miruga27 0:7fb6877b5d7c 55 #endif
miruga27 0:7fb6877b5d7c 56
miruga27 0:7fb6877b5d7c 57 #ifdef ORIGINAL_METHOD
miruga27 0:7fb6877b5d7c 58 #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */
miruga27 0:7fb6877b5d7c 59 #else
miruga27 0:7fb6877b5d7c 60 #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */
miruga27 0:7fb6877b5d7c 61 #endif
miruga27 0:7fb6877b5d7c 62
miruga27 0:7fb6877b5d7c 63 /**
miruga27 0:7fb6877b5d7c 64 * Data structure for CRC32 (checksum) computation
miruga27 0:7fb6877b5d7c 65 */
miruga27 0:7fb6877b5d7c 66 typedef struct {
miruga27 0:7fb6877b5d7c 67 CrcUint32 crc32_table[256]; /* CRC table */
miruga27 0:7fb6877b5d7c 68 } SDLTest_Crc32Context;
miruga27 0:7fb6877b5d7c 69
miruga27 0:7fb6877b5d7c 70 /* ---------- Function Prototypes ------------- */
miruga27 0:7fb6877b5d7c 71
miruga27 0:7fb6877b5d7c 72 /**
miruga27 0:7fb6877b5d7c 73 * /brief Initialize the CRC context
miruga27 0:7fb6877b5d7c 74 *
miruga27 0:7fb6877b5d7c 75 * Note: The function initializes the crc table required for all crc calculations.
miruga27 0:7fb6877b5d7c 76 *
miruga27 0:7fb6877b5d7c 77 * /param crcContext pointer to context variable
miruga27 0:7fb6877b5d7c 78 *
miruga27 0:7fb6877b5d7c 79 * /returns 0 for OK, -1 on error
miruga27 0:7fb6877b5d7c 80 *
miruga27 0:7fb6877b5d7c 81 */
miruga27 0:7fb6877b5d7c 82 int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext);
miruga27 0:7fb6877b5d7c 83
miruga27 0:7fb6877b5d7c 84
miruga27 0:7fb6877b5d7c 85 /**
miruga27 0:7fb6877b5d7c 86 * /brief calculate a crc32 from a data block
miruga27 0:7fb6877b5d7c 87 *
miruga27 0:7fb6877b5d7c 88 * /param crcContext pointer to context variable
miruga27 0:7fb6877b5d7c 89 * /param inBuf input buffer to checksum
miruga27 0:7fb6877b5d7c 90 * /param inLen length of input buffer
miruga27 0:7fb6877b5d7c 91 * /param crc32 pointer to Uint32 to store the final CRC into
miruga27 0:7fb6877b5d7c 92 *
miruga27 0:7fb6877b5d7c 93 * /returns 0 for OK, -1 on error
miruga27 0:7fb6877b5d7c 94 *
miruga27 0:7fb6877b5d7c 95 */
miruga27 0:7fb6877b5d7c 96 int SDLTest_crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
miruga27 0:7fb6877b5d7c 97
miruga27 0:7fb6877b5d7c 98 /* Same routine broken down into three steps */
miruga27 0:7fb6877b5d7c 99 int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32);
miruga27 0:7fb6877b5d7c 100 int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32);
miruga27 0:7fb6877b5d7c 101 int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32);
miruga27 0:7fb6877b5d7c 102
miruga27 0:7fb6877b5d7c 103
miruga27 0:7fb6877b5d7c 104 /**
miruga27 0:7fb6877b5d7c 105 * /brief clean up CRC context
miruga27 0:7fb6877b5d7c 106 *
miruga27 0:7fb6877b5d7c 107 * /param crcContext pointer to context variable
miruga27 0:7fb6877b5d7c 108 *
miruga27 0:7fb6877b5d7c 109 * /returns 0 for OK, -1 on error
miruga27 0:7fb6877b5d7c 110 *
miruga27 0:7fb6877b5d7c 111 */
miruga27 0:7fb6877b5d7c 112
miruga27 0:7fb6877b5d7c 113 int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext);
miruga27 0:7fb6877b5d7c 114
miruga27 0:7fb6877b5d7c 115
miruga27 0:7fb6877b5d7c 116 /* Ends C function definitions when using C++ */
miruga27 0:7fb6877b5d7c 117 #ifdef __cplusplus
miruga27 0:7fb6877b5d7c 118 }
miruga27 0:7fb6877b5d7c 119 #endif
miruga27 0:7fb6877b5d7c 120 #include "close_code.h"
miruga27 0:7fb6877b5d7c 121
miruga27 0:7fb6877b5d7c 122 #endif /* _SDL_test_crc32_h */
miruga27 0:7fb6877b5d7c 123
miruga27 0:7fb6877b5d7c 124 /* vi: set ts=4 sw=4 expandtab: */