shithub: aacenc

Download patch

ref: 2a2cde962f4f63b12ee7e30759f3b0048932328f
parent: 9bffa38f24f9c853b71d50f216141dcbc5f2f741
author: menno <menno>
date: Fri Feb 4 16:24:20 EST 2000

Window switching back to old

--- a/enc_tf.c
+++ b/enc_tf.c
@@ -46,8 +46,8 @@
 enum QC_MOD_SELECT qc_select = AAC_QC;                   /* later f(encPara) */
 enum AAC_PROFILE profile = MAIN;
 enum WINDOW_TYPE block_type[MAX_TIME_CHANNELS];
-enum WINDOW_TYPE desired_block_type;
-enum WINDOW_TYPE next_desired_block_type;
+enum WINDOW_TYPE desired_block_type[MAX_TIME_CHANNELS];
+enum WINDOW_TYPE next_desired_block_type[MAX_TIME_CHANNELS+2];
 
 /* Additional variables for AAC */
 int aacAllowScalefacs = 1;              /* Allow AAC scalefactors to be nonconstant */
@@ -249,12 +249,12 @@
 		int chanNum;
 
 		for (chanNum=0;chanNum<max_ch;chanNum++) {
-                        if(as->use_LTP)
-			   for( i=0; i<block_size_samples; i++ ) {
-				/* temporary fix: a linear buffer for LTP containing the whole time frame */
-				nok_tmp_DTimeSigBuf[chanNum][i] = DTimeSigBuf[chanNum][i];
-				nok_tmp_DTimeSigBuf[chanNum][block_size_samples + i] = DTimeSigLookAheadBuf[chanNum][i];
-			   }
+			if(as->use_LTP)
+				for( i=0; i<block_size_samples; i++ ) {
+					/* temporary fix: a linear buffer for LTP containing the whole time frame */
+					nok_tmp_DTimeSigBuf[chanNum][i] = DTimeSigBuf[chanNum][i];
+					nok_tmp_DTimeSigBuf[chanNum][block_size_samples + i] = DTimeSigLookAheadBuf[chanNum][i];
+				}
 			for( i=0; i<block_size_samples; i++ ) {
 				/* last frame input data are encoded now */
 				DTimeSigBuf[chanNum][i] = DTimeSigLookAheadBuf[chanNum][i];
@@ -311,7 +311,7 @@
 				sampling_rate,
 				chanNum,
 				&DTimeSigLookAheadBuf[chanNum],
-				&next_desired_block_type,
+				&next_desired_block_type[chanNum],
 				(int)qc_select,
 				block_size_samples,
 				chpo_long,
@@ -325,6 +325,7 @@
 	* block_switch processing
 	*
 	******************************************************************************************************************************/
+#if 0
 	/* Window switching taken from the NTT source code in the MPEG4 VM. */
 	{
 		static int ntt_InitFlag = 1;
@@ -355,8 +356,38 @@
 		}
 		ntt_InitFlag = 0;
 	}
+#else
+	{
+		int chanNum;
+		for (chanNum=0;chanNum<max_ch;chanNum++) {
+			/* A few definitions:                                                      */
+			/*   block_type:  Initially, the block_type used in the previous frame.    */
+			/*                Will be set to the block_type to use this frame.         */
+			/*                A block type will be selected to ensure a meaningful     */
+			/*                window transition.                                       */
+			/*   next_desired_block_type:  Block_type (LONG or SHORT) which the psycho */
+			/*                model wants to use next frame.  The psycho model is      */
+			/*                using a look-ahead buffer.                               */
+			/*   desired_block_type:  Block_type (LONG or SHORT) which the psycho      */
+			/*                previously wanted to use.  It is the desired block_type  */
+			/*                for this frame.                                          */
+			if ( (block_type[chanNum]==ONLY_SHORT_WINDOW)||(block_type[chanNum]==LONG_SHORT_WINDOW) ) {
+				if ( (desired_block_type[chanNum]==ONLY_LONG_WINDOW)&&(next_desired_block_type[chanNum]==ONLY_LONG_WINDOW) ) {
+					block_type[chanNum]=SHORT_LONG_WINDOW;
+				} else {
+					block_type[chanNum]=ONLY_SHORT_WINDOW;
+				}
+			} else if (next_desired_block_type[chanNum]==ONLY_SHORT_WINDOW) {
+				block_type[chanNum]=LONG_SHORT_WINDOW;
+			} else {
+				block_type[chanNum]=ONLY_LONG_WINDOW;
+			}
+			desired_block_type[chanNum]=next_desired_block_type[chanNum];
+		}
+	}
+#endif
 
-//	printf("%d\n", block_type[0]);
+//	printf("%d\t\n", block_type[0]);
 //	block_type[0] = ONLY_LONG_WINDOW;
 //	block_type[1] = ONLY_LONG_WINDOW;
 //	block_type[0] = ONLY_SHORT_WINDOW;
--- a/psych.c
+++ b/psych.c
@@ -52,9 +52,9 @@
 
 Source file:
 
-$Id: psych.c,v 1.31 2000/02/04 17:03:55 menno Exp $
-$Id: psych.c,v 1.31 2000/02/04 17:03:55 menno Exp $
-$Id: psych.c,v 1.31 2000/02/04 17:03:55 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.32 2000/02/04 21:24:20 menno Exp $
 
 **********************************************************************/
 
@@ -581,6 +581,9 @@
 			&psy_var_long, &psy_var_short, ch);
 		psy_step11andahalf(&part_tbl_long, &part_tbl_short, psy_stvar_long, psy_stvar_short, no_of_chan);
 		psy_step11(&part_tbl_long, &part_tbl_short, &psy_stvar_long[no_of_chan], &psy_stvar_short[no_of_chan], ch);
