www.pudn.com > AVS_M_ver10.rar > deci12k8.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. ************************************************************************ */ /*-------------------------------------------------------------------* * Function decim_12k8() and oversamp_12k8() * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * decim_12k8 : decimation from fs to 12.8kHz. * * oversamp_12k8 : oversampling from 12.8kHz to fs. * * * * fs = 16/22/24/28.8/32/44/48 kHz. * *-------------------------------------------------------------------*/ #include#include #include #include "../include/amr_plus.h" #define L_FRAME_MAX (L_FRAME24k) #define L_FILT_MAX (L_FILT24k) #define L_SUBFR16k 80 /* Subframe size at 16kHz */ static void interpol_add(float *signal, float *signal_int, int L_frame_int, const float *filter, int nb_coef, int fac_up, int fac_down, float gain); void decim_12k8( float sig_fs[], /* input: signal to decimate */ int lg, /* input: length of input */ float sig12k8[], /* output: decimated signal */ float mem[], /* in/out: memory (2*L_FILT_FS) */ int band) /* input: 0=0..6.4k, 1=6.4..10.8k */ { int i, ncoef; float signal[(2*L_FILT_MAX)+L_FRAME_MAX]; const float *filter; float gain; int fac_up, fac_down; gain = 1.0; switch (lg) { case L_FRAME16kPLUS: ncoef = NCOEF_32k; fac_up = FAC1_32k; fac_down = FAC2_32k; if (band == 0) { filter = filter_32k; } else { if (lg == L_FRAME16kPLUS) { filter = filter_32k_7k; } else { filter = filter_32k_hf; } } break; case L_FRAME24k: ncoef = NCOEF_48k; fac_up = FAC1_48k; fac_down = FAC2_48k; if (band == 0) { filter = filter_48k; } else { filter = filter_48k_hf; } break; case L_FRAME8k: /* This mode actually upsamples rather than down */ ncoef = NCOEF_32k>>2; fac_up = FAC1_32k*2; fac_down = FAC2_32k; filter = filter_8k; gain = 2.0f; break; default: printf("wrong frame size in decim_12k8!\n"); exit(0); break; } if (lg <= L_FRAME24k) { ncoef = (ncoef+1)>>1; fac_up *= 2; gain *= 2.0; } for (i=0; i<(2*ncoef); i++) { signal[i] = mem[i]; } for (i=0; i fac_up_minus_frac_step) { pos += pos_step_plus_one; frac -= fac_up_minus_frac_step; } else { pos += pos_step; frac += frac_step; } } return; } static void interpol_add(float *signal, float *signal_int, int L_frame_int, const float *filter, int nb_coef, int fac_up, int fac_down, float gain) { int i, j, frac, frac_step, pos, pos_step; int pos_step_plus_one, fac_up_minus_frac_step; float s, *x1, *x2, tmp; const float *c1, *c2; pos_step = fac_down / fac_up; pos_step_plus_one = pos_step + 1; frac_step = fac_down - (pos_step*fac_up); fac_up_minus_frac_step = fac_up-frac_step; pos = 0; frac = 0; for(i=0; i fac_up_minus_frac_step) { pos += pos_step_plus_one; frac -= fac_up_minus_frac_step; } else { pos += pos_step; frac += frac_step; } } return; }