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