00001 /* 00002 * encoder.h include file 00003 * 00004 * Copyright (c) 2000 Mark Taylor 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the 00018 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 * Boston, MA 02111-1307, USA. 00020 */ 00021 00022 00023 #ifndef LAME_ENCODER_H 00024 #define LAME_ENCODER_H 00025 00026 /*********************************************************************** 00027 * 00028 * encoder and decoder delays 00029 * 00030 ***********************************************************************/ 00031 00032 /* 00033 * layer III enc->dec delay: 1056 (1057?) (observed) 00034 * layer II enc->dec delay: 480 (481?) (observed) 00035 * 00036 * polyphase 256-16 (dec or enc) = 240 00037 * mdct 256+32 (9*32) (dec or enc) = 288 00038 * total: 512+16 00039 * 00040 * My guess is that delay of polyphase filterbank is actualy 240.5 00041 * (there are technical reasons for this, see postings in mp3encoder). 00042 * So total Encode+Decode delay = ENCDELAY + 528 + 1 00043 */ 00044 00045 /* 00046 * ENCDELAY The encoder delay. 00047 * 00048 * Minimum allowed is MDCTDELAY (see below) 00049 * 00050 * The first 96 samples will be attenuated, so using a value less than 96 00051 * will result in corrupt data for the first 96-ENCDELAY samples. 00052 * 00053 * suggested: 576 00054 * set to 1160 to sync with FhG. 00055 */ 00056 00057 #define ENCDELAY 576 00058 00059 00060 00061 /* 00062 * make sure there is at least one complete frame after the 00063 * last frame containing real data 00064 * 00065 * Using a value of 288 would be sufficient for a 00066 * a very sophisticated decoder that can decode granule-by-granule instead 00067 * of frame by frame. But lets not assume this, and assume the decoder 00068 * will not decode frame N unless it also has data for frame N+1 00069 * 00070 */ 00071 /*#define POSTDELAY 288*/ 00072 #define POSTDELAY 1152 00073 00074 00075 00076 /* 00077 * delay of the MDCT used in mdct.c 00078 * original ISO routines had a delay of 528! 00079 * Takehiro's routines: 00080 */ 00081 00082 #define MDCTDELAY 48 00083 #define FFTOFFSET (224+MDCTDELAY) 00084 00085 /* 00086 * Most decoders, including the one we use, have a delay of 528 samples. 00087 */ 00088 00089 #define DECDELAY 528 00090 00091 00092 /* number of subbands */ 00093 #define SBLIMIT 32 00094 00095 /* parition bands bands */ 00096 #define CBANDS 64 00097 00098 /* number of critical bands/scale factor bands where masking is computed*/ 00099 #define SBPSY_l 21 00100 #define SBPSY_s 12 00101 00102 /* total number of scalefactor bands encoded */ 00103 #define SBMAX_l 22 00104 #define SBMAX_s 13 00105 #define PSFB21 6 00106 #define PSFB12 6 00107 00108 00109 00110 /* FFT sizes */ 00111 #define BLKSIZE 1024 00112 #define HBLKSIZE (BLKSIZE/2 + 1) 00113 #define BLKSIZE_s 256 00114 #define HBLKSIZE_s (BLKSIZE_s/2 + 1) 00115 00116 00117 /* #define switch_pe 1800 */ 00118 #define NORM_TYPE 0 00119 #define START_TYPE 1 00120 #define SHORT_TYPE 2 00121 #define STOP_TYPE 3 00122 00123 /* 00124 * Mode Extention: 00125 * When we are in stereo mode, there are 4 possible methods to store these 00126 * two channels. The stereo modes -m? are using a subset of them. 00127 * 00128 * -ms: MPG_MD_LR_LR 00129 * -mj: MPG_MD_LR_LR and MPG_MD_MS_LR 00130 * -mf: MPG_MD_MS_LR 00131 * -mi: all 00132 */ 00133 00134 #define MPG_MD_LR_LR 0 00135 #define MPG_MD_LR_I 1 00136 #define MPG_MD_MS_LR 2 00137 #define MPG_MD_MS_I 3 00138 00139 00140 int lame_encode_mp3_frame(lame_global_flags * const gfp, 00141 sample_t const *inbuf_l, 00142 sample_t const *inbuf_r, unsigned char *mp3buf, int mp3buf_size); 00143 00144 #endif /* LAME_ENCODER_H */