shithub: aacenc

Download patch

ref: 38fbe851a7f08f18e057c90e66ff5c74351ca378
parent: 89fd5d9b410e93a72767913b8cce285b44e24036
author: menno <menno>
date: Fri Aug 11 11:47:34 EDT 2000

Bugfixes and multichannel updates

--- a/enc_tf.c
+++ b/enc_tf.c
@@ -36,7 +36,7 @@
 double *reconstructed_spectrum[MAX_TIME_CHANNELS];
 double *overlap_buffer[MAX_TIME_CHANNELS];
 double *DTimeSigBuf[MAX_TIME_CHANNELS];
-double *DTimeSigLookAheadBuf[MAX_TIME_CHANNELS+2];
+double *DTimeSigLookAheadBuf[MAX_TIME_CHANNELS*2];
 double *nok_tmp_DTimeSigBuf[MAX_TIME_CHANNELS]; /* temporary fix to the buffer size problem. */
 
 /* variables used by the T/F mapping */
@@ -85,7 +85,7 @@
     if (nok_lt_status[chanNum].delay) free(nok_lt_status[chanNum].delay);
     if (nok_tmp_DTimeSigBuf[chanNum]) free(nok_tmp_DTimeSigBuf[chanNum]);
   }
-  for (chanNum=0;chanNum<MAX_TIME_CHANNELS+2;chanNum++) {
+  for (chanNum=0;chanNum<MAX_TIME_CHANNELS*2;chanNum++) {
     if (DTimeSigLookAheadBuf[chanNum]) free(DTimeSigLookAheadBuf[chanNum]);
   }
 }
@@ -156,7 +156,7 @@
     nok_tmp_DTimeSigBuf[chanNum]  = (double*)malloc(2*block_size_samples*sizeof(double));
     memset(nok_tmp_DTimeSigBuf[chanNum],0,(2*block_size_samples)*sizeof(double));
   }
-  for (chanNum=0;chanNum<MAX_TIME_CHANNELS+2;chanNum++) {
+  for (chanNum=0;chanNum<MAX_TIME_CHANNELS*2;chanNum++) {
     DTimeSigLookAheadBuf[chanNum]   = (double*)malloc((block_size_samples)*sizeof(double));
     memset(DTimeSigLookAheadBuf[chanNum],0,(block_size_samples)*sizeof(double));
   }
@@ -250,16 +250,10 @@
   /* Energy array (computed before prediction for long windows) */
   double energy[MAX_TIME_CHANNELS][MAX_SCFAC_BANDS];
 
-  /* determine the function parameters used earlier:   HP 21-aug-96 */
+  /* determine the function parameters used earlier */
   int          average_bits = as->frame_bits;
   int          available_bitreservoir_bits = as->available_bits-as->frame_bits;
 
-  /* actual amount of bits currently in the bit reservoir */
-  /* it is the job of this module to determine
-  the no of bits to use in addition to average_block_bits
-  max. available: average_block_bits + available_bitreservoir_bits */
-//	int max_bitreservoir_bits = 8184;
-
   /* max. allowed amount of bits in the reservoir  (used to avoid padding bits) */
   long num_bits_available;
 
@@ -269,11 +263,10 @@
   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];
 
