2 |
- |
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 |
* delay of the MDCT used in mdct.c
|
|
|
61 |
* original ISO routines had a delay of 528!
|
|
|
62 |
* Takehiro's routines:
|
|
|
63 |
*/
|
|
|
64 |
|
|
|
65 |
#define MDCTDELAY 48
|
|
|
66 |
#define FFTOFFSET (224+MDCTDELAY)
|
|
|
67 |
|
|
|
68 |
/*
|
|
|
69 |
* Most decoders, including the one we use, have a delay of 528 samples.
|
|
|
70 |
*/
|
|
|
71 |
|
|
|
72 |
#define DECDELAY 528
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
/* number of subbands */
|
|
|
76 |
#define SBLIMIT 32
|
|
|
77 |
|
|
|
78 |
/* parition bands bands */
|
|
|
79 |
#define CBANDS 64
|
|
|
80 |
|
|
|
81 |
/* number of critical bands/scale factor bands where masking is computed*/
|
|
|
82 |
#define SBPSY_l 21
|
|
|
83 |
#define SBPSY_s 12
|
|
|
84 |
|
|
|
85 |
/* total number of scalefactor bands encoded */
|
|
|
86 |
#define SBMAX_l 22
|
|
|
87 |
#define SBMAX_s 13
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
/* FFT sizes */
|
|
|
92 |
#define BLKSIZE 1024
|
|
|
93 |
#define HBLKSIZE (BLKSIZE/2 + 1)
|
|
|
94 |
#define BLKSIZE_s 256
|
|
|
95 |
#define HBLKSIZE_s (BLKSIZE_s/2 + 1)
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
/* #define switch_pe 1800 */
|
|
|
99 |
#define NORM_TYPE 0
|
|
|
100 |
#define START_TYPE 1
|
|
|
101 |
#define SHORT_TYPE 2
|
|
|
102 |
#define STOP_TYPE 3
|
|
|
103 |
|
|
|
104 |
/*
|
|
|
105 |
* Mode Extention:
|
|
|
106 |
* When we are in stereo mode, there are 4 possible methods to store these
|
|
|
107 |
* two channels. The stereo modes -m? are using a subset of them.
|
|
|
108 |
*
|
|
|
109 |
* -ms: MPG_MD_LR_LR
|
|
|
110 |
* -mj: MPG_MD_LR_LR and MPG_MD_MS_LR
|
|
|
111 |
* -mf: MPG_MD_MS_LR
|
|
|
112 |
* -mi: all
|
|
|
113 |
*/
|
|
|
114 |
|
|
|
115 |
#define MPG_MD_LR_LR 0
|
|
|
116 |
#define MPG_MD_LR_I 1
|
|
|
117 |
#define MPG_MD_MS_LR 2
|
|
|
118 |
#define MPG_MD_MS_I 3
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
#include "machine.h"
|
|
|
122 |
#include "lame.h"
|
|
|
123 |
|
|
|
124 |
int lame_encode_mp3_frame (
|
|
|
125 |
lame_global_flags* const gfp,
|
|
|
126 |
sample_t* inbuf_l,
|
|
|
127 |
sample_t* inbuf_r,
|
|
|
128 |
unsigned char* mp3buf,
|
|
|
129 |
int mp3buf_size );
|
|
|
130 |
|
|
|
131 |
#endif /* LAME_ENCODER_H */
|