00001 /* 00002 Copyright (c) 2005, The Musepack Development Team 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are 00007 met: 00008 00009 * Redistributions of source code must retain the above copyright 00010 notice, this list of conditions and the following disclaimer. 00011 00012 * Redistributions in binary form must reproduce the above 00013 copyright notice, this list of conditions and the following 00014 disclaimer in the documentation and/or other materials provided 00015 with the distribution. 00016 00017 * Neither the name of the The Musepack Development Team nor the 00018 names of its contributors may be used to endorse or promote 00019 products derived from this software without specific prior 00020 written permission. 00021 00022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00025 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00026 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 00036 00037 #ifndef _mpcdec_decoder_h_ 00038 #define _mpcdec_decoder_h_ 00039 00040 #include "huffman.h" 00041 #include "math.h" 00042 #include "mpcdec.h" 00043 #include "reader.h" 00044 #include "streaminfo.h" 00045 00046 enum { 00047 MPC_V_MEM = 2304, 00048 MPC_DECODER_MEMSIZE = 16384, // overall buffer size 00049 }; 00050 00051 typedef struct { 00052 mpc_int32_t L [36]; 00053 mpc_int32_t R [36]; 00054 } QuantTyp; 00055 00056 typedef struct mpc_decoder_t { 00057 mpc_reader *r; 00058 00060 00061 00062 mpc_uint32_t dword; 00063 mpc_uint32_t pos; 00064 mpc_uint32_t Speicher[MPC_DECODER_MEMSIZE]; 00065 mpc_uint32_t Zaehler; 00066 00067 mpc_uint32_t samples_to_skip; 00068 00069 mpc_uint32_t FwdJumpInfo; 00070 mpc_uint32_t ActDecodePos; 00071 mpc_uint32_t FrameWasValid; 00072 00073 mpc_uint32_t DecodedFrames; 00074 mpc_uint32_t OverallFrames; 00075 mpc_int32_t SampleRate; // Sample frequency 00076 00077 mpc_uint32_t StreamVersion; // version of bitstream 00078 mpc_uint32_t MS_used; // MS-coding used ? 00079 mpc_int32_t Max_Band; 00080 mpc_uint32_t MPCHeaderPos; // AB: needed to support ID3v2 00081 mpc_uint32_t LastValidSamples; 00082 mpc_uint32_t TrueGaplessPresent; 00083 00084 mpc_uint32_t EQ_activated; 00085 00086 mpc_uint32_t WordsRead; // counts amount of decoded dwords 00087 00088 // randomizer state variables 00089 mpc_uint32_t __r1; 00090 mpc_uint32_t __r2; 00091 00092 mpc_uint32_t Q_bit [32]; 00093 mpc_uint32_t Q_res [32][16]; 00094 00095 // huffman table stuff 00096 HuffmanTyp HuffHdr [10]; 00097 HuffmanTyp HuffSCFI [ 4]; 00098 HuffmanTyp HuffDSCF [16]; 00099 HuffmanTyp* HuffQ [2] [8]; 00100 00101 HuffmanTyp HuffQ1 [2] [3*3*3]; 00102 HuffmanTyp HuffQ2 [2] [5*5]; 00103 HuffmanTyp HuffQ3 [2] [ 7]; 00104 HuffmanTyp HuffQ4 [2] [ 9]; 00105 HuffmanTyp HuffQ5 [2] [15]; 00106 HuffmanTyp HuffQ6 [2] [31]; 00107 HuffmanTyp HuffQ7 [2] [63]; 00108 const HuffmanTyp* SampleHuff [18]; 00109 HuffmanTyp SCFI_Bundle [ 8]; 00110 HuffmanTyp DSCF_Entropie [13]; 00111 HuffmanTyp Region_A [16]; 00112 HuffmanTyp Region_B [ 8]; 00113 HuffmanTyp Region_C [ 4]; 00114 00115 HuffmanTyp Entropie_1 [ 3]; 00116 HuffmanTyp Entropie_2 [ 5]; 00117 HuffmanTyp Entropie_3 [ 7]; 00118 HuffmanTyp Entropie_4 [ 9]; 00119 HuffmanTyp Entropie_5 [15]; 00120 HuffmanTyp Entropie_6 [31]; 00121 HuffmanTyp Entropie_7 [63]; 00122 00123 mpc_int32_t SCF_Index_L [32] [3]; 00124 mpc_int32_t SCF_Index_R [32] [3]; // holds scalefactor-indices 00125 QuantTyp Q [32]; // holds quantized samples 00126 mpc_int32_t Res_L [32]; 00127 mpc_int32_t Res_R [32]; // holds the chosen quantizer for each subband 00128 mpc_int32_t DSCF_Flag_L [32]; 00129 mpc_int32_t DSCF_Flag_R [32]; // differential SCF used? 00130 mpc_int32_t SCFI_L [32]; 00131 mpc_int32_t SCFI_R [32]; // describes order of transmitted SCF 00132 mpc_int32_t DSCF_Reference_L [32]; 00133 mpc_int32_t DSCF_Reference_R [32]; // holds last frames SCF 00134 mpc_int32_t MS_Flag[32]; // MS used? 00135 #ifdef MPC_FIXED_POINT 00136 unsigned char SCF_shift[256]; 00137 #endif 00138 00139 MPC_SAMPLE_FORMAT V_L[MPC_V_MEM + 960]; 00140 MPC_SAMPLE_FORMAT V_R[MPC_V_MEM + 960]; 00141 MPC_SAMPLE_FORMAT Y_L[36][32]; 00142 MPC_SAMPLE_FORMAT Y_R[36][32]; 00143 MPC_SAMPLE_FORMAT SCF[256]; 00144 00145 00146 } mpc_decoder; 00147 00148 #endif // _mpc_decoder_h