www.pudn.com > aacenc.rar > enc_tf.c
#include#include #include "bitstream.h" #include "interface.h" #include "enc.h" #include "block.h" #include "tf_main.h" #include "psych.h" #include "common.h" /* common module */ #include "aac_back_pred.h" #include "mc_enc.h" #include "ms.h" #include "is.h" #include "winswitch.h" /* AAC ±í */ int max_sfb_s[/*bitrate_idx*/][/*srate_idx*/12] = { /* 96 88 64 48 44 32 24 22 16 12 11 8 kHz */ { 12, 12, 12, 13, 12, 13, 15, 15, 15, 15, 15, 15 }, /* 64000 bps */ { 12, 12, 12, 13, 12, 13, 15, 15, 15, 15, 15, 15 }, /* 80000 bps */ { 12, 12, 12, 13, 13, 13, 15, 15, 15, 15, 15, 15 }, /* 96000 bps */ { 12, 12, 12, 13, 13, 13, 15, 15, 15, 15, 15, 15 }, /* 112000 bps */ { 12, 12, 12, 13, 13, 13, 15, 15, 15, 15, 15, 15 }, /* 128000 bps */ { 12, 12, 12, 13, 13, 13, 15, 15, 15, 15, 15, 15 }, /* 160000 bps */ { 12, 12, 12, 13, 13, 13, 15, 15, 15, 15, 15, 15 }, /* 192000 bps */ { 12, 12, 12, 13, 13, 13, 15, 15, 15, 15, 15, 15 }, /* 224000 bps */ { 12, 12, 12, 13, 13, 13, 15, 15, 15, 15, 15, 15 } /* 256000 bps */ }; int max_sfb_l[/*bitrate_idx*/][/*srate_idx*/12] = { /* 96 88 64 48 44 32 24 22 16 12 11 8 kHz */ { 49, 49, 47, 48, 42, 51, 47, 47, 43, 43, 43, 40 }, /* 64000 bps */ { 49, 49, 47, 48, 42, 51, 47, 47, 43, 43, 43, 40 }, /* 80000 bps */ { 49, 49, 47, 48, 45, 51, 47, 47, 43, 43, 43, 40 }, /* 96000 bps */ { 49, 49, 47, 48, 45, 51, 47, 47, 43, 43, 43, 40 }, /* 112000 bps */ { 49, 49, 47, 48, 48, 51, 47, 47, 43, 43, 43, 40 }, /* 128000 bps */ { 49, 49, 47, 48, 48, 51, 47, 47, 43, 43, 43, 40 }, /* 160000 bps */ { 49, 49, 47, 48, 48, 51, 47, 47, 43, 43, 43, 40 }, /* 192000 bps */ { 49, 49, 47, 48, 48, 51, 47, 47, 43, 43, 43, 40 }, /* 224000 bps */ { 49, 49, 47, 48, 48, 51, 47, 47, 43, 43, 43, 40 } /* 256000 bps */ }; /* Table for cut-off frequencies */ /* for most bitrates this is simply the Nyquist frequency */ /* Only changed is 44.1kHz, and they correspond quite well with wath max_sfb does, so this may be unneeded. */ int cut_off[/*bitrate_idx*/][/*srate_idx*/12] = { { 48000, 44100, 32000, 24000, 16000, 16000, 12000, 11025, 8000, 5512, 4000 }, { 48000, 44100, 32000, 24000, 16000, 16000, 12000, 11025, 8000, 5512, 4000 }, { 48000, 44100, 32000, 24000, 18000, 16000, 12000, 11025, 8000, 5512, 4000 }, { 48000, 44100, 32000, 24000, 18000, 16000, 12000, 11025, 8000, 5512, 4000 }, { 48000, 44100, 32000, 24000, 20000, 16000, 12000, 11025, 8000, 5512, 4000 }, { 48000, 44100, 32000, 24000, 20000, 16000, 12000, 11025, 8000, 5512, 4000 }, { 48000, 44100, 32000, 24000, 20000, 16000, 12000, 11025, 8000, 5512, 4000 }, { 48000, 44100, 32000, 24000, 20000, 16000, 12000, 11025, 8000, 5512, 4000 }, { 48000, 44100, 32000, 24000, 20000, 16000, 12000, 11025, 8000, 5512, 4000 }, }; /* other aac */ #include "aac_qc.h" #include "all.h" #include "aac_se_enc.h" static int block_size_samples = 1024; /* nr of samples per block in one! audio channel */ static int short_win_in_long = 8; static int max_ch; /* no of of audio channels */ static double *spectral_line_vector[MAX_TIME_CHANNELS]; static double *reconstructed_spectrum[MAX_TIME_CHANNELS]; static double *overlap_buffer[MAX_TIME_CHANNELS]; static double *DTimeSigBuf[MAX_TIME_CHANNELS]; static double *DTimeSigLookAheadBuf[MAX_TIME_CHANNELS]; /* static variables used by the T/F mapping */ static enum QC_MOD_SELECT qc_select = AAC_QC; /* later f(encPara) */ static enum AAC_PROFILE profile = MAIN; /* Additional variables for AAC */ static int aacAllowScalefacs = 1; /* Allow AAC scalefactors to be nonconstant */ static TNS_INFO tnsInfo[MAX_TIME_CHANNELS]; AACQuantInfo quantInfo[MAX_TIME_CHANNELS]; /* Info structure for AAC quantization and coding */ /* Channel information */ Ch_Info channelInfo[MAX_TIME_CHANNELS]; /* AAC shorter windows 960-480-120 */ static int useShortWindows=0; /* don't use shorter windows */ // TEMPORARY HACK int srate_idx; int bitrate_idx; int sampling_rate; int bit_rate; // END OF HACK /* EncTfFree() */ /* Free memory allocated by t/f-based encoder core. */ void EncTfFree () { int chanNum; for (chanNum=0;chanNum > 3) << 3); /* Compute how many reservoir bits can be used and still be able to byte */ /* align without exceeding num_bits_available, and have room for an ID_END marker */ available_bitreservoir_bits = maxNumBitsByteAligned - LEN_SE_ID - average_bits; #if 0 // Not needed now, there are no SMR values anyway for (chanNum=0;chanNum