ref: 9809ab276f634d5b480293d97790aaf0a3447ac5
parent: 6f5ed87b5d7aa73bd598018025cd655135c4c166
author: menno <menno>
date: Tue Jan 18 11:10:23 EST 2000
Added frequency cut-off option (-c)
--- a/aacenc.h
+++ b/aacenc.h
@@ -13,6 +13,7 @@
int in_sampling_rate; // Sampling rate of the input file
int out_sampling_rate; // Sampling rate of the output AAC file
int bit_rate; // Bitrate: can be any bitrate higher than 16kbps in steps of 1kbps
+ int cut_off; // Sets the cut_off frequency.
int profile; // AAC Profile: can be MAIN_PROFILE or LOW_PROFILE
int write_header; // If this is 1, a ADIF header will be written, if it is 0, no
// header will be written. (better turn this on, because
@@ -57,6 +58,7 @@
int samplesToRead;
int savedSize;
float saved[2048];
+ int cut_off;
} faacAACStream;
#ifndef FAAC_DLL
--- a/enc_tf.c
+++ b/enc_tf.c
@@ -408,7 +408,7 @@
******************************************************************************************************************************/
{
- int chanNum;
+ int chanNum, k;
for (chanNum=0;chanNum<max_ch;chanNum++) {
buffer2freq(
DTimeSigBuf[chanNum],
@@ -421,6 +421,14 @@
block_size_samples/short_win_in_long,
MOVERLAPPED
);
+
+ if (block_type[chanNum] == ONLY_SHORT_WINDOW) {
+ for( k=0; k<8; k++ ) {
+ specFilter(spectral_line_vector[chanNum]+k*BLOCK_LEN_SHORT, spectral_line_vector[chanNum]+k*BLOCK_LEN_SHORT, as->out_sampling_rate, as->cut_off, BLOCK_LEN_SHORT);
+ }
+ } else {
+ specFilter(spectral_line_vector[chanNum], spectral_line_vector[chanNum], as->out_sampling_rate, as->cut_off, BLOCK_LEN_LONG);
+ }
}
}
--- a/encoder.c
+++ b/encoder.c
@@ -53,6 +53,7 @@
as->out_sampling_rate = ac->out_sampling_rate;
as->in_sampling_rate = ac->in_sampling_rate;
as->write_header = ac->write_header;
+ as->cut_off = ac->cut_off;
as->use_MS = ac->use_MS;
as->use_IS = ac->use_IS;
as->use_TNS = ac->use_TNS;
@@ -335,7 +336,7 @@
faacVersion *faacv = malloc(sizeof(faacVersion));
faacv->DLLMajorVersion = 2;
- faacv->DLLMinorVersion = 15;
+ faacv->DLLMinorVersion = 16;
faacv->MajorVersion = 0;
faacv->MinorVersion = 55;
strcpy(faacv->HomePage, "http://www.slimline.net/aac/");
@@ -405,6 +406,7 @@
printf(" -nh No header will be written to the AAC file.\n");
printf(" -oX Set output directory.\n");
printf(" -sX Set output sampling rate.\n");
+ printf(" -cX Set cut-off frequency.\n");
printf(" -r Use raw data input file.\n");
printf(" file Multiple files can be given as well as wild cards.\n");
printf(" Can be any of the filetypes supported by libsndfile\n");
@@ -433,6 +435,7 @@
int profile = MAIN_PROFILE;
int no_header = 0;
int use_IS = 0, use_MS = 0, use_TNS = 1, use_LTP = 1, use_PNS = 0;
+ int cut_off = 0;
int bit_rate = 128;
int out_rate = 0;
char out_dir[255];
@@ -511,8 +514,7 @@
}
} else {
switch(argv[i][1]) {
- case 'p':
- case 'P':
+ case 'p': case 'P':
if (argv[i][2] == 'n' || 'N')
use_PNS = 1;
else if (argv[i][2] == 'l' || 'L')
@@ -520,8 +522,7 @@
else
profile = MAIN_PROFILE;
break;
- case 'n':
- case 'N':
+ case 'n': case 'N':
if (argv[i][2] == 'm' || 'M')
use_MS = -1;
else if (argv[i][2] == 't' || 'T')
@@ -531,33 +532,29 @@
else
no_header = 1;
break;
- case 'm':
- case 'M':
+ case 'm': case 'M':
use_MS = 1;
break;
- case 'i':
- case 'I':
+ case 'i': case 'I':
use_IS = 1;
break;
- case 'r':
- case 'R':
+ case 'r': case 'R':
raw_audio = 1;
break;
- case 'b':
- case 'B':
+ case 'b': case 'B':
bit_rate = atoi(&argv[i][2]);
break;
- case 's':
- case 'S':
- out_rate = atoi(&argv[i][2]);
+ case 's': case 'S':
+ cut_off = atoi(&argv[i][2]);
break;
- case 'o':
- case 'O':
+ case 'c': case 'C':
+ cut_off = atoi(&argv[i][2]);
+ break;
+ case 'o': case 'O':
out_dir_set = 1;
strcpy(out_dir, &argv[i][2]);
break;
- case 'h':
- case 'H':
+ case 'h': case 'H':
usage();
return 1;
}
@@ -614,6 +611,7 @@
ac.in_sampling_rate = sf_info.samplerate;
ac.out_sampling_rate = out_rate ? out_rate : sf_info.samplerate;
ac.bit_rate = bit_rate * 1000;
+ ac.cut_off = cut_off ? cut_off : (ac.out_sampling_rate>>1);
ac.profile = profile;
ac.use_MS = use_MS;
ac.use_IS = use_IS;
--- a/imdct.c
+++ b/imdct.c
@@ -351,3 +351,29 @@
}
/***********************************************************************************************/
+
+void specFilter (double p_in[],
+ double p_out[],
+ int samp_rate,
+ int lowpass_freq,
+ int specLen
+ )
+{
+ float lowpass;
+ int xlowpass,i;
+
+ /* calculate the last line which is not zero */
+ lowpass = (float)lowpass_freq * (float)specLen;
+ lowpass /= (samp_rate>>1);
+ lowpass += 1.0; /* round up to ensure that the desired upper frequency limit is correct */
+ xlowpass = ((int)lowpass < specLen) ? (int)lowpass : specLen ;
+
+ if( p_out != p_in ) {
+ for (i = 0; i < specLen; i++ ) {
+ p_out[i] = p_in[i];
+ }
+ }
+ for (i = xlowpass; i <specLen ; i++ ) {
+ p_out[i] = 0;
+ }
+}
\ No newline at end of file
--- a/tf_main.h
+++ b/tf_main.h
@@ -138,5 +138,12 @@
void imdct(double in_data[], double out_data[], int len);
+void specFilter (double p_in[],
+ double p_out[],
+ int samp_rate,
+ int lowpass_freq,
+ int specLen
+ );
+
#endif /* #ifndef _TF_MAIN_H_INCLUDED */