www.pudn.com > AVS_M_ver10.rar > qpisf_2s.c


/* 
*********************************************************************** 
* COPYRIGHT AND WARRANTY INFORMATION 
* 
* Copyright 2007  Audio Video Coding Standard, Part Ⅹ 
* 
* This software module was developed by AVS Audio sub-group 
* 
* DISCLAIMER OF WARRANTY 
* 
* These software programs are available to the users without any 
* license fee or royalty on an "as is" basis. The AVS disclaims 
* any and all warranties, whether express, implied, or statutory, 
* including any implied warranties of merchantability or of fitness 
* for a particular purpose. In no event shall the contributors or  
* the AVS be liable for any incidental, punitive, or consequential 
* damages of any kind whatsoever arising from the use of this program. 
* 
* This disclaimer of warranty extends to the user of this program 
* and user's customers, employees, agents, transferees, successors, 
* and assigns. 
* 
* The AVS does not represent or warrant that the program furnished 
* hereunder are free of infringement of any third-party patents. 
* Commercial implementations of AVS, including shareware, may be 
* subject to royalty fees to patent holders. Information regarding 
* the AVS patent policy is available from the AVS Web site at 
* http://www.avs.org.cn 
* 
* THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE AVS PATENT POLICY. 
************************************************************************ 
*/ 
 
/*-------------------------------------------------------------------* 
 * functions: qpisf_2s() and dpisf_2s()                              * 
 *                                                                   * 
 * Coding/Decoding of ISF parameters  with prediction.               * 
 *                                                                   * 
 * The ISF vector is quantized using two-stage VQ with split-by-2    * 
 * in 1st stage and split-by-5 in the second stage.                  * 
 *-------------------------------------------------------------------*/ 
#include  
#include  
#include "../include/amr_plus.h" 
#define MU       (1.0f/3.0f)     /* prediction factor */ 
#define N_SURV_MAX 4             /* 4 survivors max   */ 
 
#include "./isf_tab_mu.h" 
 
/*------------------------------------------------------------------* 
 * routine:   qpisf_2s()                                            * 
 *            ~~~~~~~~~                                             * 
 * Quantization of ISF parameters with prediction                   * 
 *                                                                  * 
 * The ISF vector is quantized using two-stage VQ with split-by-2   * 
 * in 1st stage and split-by-5 in the second stage.                 * 
 *------------------------------------------------------------------*/ 
static int sub_VQ(float *x, const float *dico, int dim, int dico_size, float *err); 
static void VQ_stage1(float *x, const float *dico, int dim, int dico_size, 
                      int *index, int surv); 
void qpisf_2s_46b( 
  float *isf1,      /* input : ISF in the frequency domain (0..6400) */ 
  float *isf_q,     /* output: quantized ISF                         */ 
  float *past_isfq, /* i/0   : past ISF quantizer                    */ 
  int *indice,      /* output: quantization indices (7 words)        */ 
  int nb_surv       /* input : number of survivor (1, 2, 3 or 4)     */ 
) 
{ 
  int i, k, tmp_ind[5]; 
  int surv1[N_SURV_MAX];     /* indices of survivors from 1st stage */ 
  float temp, min_err, distance, isf[ORDER]; 
  float isf_stage2[ORDER]; 
  for (i=0; i N_SURV_MAX) { 
    nb_surv = N_SURV_MAX; 
  } 
  for (k=0; k 0; j--) 
				{ 
					isf_buf[j*ORDER+i] = isf_buf[(j-1)*ORDER+i]; 
				}                  
				isf_buf[i]=isf_q[i]; 
			} 
		} 
	} 
	else /* bad frame */ 
	{ 
		/* use the past ISFs slightly shifted towards their mean */ 
		for (i = 0; i < ORDER; i++) { 
			ref_isf[i] = mean_isf[i] / (L_MEANBUF+1); 
			for (j = 0; j < L_MEANBUF; j++)  
			{ 
				ref_isf[i] += isf_buf[j*ORDER+i] / (L_MEANBUF+1); 
			} 
		} 
		for (i=0; ik; l--) 
        { 
          dist_min[l] = dist_min[l-1]; 
          index[l] = index[l-1]; 
        } 
        dist_min[k] = dist; 
        index[k] = i; 
        break; 
      } 
    } 
  } 
  return; 
}