+		psy_step12(&part_tbl_long, &part_tbl_short, &psy_stvar_long[no_of_chan], &psy_stvar_short[no_of_chan], 
+			&psy_var_long, &psy_var_short, ch);
+		psy_step13(&psy_var_long, block_type, ch);
 		psy_step14(p_sri, &part_tbl_long, &part_tbl_short, &psy_stvar_long[no_of_chan],
 			&psy_stvar_short[no_of_chan], &psy_var_long, &psy_var_short, ch);
 		psy_step15(psy_stvar_long[no_of_chan].use_ms, psy_stvar_short[no_of_chan].use_ms, p_sri, &psy_stvar_long[0], &psy_stvar_short[0], &psy_var_long, &psy_var_short, no_of_chan);
@@ -1073,6 +1076,40 @@
 				}
 			}
 		}
+	}
+}
+
+
+void psy_step12(PARTITION_TABLE_LONG *part_tbl_long, 
+				PARTITION_TABLE_SHORT *part_tbl_short, 
+				PSY_STATVARIABLE_LONG *psy_stvar_long, 
+				PSY_STATVARIABLE_SHORT *psy_stvar_short, 
+				PSY_VARIABLE_LONG *psy_var_long, 
+				PSY_VARIABLE_SHORT *psy_var_short,
+				int ch
+				)
+{
+    int b;
+
+    psy_var_long->pe = 0.0;
+    for(b = 0; b < part_tbl_long->len; ++b){
+		psy_var_long->pe -= part_tbl_long->width[b]
+			* log10(psy_stvar_long->nb[psy_stvar_long->p_nb + b]
+			/ (psy_var_long->e[b] + 0.0000000001)); 
+    }
+//	if(psy_var_long->pe > 1100)
+//		printf("%f\t\n",psy_var_long->pe);
+}
+
+void psy_step13(PSY_VARIABLE_LONG *psy_var_long, 
+				enum WINDOW_TYPE *block_type,
+				int ch
+				)
+{
+	if(psy_var_long->pe > 1100) {
+        *block_type = ONLY_SHORT_WINDOW;
+	} else {
+        *block_type = ONLY_LONG_WINDOW;
 	}
 }