www.pudn.com > aacenc.rar > aac_back_pred.c



/*********************************************************************
 *
 * aac_back_pred.c  -  AAC 后向预测程序
 *
 *
**********************************************************************/

/**********************************************************************

INPUT:
"	act_spec[]表示当前帧要编码的频谱成分; 
"	last_spec[]表示前一帧的量化频谱误差; 
"	btype为当前帧的窗口类型; 
"	]nsfb为比例因子频带的数目; 
"	isfb_width[]为比例因子带宽。 

OUTPUT:
"	act_spec[]为当前要编码帧的频谱误差; 
"	pred_global_flag为全局预测使能/禁止标志; 
"	pred_sbf_glag[]为每个比例因子通带的使能和禁止标志; 
"	reset_group为其余组的数目,如果为-1则表示没有其余的组。 

***********************************************************************/

#include "aac_back_pred.h"


static int psy_init_mc[MAX_TIME_CHANNELS];
static float dr_mc[MAX_TIME_CHANNELS][LPC][FLEN_LONG/2],e_mc[MAX_TIME_CHANNELS][LPC+1+1][FLEN_LONG/2];
static float K_mc[MAX_TIME_CHANNELS][LPC+1][FLEN_LONG/2], R_mc[MAX_TIME_CHANNELS][LPC+1][FLEN_LONG/2];
static float VAR_mc[MAX_TIME_CHANNELS][LPC+1][FLEN_LONG/2], KOR_mc[MAX_TIME_CHANNELS][LPC+1][FLEN_LONG/2];
static float sb_samples_pred_mc[MAX_TIME_CHANNELS][FLEN_LONG/2];
static int thisLineNeedsResetting_mc[MAX_TIME_CHANNELS][FLEN_LONG/2];
static int reset_count_mc[MAX_TIME_CHANNELS];

void PredInit() {
  int i;
  for (i=0;i=1;j--) 
	R[j][i] = A*(R[j-1][i]-dr[j][i]);
      R[0][i] = A*e[0][i];
    }


  /**************************************************/
  /*   在这里重置状态*/           
  /**************************************************/
   for (i=0;iMINVAR)
	  K[j][i] = KOR[j][i]/VAR[j][i]*B;
	else
	  K[j][i] = 0;
      }
    }


   for (k=0; k0.0) num_bit+=snr[i]/6.*isfb_width[i];	

  pred_global_flag[0]=1;
  if(num_bit<100 /*50*/) {
    pred_global_flag[0]=0; num_bit=0.0; 
    for (j=0; j= 31 * RESET_FRAME)
    *reset_count = RESET_FRAME;
  if (*reset_count % RESET_FRAME == 0)
  { /* Send a reset in this frame */
    *reset_group = *reset_count / 8;

    for (i = *reset_group - 1; i < FLEN_LONG / 2; i += 30)
    {
      thisLineNeedsResetting[i]=1;
    }
  }
  else
    *reset_group = -1;



 

 /* Ensure that prediction data is sent when there is a prediction
  * reset.
  */
  if (*reset_group != -1 && pred_global_flag[0] == 0)
  {
    pred_global_flag[0] = 1;
    for (i = 0; i < nsfb; i++)
      pred_sfb_flag[i] = 0;
  }
 /* End of code segment */


}