shithub: aacenc

Download patch

ref: 4275e773a2a41b48184b75367feabb374b066df7
parent: 6d6d8e8397f092d3db4ba6ecd540edc9deb79d8c
author: menno <menno>
date: Mon Jan 24 09:33:35 EST 2000

Unneeded calls to functions removed

--- a/enc_tf.c
+++ b/enc_tf.c
@@ -257,14 +257,28 @@
 			} /* end for(i ..) */
 		} /* end for(chanNum ... ) */
 
-		for (chanNum=2;chanNum<4;chanNum++) {
-			if (chanNum == 2) {
-				for(i = 0; i < block_size_samples; i++){
-					DTimeSigLookAheadBuf[chanNum][i] = (DTimeSigLookAheadBuf[0][i]+DTimeSigLookAheadBuf[1][i])/SQRT2;
+		if (as->use_MS == 0) {
+			for (chanNum=2;chanNum<4;chanNum++) {
+				if (chanNum == 2) {
+					for(i = 0; i < block_size_samples; i++){
+						DTimeSigLookAheadBuf[chanNum][i] = (DTimeSigLookAheadBuf[0][i]+DTimeSigLookAheadBuf[1][i])/2;
+					}
+				} else {
+					for(i = 0; i < block_size_samples; i++){
+						DTimeSigLookAheadBuf[chanNum][i] = (DTimeSigLookAheadBuf[0][i]-DTimeSigLookAheadBuf[1][i])/2;
+					}
 				}
-			} else {
-				for(i = 0; i < block_size_samples; i++){
-					DTimeSigLookAheadBuf[chanNum][i] = (DTimeSigLookAheadBuf[0][i]-DTimeSigLookAheadBuf[1][i])/SQRT2;
+			}
+		} else if (as->use_MS == 1) {
+			for (chanNum=0;chanNum<2;chanNum++) {
+				if (chanNum == 0) {
+					for(i = 0; i < block_size_samples; i++){
+						DTimeSigLookAheadBuf[chanNum][i] = (as->inputBuffer[0][i]+as->inputBuffer[1][i])/2;
+					}
+				} else {
+					for(i = 0; i < block_size_samples; i++){
+						DTimeSigLookAheadBuf[chanNum][i] = (as->inputBuffer[0][i]-as->inputBuffer[1][i])/2;
+					}
 				}
 			}
 		}
@@ -272,7 +286,10 @@
 	}
 
 	if (fixed_stream == NULL) {
-		psy_fill_lookahead(DTimeSigLookAheadBuf, max_ch+2);
+		if (as->use_MS != -1)
+			psy_fill_lookahead(DTimeSigLookAheadBuf, max_ch+2);
+		else
+			psy_fill_lookahead(DTimeSigLookAheadBuf, max_ch);
 
 		return FNO_ERROR; /* quick'n'dirty fix for encoder startup    HP 21-aug-96 */
 	}
@@ -291,8 +308,14 @@
 	*
 	******************************************************************************************************************************/
 	{
-		int chanNum;
-		for (chanNum=0;chanNum<max_ch+2;chanNum++) {
+		int chanNum, channels;
+
+		if (as->use_MS == 0)
+			channels = max_ch+2;
+		else
+			channels = max_ch;
+
+		for (chanNum = 0; chanNum < channels; chanNum++) {
 
 			EncTf_psycho_acoustic(
 				sampling_rate,
--- a/ms.c
+++ b/ms.c
@@ -156,7 +156,7 @@
 
 									msInfo->ms_used[b] = 1;
 									for (j = groupIndex; j < quantInfo[chan].window_group_length[g]+groupIndex; j++) {
-										p_ratio_short[chan][(g*maxSfb)+sfbNum] = p_chpo_short[chan+2][j].p_ratio[sfbNum];
+										p_ratio_short[chan][(g*maxSfb)+sfbNum] = p_chpo_short[chan][j].p_ratio[sfbNum];
 										p_chpo_short[1][j].use_ms[sfbNum] = 1;
 									}
 
@@ -163,7 +163,7 @@
 								} else {
 
 									msInfo->ms_used[b] = 1;
-									p_ratio_long[chan][sfbNum] = p_chpo_long[chan+2].p_ratio[sfbNum];
+									p_ratio_long[chan][sfbNum] = p_chpo_long[chan].p_ratio[sfbNum];
 									p_chpo_long[1].use_ms[sfbNum] = 1;
 									
 								}