make usb_serial work again. Also know as "make sure arrays are allocated at their...
[kugel-rb.git] / apps / codecs / libmusepack / decoder.h
blobd65f6dcfb3113b68f623d67bfbcd766e6251a377
1 /*
2 Copyright (c) 2005, The Musepack Development Team
3 All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
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.
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.
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.
35 /// \file decoder.h
37 #ifndef _mpcdec_decoder_h_
38 #define _mpcdec_decoder_h_
40 #include "huffman.h"
41 #include "math.h"
42 #include "musepack.h"
43 #include "reader.h"
44 #include "streaminfo.h"
46 #define MPC_SUPPORT_SV456
47 #define SCF_HACK
49 enum {
50 MPC_V_MEM = 2304,
51 MPC_DECODER_MEMSIZE = 16384, // overall buffer size
54 typedef struct {
55 mpc_int16_t L [36];
56 mpc_int16_t R [36];
57 } QuantTyp;
59 typedef struct mpc_decoder_t {
60 mpc_reader *r;
62 /// @name internal state variables
63 //@{
65 mpc_uint32_t next;
66 mpc_uint32_t dword; /// currently decoded 32bit-word
67 mpc_uint32_t pos; /// bit-position within dword
68 mpc_uint32_t *Speicher; /// read-buffer
69 mpc_uint32_t Zaehler; /// actual index within read-buffer
70 mpc_uint32_t Ring;
72 mpc_uint32_t samples_to_skip;
73 mpc_uint32_t last_block_samples;
74 mpc_uint32_t FwdJumpInfo;
75 mpc_uint32_t ActDecodePos;
78 mpc_uint32_t DecodedFrames;
79 mpc_uint32_t OverallFrames;
80 mpc_uint32_t MaxDecodedFrames; // Maximum frames decoded (indicates usable seek table entries)
81 mpc_uint16_t SeekTableIndex;
82 mpc_uint32_t SeekTableCounter;
83 mpc_int32_t SampleRate; // Sample frequency
85 mpc_uint32_t StreamVersion; // version of bitstream
86 mpc_int32_t Max_Band;
87 mpc_uint32_t MPCHeaderPos; // AB: needed to support ID3v2
89 mpc_uint32_t FrameWasValid;
90 mpc_uint32_t MS_used; // MS-coding used ?
91 mpc_uint32_t TrueGaplessPresent;
93 mpc_uint32_t WordsRead; // counts amount of decoded dwords
95 // randomizer state variables
96 mpc_uint32_t __r1;
97 mpc_uint32_t __r2;
99 mpc_int8_t SCF_Index_L [32] [3];
100 mpc_int8_t SCF_Index_R [32] [3]; // holds scalefactor-indices
101 QuantTyp Q [32]; // holds quantized samples
102 mpc_int8_t Res_L [32];
103 mpc_int8_t Res_R [32]; // holds the chosen quantizer for each subband
104 #ifdef MPC_SUPPORT_SV456
105 mpc_bool_t DSCF_Flag_L [32];
106 mpc_bool_t DSCF_Flag_R [32]; // differential SCF used?
107 #endif
108 mpc_int8_t SCFI_L [32];
109 mpc_int8_t SCFI_R [32]; // describes order of transmitted SCF
110 //mpc_int32_t DSCF_Reference_L [32];
111 //mpc_int32_t DSCF_Reference_R [32]; // holds last frames SCF
112 mpc_bool_t MS_Flag[32]; // MS used?
114 mpc_uint32_t* SeekTable;
115 mpc_bool_t Use_SeekTable;
116 mpc_bool_t Use_FastSeek;
117 mpc_bool_t Use_StaticSeekTable;
118 mpc_uint8_t SeekTable_Step;
119 mpc_uint32_t Max_SeekTable_Size;
121 #ifdef MPC_FIXED_POINT
122 unsigned char SCF_shift[256];
123 #endif
125 MPC_SAMPLE_FORMAT V_L[MPC_V_MEM + 960];
126 MPC_SAMPLE_FORMAT V_R[MPC_V_MEM + 960];
127 MPC_SAMPLE_FORMAT (*Y_L)[32];
128 MPC_SAMPLE_FORMAT (*Y_R)[32];
129 MPC_SAMPLE_FORMAT SCF[256]; ///< holds adapted scalefactors (for clipping prevention)
130 //@}
132 } mpc_decoder;
134 #endif // _mpc_decoder_h