Mercurial > mplayer.hg
annotate libmpcodecs/vqf.h @ 29385:f9ae25067fe0
Fix 24bit audio playback.
The reordering channels code had reoccurring bug
where in switch(samplesize) block the
case 3 (3 bytes) doesn't end with break;
leading to execution of the next case 4 too.
This mangles the already processed data and
causes massive memory corruption.
author | iive |
---|---|
date | Sun, 19 Jul 2009 09:55:29 +0000 |
parents | 0f1b5b68af32 |
children |
rev | line source |
---|---|
14276 | 1 /* (c)Copyright 1996-2000 NTT Cyber Space Laboratories */ |
2 /* Released on 2000.05.22 by N. Iwakami */ | |
3 /* Modified on 2000.05.25 by N. Iwakami */ | |
4 /* Released on 2000.09.06 by N. Iwakami */ | |
5 | |
6 // Modified for MPlayer on 2004.12.29 | |
7 | |
26029 | 8 #ifndef MPLAYER_VQF_H |
9 #define MPLAYER_VQF_H | |
14276 | 10 |
26147
41652035483c
Add necessary header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
11 #include <stdio.h> |
41652035483c
Add necessary header #includes to fix 'make checkheaders'.
diego
parents:
26029
diff
changeset
|
12 |
14276 | 13 #ifdef _MSC_VER |
14 # ifdef DLL_MODULE | |
15 # define DllPort __declspec( dllexport ) | |
16 # else | |
17 # define DllPort __declspec( dllimport ) | |
18 # endif | |
19 #else | |
20 # define DllPort | |
21 #endif | |
22 | |
23 #ifdef __cplusplus | |
24 extern "C" { // only need to import/export C interface if used by C++ source code | |
25 #endif | |
26 | |
27 /************************/ | |
28 /*** General settings ***/ | |
29 /************************/ | |
30 /* Initialization error code */ | |
31 enum INIT_ERROR_CODE { | |
32 TVQ_NO_ERROR = 0, // no error | |
33 TVQ_ERROR, // general | |
34 TVQ_ERROR_VERSION, // wrong version | |
35 TVQ_ERROR_CHANNEL, // channel setting error | |
36 TVQ_ERROR_MODE, // wrong coding mode | |
37 TVQ_ERROR_PARAM, // inner parameter setting error | |
38 TVQ_ERROR_N_CAN, // wrong number of VQ pre-selection candidates, used only in encoder | |
39 }; | |
40 | |
41 /* version ID */ | |
42 #define TVQ_UNKNOWN_VERSION -1 | |
43 #define V2 0 | |
44 #define V2PP 1 | |
45 | |
46 #define N_VERSIONS 2 | |
47 | |
48 /* window types */ | |
49 enum WINDOW_TYPE { | |
50 ONLY_LONG_WINDOW = 0, | |
51 LONG_SHORT_WINDOW, | |
52 ONLY_SHORT_WINDOW, | |
53 SHORT_LONG_WINDOW, | |
54 SHORT_MEDIUM_WINDOW, | |
55 MEDIUM_LONG_WINDOW, | |
56 LONG_MEDIUM_WINDOW, | |
57 MEDIUM_SHORT_WINDOW, | |
58 ONLY_MEDIUM_WINDOW, | |
59 }; | |
60 | |
61 /* block types */ | |
62 enum BLOCK_TYPE { | |
63 BLK_SHORT = 0, | |
64 BLK_MEDIUM, | |
65 BLK_LONG, | |
66 BLK_PPC, | |
67 }; | |
68 #define N_BTYPE 3 // number of block types | |
69 #define N_INTR_TYPE 4 // number of interleave types, enum BLOCK_TYPE is commonly used for detecting interleave types. | |
70 | |
71 /* maximum number of channels */ | |
72 #define N_CH_MAX 2 | |
73 | |
74 /* type definition of code information interface */ | |
75 typedef struct { | |
76 /* block type */ | |
77 int w_type; | |
78 int btype; | |
79 | |
80 /* FBC info */ | |
81 int *segment_sw[ N_CH_MAX ]; | |
82 int *band_sw[ N_CH_MAX ]; | |
83 int *fg_intensity[ N_CH_MAX ]; | |
84 | |
85 /* VQ info */ | |
86 int *wvq; | |
87 | |
88 /* BSE info */ | |
89 int *fw; | |
90 int *fw_alf; | |
91 | |
92 /* gain info */ | |
93 int *pow; | |
94 | |
95 /* LSP info */ | |
96 int *lsp[ N_CH_MAX ]; | |
97 | |
98 /* PPC info */ | |
99 int pit[ N_CH_MAX ]; | |
100 int *pls; | |
101 int pgain[ N_CH_MAX ]; | |
102 | |
103 /* EBC info */ | |
104 int *bc[ N_CH_MAX ]; | |
105 | |
106 void *manager; | |
107 } INDEX; | |
108 | |
109 /***********************************************/ | |
110 /*** Definitions about program configuration ***/ | |
111 /***********************************************/ | |
112 /* type definition of tvqConfInfoSubBlock */ | |
113 typedef struct { | |
114 int sf_sz; // subframe size | |
115 int nsf; // number of subframes | |
116 int ndiv; // number of division of weighted interleave vector quantization | |
117 int ncrb; // number of Bark-scale subbands | |
118 int fw_ndiv; // number of division of BSE VQ | |
119 int fw_nbit; // number of bits for BSE VQ | |
120 int nsubg; // number of sub-blocks for gain coding | |
121 int ppc_enable; // PPC switch | |
122 int ebc_enable; // EBC switch | |
123 int ebc_crb_base; // EBC base band | |
124 int ebc_bits; // EBC bits | |
125 int fbc_enable; // FBC switch | |
126 int fbc_n_segment; // FBC number of segments | |
127 int fbc_nband; // FBC number of subbands | |
128 int *fbc_crb_tbl; // FBC subband table | |
129 } tvqConfInfoSubBlock; | |
130 | |
131 /* type definition of tvqConfInfo */ | |
132 typedef struct { | |
133 /* frame configuration */ | |
134 int N_CH; | |
135 /* window type coding */ | |
136 int BITS_WTYPE; | |
137 /* LSP coding */ | |
138 int LSP_BIT0; | |
139 int LSP_BIT1; | |
140 int LSP_BIT2; | |
141 int LSP_SPLIT; | |
142 /* Bark-scale envelope coding */ | |
143 int FW_ARSW_BITS; | |
144 /* gain coding */ | |
145 int GAIN_BITS; | |
146 int SUB_GAIN_BITS; | |
147 /* pitch excitation */ | |
148 int N_DIV_P; | |
149 int BASF_BIT; | |
150 int PGAIN_BIT; | |
151 | |
152 /* block type dependent parameters */ | |
153 tvqConfInfoSubBlock cfg[N_BTYPE]; | |
154 | |
155 } tvqConfInfo; | |
156 | |
157 | |
158 /*************************************************/ | |
159 /*** Definitions about TwinVQ bitstream header ***/ | |
160 /*************************************************/ | |
17012 | 161 //#include "declib_src/tvq_hdr.h" |
14276 | 162 //#ifndef BUFSIZ |
163 //#define BUFSIZ 1024 | |
164 //#endif | |
165 | |
166 #define KEYWORD_BYTES 4 | |
167 #define VERSION_BYTES 8 | |
168 #define ELEM_BYTES sizeof(unsigned long) | |
169 | |
170 | |
171 /* | |
172 */ | |
173 typedef struct { | |
174 char ID[KEYWORD_BYTES+VERSION_BYTES+1]; | |
175 int size; | |
176 /* Common Chunk */ | |
177 int channelMode; /* channel mode (mono:0/stereo:1) */ | |
178 int bitRate; /* bit rate (kbit/s) */ | |
179 int samplingRate; /* sampling rate (44.1 kHz -> 44) */ | |
180 int securityLevel; /* security level (always 0) */ | |
181 /* Text Chunk */ | |
182 char Name[BUFSIZ]; | |
183 char Comt[BUFSIZ]; | |
184 char Auth[BUFSIZ]; | |
185 char Cpyr[BUFSIZ]; | |
186 char File[BUFSIZ]; | |
187 char Extr[BUFSIZ]; // add by OKAMOTO 99.12.21 | |
188 /* Data size chunk*/ | |
189 int Dsiz; | |
190 } headerInfo; | |
191 | |
192 // TwinVQ decoder initialization/termination functions | |
193 //DllPort int TvqInitialize( headerInfo *setupInfo, INDEX *index, int dispErrorMessageBox ); | |
194 //DllPort void TvqTerminate( INDEX *index ); | |
195 //DllPort void TvqGetVectorInfo(int *bits0[], int *bits1[]); | |
29212
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
26147
diff
changeset
|
196 //DllPort void TvqResetFrameCounter(void); |
14276 | 197 |
198 // TwinVQ decoder function | |
199 //DllPort void TvqDecodeFrame(INDEX *indexp, float out[]); | |
200 //DllPort int TvqWtypeToBtype( int w_type, int *btype ); | |
201 //DllPort void TvqUpdateVectorInfo(int varbits, int *ndiv, int bits0[], int bits1[]); | |
202 //DllPort void TvqSetFrameCounter( int position ); | |
203 | |
204 // TwinVQ query functions | |
205 //DllPort int TvqCheckVersion(char *versionID); | |
206 //DllPort void TvqGetSetupInfo(headerInfo *setupInfo); // setup information | |
207 //DllPort void TvqGetConfInfo(tvqConfInfo *cf); // configuration information | |
29212
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
26147
diff
changeset
|
208 //DllPort int TvqGetFrameSize(void); // frame size |
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
26147
diff
changeset
|
209 //DllPort int TvqGetNumChannels(void); // number of channels |
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
26147
diff
changeset
|
210 //DllPort int TvqGetBitRate(void); // total bitrate |
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
26147
diff
changeset
|
211 //DllPort float TvqGetSamplingRate(void); // sampling rate |
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
26147
diff
changeset
|
212 //DllPort int TvqGetNumFixedBitsPerFrame(void); // number of fixed bits per frame |
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
26147
diff
changeset
|
213 //DllPort int TvqGetNumFrames(void); // number of decoded frame |
14276 | 214 //DllPort int TvqGetModuleVersion( char* versionString ); |
215 | |
216 #ifdef V2PLUS_SUPPORT | |
217 // TwinVQ FB coding tool control | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
218 DllPort void TvqFbCountUsedBits(int nbit); // count number of used bits |
29212
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
26147
diff
changeset
|
219 DllPort float TvqGetFbCurrentBitrate(void); // query average bitrate for the tool |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
220 DllPort int TvqGetFbTotalBits(void); // query total number of used bits |
14276 | 221 #endif |
222 | |
223 #ifdef __cplusplus | |
224 } | |
225 #endif | |
226 | |
227 | |
26029 | 228 #endif /* MPLAYER_VQF_H */ |