1 /* 2 Copyright (c) 2005-2009, The Musepack Development Team 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without 6 modification, are permitted provided that the following conditions are 7 met: 8 9 * Redistributions of source code must retain the above copyright 10 notice, this list of conditions and the following disclaimer. 11 12 * Redistributions in binary form must reproduce the above 13 copyright notice, this list of conditions and the following 14 disclaimer in the documentation and/or other materials provided 15 with the distribution. 16 17 * Neither the name of the The Musepack Development Team nor the 18 names of its contributors may be used to endorse or promote 19 products derived from this software without specific prior 20 written permission. 21 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 /// \file huffman.h 35 /// Data structures and functions for huffman coding. 36 37 #ifndef _MPCDEC_HUFFMAN_H_ 38 #define _MPCDEC_HUFFMAN_H_ 39 #ifdef WIN32 40 #pragma once 41 #endif 42 43 #include "mpc_types.h" 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 // LUT size parameter, LUT size is 1 << LUT_DEPTH 50 #define LUT_DEPTH 6 51 52 /// Huffman table entry. 53 typedef struct mpc_huffman_t { 54 mpc_uint16_t Code; 55 mpc_uint8_t Length; 56 mpc_int8_t Value; 57 } mpc_huffman; 58 59 /// Huffman LUT entry. 60 typedef struct mpc_huff_lut_t { 61 mpc_uint8_t Length; 62 mpc_int8_t Value; 63 } mpc_huff_lut; 64 65 /// Type used for huffman LUT decoding 66 typedef struct mpc_lut_data_t { 67 mpc_huffman const * const table; 68 mpc_huff_lut lut[1 << LUT_DEPTH]; 69 } mpc_lut_data; 70 71 /// Type used for canonical huffman decoding 72 typedef struct mpc_can_data_t { 73 mpc_huffman const * const table; 74 mpc_int8_t const * const sym; 75 mpc_huff_lut lut[1 << LUT_DEPTH]; 76 } mpc_can_data; 77 78 void huff_init_lut(const int bits); 79 80 #ifdef __cplusplus 81 } 82 #endif 83 #endif 84