shithub: aacenc

Download patch

ref: 4367273bd26e526e94932b963702d929f6780537
parent: b62dc54bbf0ff7531b0c86ece8c7f5c68f48aa0b
author: menno <menno>
date: Sun Dec 19 19:19:52 EST 1999

Very big speedup

--- a/aac_qc.c
+++ b/aac_qc.c
@@ -73,7 +73,6 @@
 	}
 }
 
-#if 0
 int quantize(AACQuantInfo *quantInfo,
 			 double *p_spectrum,
 			 double *pow_spectrum,
@@ -82,39 +81,6 @@
 {
 	int i, sb;
 	double quantFac;
-
-	for (sb = 0; sb < quantInfo->nr_of_sfb; sb++) {
-
-		quantFac = pow(2.0, 0.1875*(quantInfo->scale_factor[sb] -
-			quantInfo->common_scalefac ));
-
-		for (i = quantInfo->sfb_offset[sb]; i < quantInfo->sfb_offset[sb+1]; i++){
-			quant[i] = (int)(pow_spectrum[i] * quantFac + MAGIC_NUMBER);
-
-			if (quant[i] > MAX_QUANT) {
-				return 1;
-			}
-			quant[i] = sgn(p_spectrum[i]) * quant[i];  /* restore the original sign */
-		}
-	}
-
-	if (quantInfo->block_type==ONLY_SHORT_WINDOW)
-		quantInfo->pulseInfo.pulse_data_present = 0;
-	else
-		PulseCoder(quantInfo, quant);
-
-	return 0;
-}
-#else
-
-int quantize(AACQuantInfo *quantInfo,
-			 double *p_spectrum,
-			 double *pow_spectrum,
-			 int quant[NUM_COEFF]
-			 )
-{
-	int i, sb;
-	double quantFac;
 	double x;
 
 	for (sb = 0; sb < quantInfo->nr_of_sfb; sb++) {
@@ -139,7 +105,6 @@
 
 	return 0;
 }
-#endif
 
 int calc_noise(AACQuantInfo *quantInfo,
 				double *p_spectrum,
@@ -337,7 +302,6 @@
 	int store_common_scalefac;
 	int best_scale_factor[SFB_NUM_MAX];
 	double pow_spectrum[NUM_COEFF];
-	int sfb_amplify_check[SFB_NUM_MAX];
 	double requant[NUM_COEFF];
 	int sb;
 	int extra_bits;
@@ -465,15 +429,15 @@
 		}
 	}
 
-//	if (old_startsf < 40) {
+	if (old_startsf < 40) {
 		if (max_dct_line!=0.0) {
-			start_com_sf = (int)(16/3 * (log(ABS(pow(max_dct_line,0.75)/MAX_QUANT)/log(2.0))));
+			start_com_sf = 30 + (int)(16/3 * (log(ABS(pow(max_dct_line,0.75)/MAX_QUANT)/log(2.0))));
 		} else {
 			start_com_sf = 40;
 		}
-//	} else {
-//		start_com_sf = old_startsf;
-//	}
+	} else {
+		start_com_sf = old_startsf;
+	}
 	if ((start_com_sf>200) || (start_com_sf<40) )
 		start_com_sf = 40;
 
@@ -480,7 +444,6 @@
 	/* initialize the scale_factors that aren't intensity stereo bands */
 	is_info=&(ch_info->is_info);
 	for(k=0; k< quantInfo -> nr_of_sfb ;k++) {
-		sfb_amplify_check[k] = 0;
 		scale_factor[k]=((is_info->is_present)&&(is_info->is_used[k])) ? scale_factor[k] : 0;
 	}