shithub: aacenc

Download patch

ref: 55308e39d51b50733f7429beb5c90d1526792c6b
parent: b4fe06fdb64bcc71d688f307a73e84b2bb60892c
author: menno <menno>
date: Sat Feb 5 09:23:42 EST 2000

SMR values were one frame ahead of data. Big quality improvement.

--- a/enc_tf.c
+++ b/enc_tf.c
@@ -232,8 +232,8 @@
 	long num_bits_available;
 
 	double *p_ratio[MAX_TIME_CHANNELS], allowed_distortion[MAX_TIME_CHANNELS][MAX_SCFAC_BANDS];
-	double p_ratio_long[MAX_TIME_CHANNELS][MAX_SCFAC_BANDS];
-	double p_ratio_short[MAX_TIME_CHANNELS][MAX_SCFAC_BANDS];
+	static double p_ratio_long[2][MAX_TIME_CHANNELS][MAX_SCFAC_BANDS];
+	static double p_ratio_short[2][MAX_TIME_CHANNELS][MAX_SCFAC_BANDS];
 	int    nr_of_sfb[MAX_TIME_CHANNELS], sfb_width_table[MAX_TIME_CHANNELS][MAX_SCFAC_BANDS];
 	int sfb_offset_table[MAX_TIME_CHANNELS][MAX_SCFAC_BANDS+1];
 
@@ -242,6 +242,8 @@
 	/* structures holding the output of the psychoacoustic model */
 	CH_PSYCH_OUTPUT_LONG chpo_long[MAX_TIME_CHANNELS+2];
 	CH_PSYCH_OUTPUT_SHORT chpo_short[MAX_TIME_CHANNELS+2][MAX_SHORT_WINDOWS];
+	static int ps = 1;
+	ps = !ps;
 
 	{
 		/* store input data in look ahead buffer which may be necessary for the window switching decision */
@@ -495,28 +497,28 @@
 			case ONLY_LONG_WINDOW:
 				memcpy( (char*)sfb_width_table[chanNum], (char*)chpo_long[chanNum].cb_width, (NSFB_LONG+1)*sizeof(int) );
 				nr_of_sfb[chanNum] = chpo_long[chanNum].no_of_cb;
-				p_ratio[chanNum]   = p_ratio_long[chanNum];
+				p_ratio[chanNum]   = p_ratio_long[ps][chanNum];
 				break;
 			case LONG_SHORT_WINDOW:
 				memcpy( (char*)sfb_width_table[chanNum], (char*)chpo_long[chanNum].cb_width, (NSFB_LONG+1)*sizeof(int) );
 				nr_of_sfb[chanNum] = chpo_long[chanNum].no_of_cb;
-				p_ratio[chanNum]   = p_ratio_long[chanNum];
+				p_ratio[chanNum]   = p_ratio_long[ps][chanNum];
 				break;
 			case ONLY_SHORT_WINDOW:
 				memcpy( (char*)sfb_width_table[chanNum], (char*)chpo_short[chanNum][0].cb_width, (NSFB_SHORT+1)*sizeof(int) );
 				nr_of_sfb[chanNum] = chpo_short[chanNum][0].no_of_cb;
-				p_ratio[chanNum]   = p_ratio_short[chanNum];
+				p_ratio[chanNum]   = p_ratio_short[ps][chanNum];
 				break;
 			case SHORT_LONG_WINDOW:
 				memcpy( (char*)sfb_width_table[chanNum], (char*)chpo_long[chanNum].cb_width, (NSFB_LONG+1)*sizeof(int) );
 				nr_of_sfb[chanNum] = chpo_long[chanNum].no_of_cb;
-				p_ratio[chanNum]   = p_ratio_long[chanNum];
+				p_ratio[chanNum]   = p_ratio_long[ps][chanNum];
 				break;
 			}
 		}
 	}
 
-	MSPreprocess(p_ratio_long, p_ratio_short, chpo_long, chpo_short,
+	MSPreprocess(p_ratio_long[!ps], p_ratio_short[!ps], chpo_long, chpo_short,
 		channelInfo, block_type, quantInfo, as->use_MS, as->use_IS, max_ch);
 
 	MSEnergy(spectral_line_vector, energy, chpo_long, chpo_short, sfb_width_table,
--- a/psych.c
+++ b/psych.c
@@ -52,9 +52,9 @@
 
 Source file:
 
-$Id: psych.c,v 1.32 2000/02/04 21:24:20 menno Exp $
-$Id: psych.c,v 1.32 2000/02/04 21:24:20 menno Exp $
-$Id: psych.c,v 1.32 2000/02/04 21:24:20 menno Exp $
+$Id: psych.c,v 1.33 2000/02/05 14:23:42 menno Exp $
+$Id: psych.c,v 1.33 2000/02/05 14:23:42 menno Exp $
+$Id: psych.c,v 1.33 2000/02/05 14:23:42 menno Exp $
 
 **********************************************************************/
 
@@ -912,16 +912,16 @@
 	       PSY_VARIABLE_SHORT *psy_var_short)
 {
 	int b,i;
-	double tmn = 18.0, nmt = 6.0;
+	double tmn = 14.5, nmt = 6.0;
 
 	for(b = 0; b < part_tbl_long->len; b++) {
-		psy_var_long->snr[b] = psy_var_long->tb[b] * tmn + (1.0 - psy_var_long->tb[b] ) * nmt;
+		psy_var_long->snr[b] = psy_var_long->tb[b] * (tmn+(b/3.0)) + (1.0 - psy_var_long->tb[b] ) * nmt;
 	}
 
 	/* added by T. Araki (1997.10.16) */
 	for(i = 0;  i < MAX_SHORT_WINDOWS; i++){
 		for(b = 0; b < part_tbl_short->len; b++)
-			psy_var_short->snr[i][b] = psy_var_short->tb[i][b] * tmn + (1.0 - psy_var_short->tb[i][b] ) * nmt ;
+			psy_var_short->snr[i][b] = psy_var_short->tb[i][b] * (tmn+b) + (1.0 - psy_var_short->tb[i][b] ) * nmt ;
 	}
 	/* added by T. Araki (1997.10.16) end */
 }