• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 /*
19 ------------------------------------------------------------------------------
20    PacketVideo Corp.
21    MP3 Decoder Library
22 
23    Filename: pvmp3_dec_defs.h
24 
25      Date: 09/21/2007
26 
27 ------------------------------------------------------------------------------
28  REVISION HISTORY
29 
30  Description:
31 
32 ------------------------------------------------------------------------------
33  INCLUDE DESCRIPTION
34 
35  This include file has the mp3 decoder common defines.
36 
37 ------------------------------------------------------------------------------
38 */
39 
40 /*----------------------------------------------------------------------------
41 ; CONTINUE ONLY IF NOT ALREADY DEFINED
42 ----------------------------------------------------------------------------*/
43 #ifndef PVMP3_DEC_DEFS_H
44 #define PVMP3_DEC_DEFS_H
45 
46 /*----------------------------------------------------------------------------
47 ; INCLUDES
48 ----------------------------------------------------------------------------*/
49 #include "pvmp3_audio_type_defs.h"
50 #include "pvmp3decoder_api.h"
51 
52 /*----------------------------------------------------------------------------
53 ; MACROS
54 ; Define module specific macros here
55 ----------------------------------------------------------------------------*/
56 #define module(x, POW2)   ((x)&(POW2-1))
57 
58 /*----------------------------------------------------------------------------
59 ; DEFINES
60 ; Include all pre-processor statements here.
61 ----------------------------------------------------------------------------*/
62 #define BUFSIZE   8192   // big enough to hold 4608 bytes == biggest mp3 frame
63 
64 #define CHAN           2
65 #define GRAN           2
66 
67 
68 #define SUBBANDS_NUMBER        32
69 #define FILTERBANK_BANDS       18
70 #define HAN_SIZE              512
71 
72 
73 /* MPEG Header Definitions - ID Bit Values */
74 
75 #define MPEG_1              0
76 #define MPEG_2              1
77 #define MPEG_2_5            2
78 #define INVALID_VERSION     -1
79 
80 /* MPEG Header Definitions - Mode Values */
81 
82 #define MPG_MD_STEREO           0
83 #define MPG_MD_JOINT_STEREO     1
84 #define MPG_MD_DUAL_CHANNEL     2
85 #define MPG_MD_MONO             3
86 
87 
88 
89 #define LEFT        0
90 #define RIGHT       1
91 
92 
93 #define SYNC_WORD         (int32)0x7ff
94 #define SYNC_WORD_LNGTH   11
95 
96 /*----------------------------------------------------------------------------
97 ; EXTERNAL VARIABLES REFERENCES
98 ; Declare variables used in this module but defined elsewhere
99 ----------------------------------------------------------------------------*/
100 
101 /*----------------------------------------------------------------------------
102 ; SIMPLE TYPEDEF'S
103 ----------------------------------------------------------------------------*/
104 
105 /*----------------------------------------------------------------------------
106 ; ENUMERATED TYPEDEF'S
107 ----------------------------------------------------------------------------*/
108 #ifdef __cplusplus
109 extern "C"
110 {
111 #endif
112 
113     typedef enum ERROR_CODE
114     {
115         NO_DECODING_ERROR         = 0,
116         UNSUPPORTED_LAYER         = 1,
117         UNSUPPORTED_FREE_BITRATE  = 2,
118         FILE_OPEN_ERROR           = 3,          /* error opening file */
119         CHANNEL_CONFIG_ERROR      = 4,     /* error in channel configuration */
120         SYNTHESIS_WINDOW_ERROR    = 5,   /* error in synthesis window table */
121         READ_FILE_ERROR           = 6,          /* error reading input file */
122         SIDE_INFO_ERROR           = 7,          /* error in side info */
123         HUFFMAN_TABLE_ERROR       = 8,      /* error in Huffman table */
124         COMMAND_LINE_ERROR        = 9,       /* error in command line */
125         MEMORY_ALLOCATION_ERROR   = 10,   /* error allocating memory */
126         NO_ENOUGH_MAIN_DATA_ERROR = 11,
127         SYNCH_LOST_ERROR          = 12,
128         OUTPUT_BUFFER_TOO_SMALL   = 13     /* output buffer can't hold output */
129     } ERROR_CODE;
130 
131     /*----------------------------------------------------------------------------
132     ; STRUCTURES TYPEDEF'S
133     ----------------------------------------------------------------------------*/
134 
135     /* Header Information Structure */
136 
137     typedef struct
138     {
139         int32 version_x;
140         int32 layer_description;
141         int32 error_protection;
142         int32 bitrate_index;
143         int32 sampling_frequency;
144         int32 padding;
145         int32 extension;
146         int32 mode;
147         int32 mode_ext;
148         int32 copyright;
149         int32 original;
150         int32 emphasis;
151     } mp3Header;
152 
153 
154     /* Layer III side information. */
155 
156     typedef  struct
157     {
158         uint32 part2_3_length;
159         uint32 big_values;
160         int32 global_gain;
161         uint32 scalefac_compress;
162         uint32 window_switching_flag;
163         uint32 block_type;
164         uint32 mixed_block_flag;
165         uint32 table_select[3];
166         uint32 subblock_gain[3];
167         uint32 region0_count;
168         uint32 region1_count;
169         uint32 preflag;
170         uint32 scalefac_scale;
171         uint32 count1table_select;
172 
173     } granuleInfo;
174 
175     typedef  struct
176     {
177         uint32      scfsi[4];
178         granuleInfo gran[2];
179 
180     } channelInfo;
181 
182     /* Layer III side info. */
183 
184     typedef struct
185     {
186         uint32      main_data_begin;
187         uint32      private_bits;
188         channelInfo ch[2];
189 
190     } mp3SideInfo;
191 
192     /* Layer III scale factors. */
193     typedef struct
194     {
195         int32 l[23];            /* [cb] */
196         int32 s[3][13];         /* [window][cb] */
197 
198     } mp3ScaleFactors;
199 
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 
205 /*----------------------------------------------------------------------------
206 ; GLOBAL FUNCTION DEFINITIONS
207 ; Function Prototype declaration
208 ----------------------------------------------------------------------------*/
209 
210 /*----------------------------------------------------------------------------
211 ; END
212 ----------------------------------------------------------------------------*/
213 
214 #endif
215 
216 
217 
218