Correct order of odd and even row colours in the rowcolors command, and set colours...
[kugel-rb.git] / apps / codecs / libmusepack / decoder.h
blob9031bf29e79e2121b0d53c905aadf79eb36c3157
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 this to enable/disable support for streamversion SV4-6
47 //#define MPC_SUPPORT_SV456
49 // SCF_HACK is used to avoid possible distortion after seeking with mpc files
50 // background: scf's are coded differential in time domain. if you seek to the
51 // desired postion it might happen that the baseline is missed and the resulting
52 // scf is much too high (hissing noise). this hack uses the lowest scaling until
53 // a non-differential scf could be decoded after seek. through this hack subbands
54 // are faded out until there was at least a single non-differential scf found.
55 #define SCF_HACK
57 enum {
58 MPC_V_MEM = 2304,
59 MPC_DECODER_MEMSIZE = 16384, // overall buffer size (words)
60 MPC_SEEK_BUFFER_SIZE = 8192, // seek buffer size (words)
63 typedef struct {
64 mpc_int16_t L [36];
65 mpc_int16_t R [36];
66 } QuantTyp;
68 typedef struct mpc_decoder_t {
69 mpc_reader *r;
71 /// @name internal state variables
72 //@{
74 mpc_uint32_t next;
75 mpc_uint32_t dword; /// currently decoded 32bit-word
76 mpc_uint32_t pos; /// bit-position within dword
77 mpc_uint32_t *Speicher; /// read-buffer
78 mpc_uint32_t Zaehler; /// actual index within read-buffer
79 mpc_uint32_t Ring;
81 mpc_uint32_t samples_to_skip;
82 mpc_uint32_t last_block_samples;
83 mpc_uint32_t FwdJumpInfo;
84 mpc_uint32_t ActDecodePos;
87 mpc_uint32_t DecodedFrames;
88 mpc_uint32_t OverallFrames;
89 mpc_int32_t SampleRate; // Sample frequency
91 mpc_uint32_t StreamVersion; // version of bitstream
92 mpc_int32_t Max_Band;
93 mpc_uint32_t MPCHeaderPos; // AB: needed to support ID3v2
95 mpc_uint32_t FrameWasValid;
96 mpc_uint32_t MS_used; // MS-coding used ?
97 mpc_uint32_t TrueGaplessPresent;
99 mpc_uint32_t WordsRead; // counts amount of decoded dwords
101 // randomizer state variables
102 mpc_uint32_t __r1;
103 mpc_uint32_t __r2;
105 mpc_int8_t SCF_Index_L [32] [3];
106 mpc_int8_t SCF_Index_R [32] [3]; // holds scalefactor-indices
107 QuantTyp Q [32]; // holds quantized samples
108 mpc_int8_t Res_L [32];
109 mpc_int8_t Res_R [32]; // holds the chosen quantizer for each subband
110 #ifdef MPC_SUPPORT_SV456
111 mpc_bool_t DSCF_Flag_L [32];
112 mpc_bool_t DSCF_Flag_R [32]; // differential SCF used?
113 #endif
114 mpc_int8_t SCFI_L [32];
115 mpc_int8_t SCFI_R [32]; // describes order of transmitted SCF
116 mpc_bool_t MS_Flag[32]; // MS used?
118 mpc_uint32_t SeekTableCounter; // used to sum up skip info, if SeekTable_Step != 1
119 mpc_uint32_t MaxDecodedFrames; // Maximum frames decoded (indicates usable seek table entries)
120 mpc_uint32_t* SeekTable; // seek table itself
121 mpc_uint8_t SeekTable_Step; // 1<<SeekTable_Step = frames per table index
122 mpc_uint32_t SeekTable_Mask; // used to avoid modulo-operation in seek
124 #ifdef MPC_FIXED_POINT
125 mpc_uint8_t SCF_shift[256];
126 #endif
128 MPC_SAMPLE_FORMAT V_L[MPC_V_MEM + 960];
129 MPC_SAMPLE_FORMAT V_R[MPC_V_MEM + 960];
130 MPC_SAMPLE_FORMAT (*Y_L)[32];
131 MPC_SAMPLE_FORMAT (*Y_R)[32];
132 MPC_SAMPLE_FORMAT SCF[256]; ///< holds adapted scalefactors (for clipping prevention)
133 //@}
135 } mpc_decoder;
137 #endif // _mpc_decoder_h