• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *      encoder.h include file
3  *
4  *      Copyright (c) 2000 Mark Taylor
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 
23 #ifndef LAME_ENCODER_H
24 #define LAME_ENCODER_H
25 
26 /***********************************************************************
27 *
28 *  encoder and decoder delays
29 *
30 ***********************************************************************/
31 
32 /*
33  * layer III enc->dec delay:  1056 (1057?)   (observed)
34  * layer  II enc->dec delay:   480  (481?)   (observed)
35  *
36  * polyphase 256-16             (dec or enc)        = 240
37  * mdct      256+32  (9*32)     (dec or enc)        = 288
38  * total:    512+16
39  *
40  * My guess is that delay of polyphase filterbank is actualy 240.5
41  * (there are technical reasons for this, see postings in mp3encoder).
42  * So total Encode+Decode delay = ENCDELAY + 528 + 1
43  */
44 
45 /*
46  * ENCDELAY  The encoder delay.
47  *
48  * Minimum allowed is MDCTDELAY (see below)
49  *
50  * The first 96 samples will be attenuated, so using a value less than 96
51  * will result in corrupt data for the first 96-ENCDELAY samples.
52  *
53  * suggested: 576
54  * set to 1160 to sync with FhG.
55  */
56 
57 #define ENCDELAY      576
58 
59 
60 
61 /*
62  * make sure there is at least one complete frame after the
63  * last frame containing real data
64  *
65  * Using a value of 288 would be sufficient for a
66  * a very sophisticated decoder that can decode granule-by-granule instead
67  * of frame by frame.  But lets not assume this, and assume the decoder
68  * will not decode frame N unless it also has data for frame N+1
69  *
70  */
71 /*#define POSTDELAY   288*/
72 #define POSTDELAY   1152
73 
74 
75 
76 /*
77  * delay of the MDCT used in mdct.c
78  * original ISO routines had a delay of 528!
79  * Takehiro's routines:
80  */
81 
82 #define MDCTDELAY     48
83 #define FFTOFFSET     (224+MDCTDELAY)
84 
85 /*
86  * Most decoders, including the one we use, have a delay of 528 samples.
87  */
88 
89 #define DECDELAY      528
90 
91 
92 /* number of subbands */
93 #define SBLIMIT       32
94 
95 /* parition bands bands */
96 #define CBANDS        64
97 
98 /* number of critical bands/scale factor bands where masking is computed*/
99 #define SBPSY_l       21
100 #define SBPSY_s       12
101 
102 /* total number of scalefactor bands encoded */
103 #define SBMAX_l       22
104 #define SBMAX_s       13
105 #define PSFB21         6
106 #define PSFB12         6
107 
108 
109 
110 /* FFT sizes */
111 #define BLKSIZE       1024
112 #define HBLKSIZE      (BLKSIZE/2 + 1)
113 #define BLKSIZE_s     256
114 #define HBLKSIZE_s    (BLKSIZE_s/2 + 1)
115 
116 
117 /* #define switch_pe        1800 */
118 #define NORM_TYPE     0
119 #define START_TYPE    1
120 #define SHORT_TYPE    2
121 #define STOP_TYPE     3
122 
123 /*
124  * Mode Extention:
125  * When we are in stereo mode, there are 4 possible methods to store these
126  * two channels. The stereo modes -m? are using a subset of them.
127  *
128  *  -ms: MPG_MD_LR_LR
129  *  -mj: MPG_MD_LR_LR and MPG_MD_MS_LR
130  *  -mf: MPG_MD_MS_LR
131  *  -mi: all
132  */
133 #if 0
134 #define MPG_MD_LR_LR  0
135 #define MPG_MD_LR_I   1
136 #define MPG_MD_MS_LR  2
137 #define MPG_MD_MS_I   3
138 #endif
139 enum MPEGChannelMode
140 {   MPG_MD_LR_LR = 0
141 ,   MPG_MD_LR_I  = 1
142 ,   MPG_MD_MS_LR = 2
143 ,   MPG_MD_MS_I  = 3
144 };
145 
146 #ifndef lame_internal_flags_defined
147 #define lame_internal_flags_defined
148 struct lame_internal_flags;
149 typedef struct lame_internal_flags lame_internal_flags;
150 #endif
151 
152 int     lame_encode_mp3_frame(lame_internal_flags * gfc,
153                               sample_t const *inbuf_l,
154                               sample_t const *inbuf_r, unsigned char *mp3buf, int mp3buf_size);
155 
156 #endif /* LAME_ENCODER_H */
157