-//	int no_sub_win, sub_win_size;
 
   /* 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];
+  CH_PSYCH_OUTPUT_LONG chpo_long[MAX_TIME_CHANNELS];
+  CH_PSYCH_OUTPUT_SHORT chpo_short[MAX_TIME_CHANNELS][MAX_SHORT_WINDOWS];
   static int ps = 1;
   ps = !ps;
 
@@ -280,59 +273,62 @@
   if (as->header_type==ADTS_HEADER)
     available_bitreservoir_bits += 58;
 
+  /***********************************************************************/
+  /* Determine channel elements */
+  /***********************************************************************/
+  DetermineChInfo(channelInfo, max_ch);
+
+
+  /***********************************************************************/
+  /* Fill buffers  */
+  /* store input data in look ahead buffer which may be necessary */
+  /* for the window switching decision */
+  /***********************************************************************/
   {
-	  /* store input data in look ahead buffer which may be necessary for the window switching decision */
-	  int i;
 	  int chanNum;
+	  int i;
 
-	  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];
-			  }
-			  for( i=0; i<block_size_samples; i++ ) {
-				  /* last frame input data are encoded now */
-				  DTimeSigBuf[chanNum][i] = DTimeSigLookAheadBuf[chanNum][i];
-				  DTimeSigLookAheadBuf[chanNum][i] = as->inputBuffer[chanNum][i];
-			  } /* end for(i ..) */
-	  } /* end for(chanNum ... ) */
+	  for (chanNum = 0; chanNum < max_ch; chanNum++) {
 
-	  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])*0.5;
+		  if (channelInfo[chanNum].present) {
+			  if ((channelInfo[chanNum].cpe) && (channelInfo[chanNum].ch_is_left)) { /* CPE */
+				  int leftChan = chanNum;
+				  int rightChan = channelInfo[chanNum].paired_ch;
+
+				  if (as->use_MS == 1) {
+					  for(i = 0; i < block_size_samples; i++){
+						  DTimeSigLookAheadBuf[leftChan][i] = (as->inputBuffer[leftChan][i]+as->inputBuffer[rightChan][i])*0.5;
+						  DTimeSigLookAheadBuf[rightChan][i] = (as->inputBuffer[leftChan][i]-as->inputBuffer[rightChan][i])*0.5;
+					  }
 				  }
 			  }
-			  else {
-				  for(i = 0; i < block_size_samples; i++){
-					  DTimeSigLookAheadBuf[chanNum][i] = (as->inputBuffer[0][i]-as->inputBuffer[1][i])*0.5;
+
+			  if(as->use_LTP) {
+				  for( i=0; i<block_size_samples; i++ ) {
+					  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++ ) {
+				  DTimeSigBuf[chanNum][i] = DTimeSigLookAheadBuf[chanNum][i];
+				  DTimeSigLookAheadBuf[chanNum][i] = as->inputBuffer[chanNum][i];
+			  }
 		  }
 	  }
   }
 
+
   if (fixed_stream == NULL) {
     psy_fill_lookahead(DTimeSigLookAheadBuf, max_ch);
-    return FNO_ERROR; /* quick'n'dirty fix for encoder startup    HP 21-aug-96 */
+    return FNO_ERROR; /* quick'n'dirty fix for encoder startup */
   }
 
   /* Keep track of number of bits used */
   used_bits = 0;
 
-  /***********************************************************************/
-  /* Determine channel elements      */
-  /***********************************************************************/
-  DetermineChInfo(channelInfo, max_ch);
-
-  /*****************************************************************************
-  *
-  * psychoacoustic
-  *
-  *****************************************************************************/
+  /*****************************************************************************/
+  /* psychoacoustics */
+  /*****************************************************************************/
   EncTf_psycho_acoustic(
 	  sampling_rate,
 	  max_ch,
@@ -344,11 +340,9 @@
 	  chpo_short
 	  );
 
-  /*****************************************************************************
-  *
-  * block_switch processing
-  *
-  *****************************************************************************/
+  /*****************************************************************************/
+  /* block_switch processing */
+  /*****************************************************************************/
   {
     int chanNum;
 	
@@ -444,9 +438,7 @@
 
 
   /*****************************************************************************
-  *
-  * T/F mapping
-  *
+  * T/F mapping (MDCT)
   *****************************************************************************/
   {
     int chanNum, k;
@@ -473,9 +465,7 @@
   }
 
   /*****************************************************************************
-  *
   * adapt ratios of psychoacoustic module to codec scale factor bands
-  *
   *****************************************************************************/
 
   {
@@ -527,9 +517,7 @@
   }
 
   /*****************************************************************************
-  *
   * quantization and coding
-  *
   *****************************************************************************/
   {
 //  int padding_limit = max_bitreservoir_bits;
@@ -757,7 +745,7 @@
       if (channelInfo[chanNum].present) {
         /* Write out a single_channel_element */
         if (!channelInfo[chanNum].cpe) {
-          /* Write out sce */ /* BugFix by YT  '+=' sould be '=' */
+          /* Write out sce */
 	  WriteSCE(&quantInfo[chanNum],   /* Quantization information */
 		   channelInfo[chanNum].tag,
 		   fixed_stream,           /* Bitstream */
--- a/ms.c
+++ b/ms.c
@@ -84,7 +84,7 @@
 
 							if (block_type[leftChan] == ONLY_SHORT_WINDOW) {
 								for (j = groupIndex; j < quantInfo[leftChan].window_group_length[g]+groupIndex; j++) {
-									use_ms_short = min(use_ms_short, p_chpo_short[1][j].use_ms[sfbNum]);
+									use_ms_short = min(use_ms_short, p_chpo_short[rightChan][j].use_ms[sfbNum]);
 								}
 								if (sfbNum < isBand) {
 									msInfo->ms_used[b] = use_ms_short;
@@ -99,8 +99,8 @@
 									used++;
 									for (j = groupIndex; j < quantInfo[leftChan].window_group_length[g]+groupIndex; j++) {
 										p_ratio_short[leftChan][(g*maxSfb)+sfbNum] = p_chpo_short[leftChan][j].p_ratio[sfbNum];
-										p_ratio_short[1][(g*maxSfb)+sfbNum] = p_chpo_short[1][j].p_ratio[sfbNum];
-										p_chpo_short[1][j].use_ms[sfbNum] = use_ms_short;
+										p_ratio_short[rightChan][(g*maxSfb)+sfbNum] = p_chpo_short[rightChan][j].p_ratio[sfbNum];
+										p_chpo_short[rightChan][j].use_ms[sfbNum] = use_ms_short;
 									}
 								}
 								else {
@@ -107,29 +107,29 @@
 									notused++;
 									for (j = groupIndex; j < quantInfo[leftChan].window_group_length[g]+groupIndex; j++) {
 										p_ratio_short[leftChan][(g*maxSfb)+sfbNum] = p_chpo_short[leftChan][j].p_ratio[sfbNum];
-										p_ratio_short[1][(g*maxSfb)+sfbNum] = p_chpo_short[1][j].p_ratio[sfbNum];
-										p_chpo_short[1][j].use_ms[sfbNum] = use_ms_short;
+										p_ratio_short[rightChan][(g*maxSfb)+sfbNum] = p_chpo_short[rightChan][j].p_ratio[sfbNum];
+										p_chpo_short[rightChan][j].use_ms[sfbNum] = use_ms_short;
 									}
 								}
 							}
 							else {
 								if (sfbNum < isBand) {
-									msInfo->ms_used[b] = p_chpo_long[1].use_ms[sfbNum];
+									msInfo->ms_used[b] = p_chpo_long[rightChan].use_ms[sfbNum];
 								}
 								else {
 									msInfo->ms_used[b] = 0;
-									p_chpo_long[1].use_ms[sfbNum] = 0;
+									p_chpo_long[rightChan].use_ms[sfbNum] = 0;
 								}
 								if (msInfo->ms_used[b]) {
 									realyused = 1;
 									used++;
 									p_ratio_long[leftChan][sfbNum] = p_chpo_long[leftChan].p_ratio[sfbNum];
-									p_ratio_long[1][sfbNum] = p_chpo_long[1].p_ratio[sfbNum];
+									p_ratio_long[rightChan][sfbNum] = p_chpo_long[rightChan].p_ratio[sfbNum];
 								}
 								else {
 									notused++;
 									p_ratio_long[leftChan][sfbNum] = p_chpo_long[leftChan].p_ratio[sfbNum];
-									p_ratio_long[1][sfbNum] = p_chpo_long[1].p_ratio[sfbNum];
+									p_ratio_long[rightChan][sfbNum] = p_chpo_long[rightChan].p_ratio[sfbNum];
 								}
 							}
 						}
@@ -139,6 +139,8 @@
 					if (realyused) {
 						channelInfo[leftChan].common_window = 1;  /* Use common window */
 						channelInfo[leftChan].ms_info.is_present=1;
+						channelInfo[rightChan].common_window = 1;  /* Use common window */
+						channelInfo[rightChan].ms_info.is_present=1;
 					}
 				}
 				else if ((block_type[leftChan]==block_type[rightChan])&&(use_ms == 1)) {
@@ -151,6 +153,8 @@
 
 					channelInfo[leftChan].ms_info.is_present = 1;
 					channelInfo[leftChan].common_window = 1;
+					channelInfo[rightChan].ms_info.is_present = 1;
+					channelInfo[rightChan].common_window = 1;
 
 					for (chan = 0; chan < 2; chan++) {
 						int chan2;
@@ -172,13 +176,13 @@
 									msInfo->ms_used[b] = 1;
 									for (j = groupIndex; j < quantInfo[chan2].window_group_length[g]+groupIndex; j++) {
 										p_ratio_short[chan2][(g*maxSfb)+sfbNum] = p_chpo_short[chan2][j].p_ratio[sfbNum];
-										p_chpo_short[1][j].use_ms[sfbNum] = 1;
+										p_chpo_short[rightChan][j].use_ms[sfbNum] = 1;
 									}
 								}
 								else {
 									msInfo->ms_used[b] = 1;
 									p_ratio_long[chan2][sfbNum] = p_chpo_long[chan2].p_ratio[sfbNum];
-									p_chpo_long[1].use_ms[sfbNum] = 1;
+									p_chpo_long[rightChan].use_ms[sfbNum] = 1;
 								}
 							}
 //							groupIndex+=quantInfo[chan2].window_group_length[g];
@@ -213,13 +217,13 @@
 									msInfo->ms_used[b] = 0;
 									for (j = groupIndex; j < quantInfo[chan].window_group_length[g]+groupIndex; j++) {
 										p_ratio_short[chan2][(g*maxSfb)+sfbNum] = p_chpo_short[chan2][j].p_ratio[sfbNum];
-										p_chpo_short[1][j].use_ms[sfbNum] = 0;
+										p_chpo_short[rightChan][j].use_ms[sfbNum] = 0;
 									}
 								}
 								else {
 									msInfo->ms_used[b] = 0;
 									p_ratio_long[chan2][sfbNum] = p_chpo_long[chan2].p_ratio[sfbNum];
-									p_chpo_long[1].use_ms[sfbNum] = 0;
+									p_chpo_long[rightChan].use_ms[sfbNum] = 0;
 								}
 							}
 //							groupIndex+=quantInfo[chan2].window_group_length[g];
@@ -263,10 +267,10 @@
 					int sfb;
 
 					if (block_type[chanNum] == ONLY_SHORT_WINDOW) {
-						p_use_ms = p_chpo_short[1][w].use_ms;
+						p_use_ms = p_chpo_short[rightChan][w].use_ms;
 					}
 					else {
-						p_use_ms = p_chpo_long[1].use_ms;
+						p_use_ms = p_chpo_long[rightChan].use_ms;
 					}
 
 					j = w*windowLength;
@@ -282,7 +286,7 @@
 							if ((p_use_ms[sfb]||(use_ms==1))&&(use_ms!=-1)) {
 								dtmp = (spectral_line_vector[leftChan][j]+spectral_line_vector[rightChan][j])*0.5;
 								energy[leftChan][bandNumber] += dtmp*dtmp;
-								dtmp = (spectral_line_vector[0][j]-spectral_line_vector[1][j])*0.5;
+								dtmp = (spectral_line_vector[leftChan][j]-spectral_line_vector[rightChan][j])*0.5;
 								energy[rightChan][bandNumber] += dtmp*dtmp;
 							} else {
 								dtmp = spectral_line_vector[leftChan][j];
@@ -363,6 +367,8 @@
 
 					channelInfo[leftChan].common_window = 1;  /* Use common window */
 					channelInfo[leftChan].ms_info.is_present=1;
+					channelInfo[rightChan].common_window = 1;  /* Use common window */
+					channelInfo[rightChan].ms_info.is_present=1;
 
 					numGroups = quantInfo[leftChan].num_window_groups;
 					maxSfb = quantInfo[leftChan].max_sfb;
@@ -428,12 +434,14 @@
 				int rightChan=channelInfo[chanNum].paired_ch;
 				int numGroups;
 				int maxSfb;
-				int g,b,w,line_offset;
+				int g,/*b,*/w,line_offset;
 				int startWindow,stopWindow;
 				MS_Info *msInfo;
 
 				channelInfo[leftChan].common_window = 1;  /* Use common window */
 				channelInfo[leftChan].ms_info.is_present=1;
+				channelInfo[rightChan].common_window = 1;  /* Use common window */
+				channelInfo[rightChan].ms_info.is_present=1;
 
 				numGroups = quantInfo[leftChan].num_window_groups;
 				maxSfb = quantInfo[leftChan].max_sfb;
@@ -441,7 +449,7 @@
 				/* Determine which bands should be enabled */
 				/* Right now, simply enable bands which do not use intensity stereo */
 				msInfo = &(channelInfo[leftChan].ms_info);
-#if 1
+#if 0
 				for (g=0;g<numGroups;g++) {
 					for (sfbNum=0;sfbNum<maxSfb;sfbNum++) {
 						b = g*maxSfb+sfbNum;
--- a/psych.c
+++ b/psych.c
@@ -517,7 +517,7 @@
 					&psy_stvar_short[leftChan],	&fft_tbl_long, &fft_tbl_short, leftChan);
 				psy_step2(sample, &psy_stvar_long[rightChan],
 					&psy_stvar_short[rightChan], &fft_tbl_long, &fft_tbl_short, rightChan);
-				if (use_MS >= 0)
+				if (use_MS == 0)
 					psy_step2MS(psy_stvar_long, psy_stvar_short,
 					leftChan, rightChan, midChan, sideChan);
 
@@ -530,7 +530,7 @@
 					&psy_var_long[0], &psy_var_short[0]);
 				psy_step4(&psy_stvar_long[rightChan], &psy_stvar_short[rightChan],
 					&psy_var_long[1], &psy_var_short[1]);
-				if (use_MS >= 0)
+				if (use_MS == 0)
 					psy_step4MS(psy_var_long, psy_var_short, 0, 1, 2, 3);
 
 				psy_step5(&part_tbl_long, &part_tbl_short, &psy_stvar_long[leftChan], &psy_stvar_short[leftChan],
@@ -537,7 +537,7 @@
 					&psy_var_long[0], &psy_var_short[0]);
 				psy_step5(&part_tbl_long, &part_tbl_short, &psy_stvar_long[rightChan], &psy_stvar_short[rightChan],
 					&psy_var_long[1], &psy_var_short[1]);
-				if (use_MS >= 0) {
+				if (use_MS == 0) {
 					psy_step5(&part_tbl_long, &part_tbl_short, &psy_stvar_long[midChan], &psy_stvar_short[midChan],
 						&psy_var_long[2], &psy_var_short[2]);
 					psy_step5(&part_tbl_long, &part_tbl_short, &psy_stvar_long[sideChan], &psy_stvar_short[sideChan],
@@ -548,7 +548,7 @@
 					&psy_var_long[0], &psy_var_short[0]);
 				psy_step6(&part_tbl_long, &part_tbl_short, &psy_stvar_long[rightChan], &psy_stvar_short[rightChan],
 					&psy_var_long[1], &psy_var_short[1]);
-				if (use_MS >= 0) {
+				if (use_MS == 0) {
 					psy_step6(&part_tbl_long, &part_tbl_short, &psy_stvar_long[midChan], &psy_stvar_short[midChan],
 						&psy_var_long[2], &psy_var_short[2]);
 					psy_step6(&part_tbl_long, &part_tbl_short, &psy_stvar_long[sideChan], &psy_stvar_short[sideChan],
@@ -557,13 +557,13 @@
 
 				psy_step7(&part_tbl_long, &part_tbl_short, &psy_var_long[0], &psy_var_short[0]);
 				psy_step7(&part_tbl_long, &part_tbl_short, &psy_var_long[1], &psy_var_short[1]);
-				if (use_MS >= 0) {
+				if (use_MS == 0) {
 					psy_step7MS(psy_var_long, psy_var_short, 0, 1, 2, 3);
 				}
 
 				psy_step8(&part_tbl_long, &part_tbl_short, &psy_var_long[0], &psy_var_short[0]);
 				psy_step8(&part_tbl_long, &part_tbl_short, &psy_var_long[1], &psy_var_short[1]);
-				if (use_MS >= 0) {
+				if (use_MS == 0) {
 					psy_step8(&part_tbl_long, &part_tbl_short, &psy_var_long[2], &psy_var_short[2]);
 					psy_step8(&part_tbl_long, &part_tbl_short, &psy_var_long[3], &psy_var_short[3]);
 				}
@@ -570,7 +570,7 @@
 
 				psy_step9(&part_tbl_long, &part_tbl_short, &psy_var_long[0], &psy_var_short[0]);
 				psy_step9(&part_tbl_long, &part_tbl_short, &psy_var_long[1], &psy_var_short[1]);
-				if (use_MS >= 0) {
+				if (use_MS == 0) {
 					psy_step9(&part_tbl_long, &part_tbl_short, &psy_var_long[2], &psy_var_short[2]);
 					psy_step9(&part_tbl_long, &part_tbl_short, &psy_var_long[3], &psy_var_short[3]);
 				}
@@ -579,18 +579,18 @@
 					&psy_var_long[0], &psy_var_short[0]);
 				psy_step10(&part_tbl_long, &part_tbl_short, &psy_stvar_long[rightChan], &psy_stvar_short[rightChan], 
 					&psy_var_long[1], &psy_var_short[1]);
-				if (use_MS >= 0) {
+				if (use_MS == 0) {
 					psy_step10(&part_tbl_long, &part_tbl_short, &psy_stvar_long[midChan], &psy_stvar_short[midChan], 
 						&psy_var_long[2], &psy_var_short[2]);
 					psy_step10(&part_tbl_long, &part_tbl_short, &psy_stvar_long[sideChan], &psy_stvar_short[sideChan], 
 						&psy_var_long[3], &psy_var_short[3]);
-
-					psy_step11MS(&part_tbl_long, &part_tbl_short, psy_stvar_long, psy_stvar_short, no_of_chan);
 				}
 
+				psy_step11MS(&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[leftChan], &psy_stvar_short[leftChan]);
 				psy_step11(&part_tbl_long, &part_tbl_short, &psy_stvar_long[rightChan], &psy_stvar_short[rightChan]);
-				if (use_MS >= 0) {
+				if (use_MS == 0) {
 					psy_step11(&part_tbl_long, &part_tbl_short, &psy_stvar_long[midChan], &psy_stvar_short[midChan]);
 					psy_step11(&part_tbl_long, &part_tbl_short, &psy_stvar_long[sideChan], &psy_stvar_short[sideChan]);
 				}
@@ -612,7 +612,7 @@
 					&psy_stvar_short[leftChan], &psy_var_long[0], &psy_var_short[0]);
 				psy_step14(p_sri, &part_tbl_long, &part_tbl_short, &psy_stvar_long[rightChan],
 					&psy_stvar_short[rightChan], &psy_var_long[1], &psy_var_short[1]);
-				if (use_MS >= 0) {
+				if (use_MS == 0) {
 					psy_step14(p_sri, &part_tbl_long, &part_tbl_short, &psy_stvar_long[midChan],
 						&psy_stvar_short[midChan], &psy_var_long[2], &psy_var_short[2]);
 					psy_step14(p_sri, &part_tbl_long, &part_tbl_short, &psy_stvar_long[sideChan],
@@ -623,13 +623,8 @@
 						leftChan, rightChan, midChan, sideChan);
 				}
 
-				if (use_MS == 1) {
-					p_chpo_long[leftChan].p_ratio   = psy_stvar_long[midChan].ismr;
-					p_chpo_long[rightChan].p_ratio   = psy_stvar_long[sideChan].ismr;
-				} else {
-					p_chpo_long[leftChan].p_ratio   = psy_stvar_long[leftChan].ismr;
-					p_chpo_long[rightChan].p_ratio   = psy_stvar_long[rightChan].ismr;
-				}
+				p_chpo_long[leftChan].p_ratio   = psy_stvar_long[leftChan].ismr;
+				p_chpo_long[rightChan].p_ratio   = psy_stvar_long[rightChan].ismr;
 				p_chpo_long[leftChan].cb_width  = p_sri->cb_width_long;
 				p_chpo_long[rightChan].cb_width  = p_sri->cb_width_long;
 				p_chpo_long[leftChan].no_of_cb = p_sri->num_cb_long;
@@ -638,13 +633,8 @@
 				memcpy(p_chpo_long[rightChan].use_ms, psy_stvar_long[rightChan].use_ms, NSFB_LONG*sizeof(int));
 
 				for( i=0; i<MAX_SHORT_WINDOWS; i++ ) {
-					if (use_MS == 1) {
-						p_chpo_short[leftChan][i].p_ratio  = psy_stvar_short[midChan].ismr[i];
-						p_chpo_short[rightChan][i].p_ratio  = psy_stvar_short[sideChan].ismr[i];
-					} else {
-						p_chpo_short[leftChan][i].p_ratio  = psy_stvar_short[leftChan].ismr[i];
-						p_chpo_short[rightChan][i].p_ratio  = psy_stvar_short[rightChan].ismr[i];
-					}
+					p_chpo_short[leftChan][i].p_ratio  = psy_stvar_short[leftChan].ismr[i];
+					p_chpo_short[rightChan][i].p_ratio  = psy_stvar_short[rightChan].ismr[i];
 					p_chpo_short[leftChan][i].cb_width = p_sri->cb_width_short;
 					p_chpo_short[rightChan][i].cb_width = p_sri->cb_width_short;
 					p_chpo_short[leftChan][i].no_of_cb = p_sri->num_cb_short;