www.pudn.com > AVS_M_ver10.rar > dec_tcx_stereo.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. ************************************************************************ */ #include#include #include #include #include "../include/amr_plus.h" /* prototypes*/ void dec_prm_tcx_stereo(int mod[], /* (i) : frame mode (mode[4], 4 division) */ int param[], /* (i) : parameters */ short serial[], /* (o) : serial bits stream */ int nbits); void init_tcx_stereo_decoder(Decoder_State_Plus *st) { st->mem_stereo_ovlp_size = 0; set_zero(st->mem_stereo_ovlp,L_OVLP_2k); st->mem_balance = 0; } float d_balance( /* output: gain */ int index /* (i) : index */ ) { float balance = (float) index / 32.0f - 2.0f; return(balance); } void dtcx_stereo(float synth[], /* in/out: synth[-M..lg] */ float mono[], float wovlp[], /* i/o: wovlp[0..127] */ int ovlp_size, /* input: 0, 64 or 128 (0=acelp) */ int L_frame, /* input: frame length */ int prm[], int pre_echo, int bad_frame[], Decoder_State_Plus *st) { int i, k, i_subfr, lg; float tmp, gain; int any_bad_frame; float xri[L_TCX_LB]; float *xnq=xri; float wm_arr[L_TCX_LB+ECU_WIEN_ORD]; float window[32+32]; float *wm = &wm_arr[ECU_WIEN_ORD]; float balance; float gain_shap[8]; float rmm[ECU_WIEN_ORD+1]; float rms[ECU_WIEN_ORD+1]; float *h; int lext=32; int n_pack = 4; /*------ set length of overlap (lext) and length of encoded frame (lg) -----*/ for (i=0;i< ECU_WIEN_ORD;i++) { wm_arr[i] = 0; } h = st->h; switch (L_frame) { case 40: lext = 8; n_pack=1; break; case 80: lext = 16; n_pack =2; break; case 160: lext = 32; n_pack= 4; break; }; lg = L_frame + lext; any_bad_frame = 0; for (i=0; i mem_balance); st->mem_balance = balance; } else { /* balance is safe */ balance = d_balance(prm[0]); st->mem_balance = balance; } if (pre_echo) { for(i=0;i side_rms)); if (L_frame!=40 || bad_frame[0]==0) { for(i=0; i mem_stereo_ovlp, st->mem_stereo_ovlp_size, L_FRAME_2k/4, prm, !mod[k], bad_frame+k, st); st->mem_stereo_ovlp_size = L_OVLP_2k/4; k++; } else if (mod[k] == 2) { dtcx_stereo( &synth_side[k*L_DIV_2k], &synth_2k[k*L_DIV_2k], st->mem_stereo_ovlp, st->mem_stereo_ovlp_size, L_FRAME_2k/2, prm,0, bad_frame+k, st); st->mem_stereo_ovlp_size = L_OVLP_2k/2; k+=2; } else if(mod[k] == 3) { dtcx_stereo( &synth_side[k*L_DIV_2k], &synth_2k[k*L_DIV_2k], st->mem_stereo_ovlp, st->mem_stereo_ovlp_size, L_FRAME_2k, prm, 0, bad_frame+k, st); st->mem_stereo_ovlp_size = L_OVLP_2k; k+=4; } else { printf("\n error, unknown mode"); exit(-1); } } k=0; while(k