⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proto_func.h

📁 关于AMR-WB+语音压缩编码的实现代码
💻 H
📖 第 1 页 / 共 3 页
字号:
int coder_amrwb_plus_mono(float channel_right[],       /* input: used on mono and stereo */
                           int codec_mode,      /* input: AMR-WB+ mode (see cnst.h) */
                           int L_frame, /* input: 80ms frame size */
                           short serial[],      /* output: serial parameters */
                           Coder_State_Plus * st,    /* i/o : coder memory state */
                           short useCaseB, int bwe_flag        /* 32kHz NBWE */
                           );

void coder_amrwb_plus_mono_first(float channel_right[], /* input: used on mono and stereo */
                                 int n_channel, /* input: 1 or 2 (mono/stereo) */
                                 int L_frame,   /* input: frame size */
                                 int L_next,    /* input: lookahead */
                                 int bwe_flag,  /* for 32kHz NBWE */
                                 Coder_State_Plus * st       /* i/o : coder memory state */
    );

int coder_amrwb_plus_first(float channel_right[],      /* input: used on mono and stereo */
                            float channel_left[],       /* input: used on stereo only */
                            int n_channel,      /* input: 1 or 2 (mono/stereo) */
                            int L_frame,        /* input: frame size */
                            int L_next, /* input: lookahead */
                            int bwe_flag,       /* AriL: for 32kHz NBWE */
                            Coder_State_Plus * st    /* i/o : coder memory state */
    );

void init_decoder_amrwb_plus(Decoder_State_Plus * st, int num_chan, int fscale, short full_reset);

int decoder_amrwb_plus(int codec_mode, /* input: AMR-WB+ mode (see cnst.h) */
                        short serial[], /* input: serial parameters (4x20ms) */
                        int bad_frame[],        /* input: bfi (bad_frame[4]) */
                        int L_frame,    /* input: frame size of synthesis */
                        int n_channel,  /* input: 1 or 2 (mono/stereo) */
                        float channel_right[],  /* (o): used on mono and stereo */
                        float channel_left[],   /* (o): used on stereo only */
                        Decoder_State_Plus * st,     /* i/o : decoder memory state */
                        int fscale,   
                        int StbrMode, 
		        int mono_dec_stereo,
                        short upsamp_fscale);

void decoder_amrwb_plus_1(float *chan_right,
                          float *chan_left,
                          int *mod,
                          int *param,
                          int *prm_hf_right,
                          int *prm_hf_left,
                          int *nbits_AVQ,
                          int codec_mode,
                          int *bad_frame,
                          int *bad_frame_hf,
                          float *AqLF,
                          float *synth,
                          int *pitch,
                          float *pit_gain, Decoder_State_Plus * st, int n_channel, int L_frame, int bwe_flag, 
						  int mono_dec_stereo);

/*---------------------------------------------------------------------*
 *              low freq band routines (0..6400Hz)                     *
 *---------------------------------------------------------------------*/

void init_coder_lf(Coder_State_Plus * st);
void coder_lf(int codec_mode,   /* (i) : AMR-WB+ mode (see cnst.h) */
              float speech[],   /* (i) : speech vector [-M..L_FRAME_PLUS+L_NEXT] */
              float synth[],    /* (o) : synthesis vector [-M..L_FRAME_PLUS] */
              int mod[],        /* (o) : mode for each 20ms frame (mode[4] */
              float AqLF[],     /* (o) : quantized coefficients (AdLF[16]) */
              float window[],   /* (i) : window for LPC analysis */
              int param[],      /* (o) : parameters (NB_DIV*NPRM_DIV) */
              float ol_gain[],  /* (o) : open-loop LTP gain */
              int ave_T_out[],  /* (o) : average LTP lag */
              float ave_p_out[],        /* (o) : average LTP gain */
              short coding_mod[],       /* (i) : selected mode for each 20ms */
              int fscale, Coder_State_Plus * st   /* i/o : coder memory state */
    );
void coder_lf_b(int codec_mode, /* (i) : AMR-WB+ mode (see cnst.h) */
                float speech[], /* (i) : speech vector [-M..L_FRAME_PLUS+L_NEXT] */
                float synth[],  /* (o) : synthesis vector [-M..L_FRAME_PLUS] */
                int mod[],      /* (o) : mode for each 20ms frame (mode[4] */
                float AqLF[],   /* (o) : quantized coefficients (AdLF[16]) */
                float window[], /* (i) : window for LPC analysis */
                int param[],    /* (o) : parameters (NB_DIV*NPRM_DIV) */
                float ol_gain[],        /* (o) : open-loop LTP gain */
                int ave_T_out[],        /* (o) : average LTP lag */
                float ave_p_out[],      /* (o) : average LTP gain */
                short coding_mod[],     /* (i) : selected mode for each 20ms */
		int pit_adj,
                Coder_State_Plus * st        /* i/o : coder memory state */
    );

void init_decoder_lf(Decoder_State_Plus * st);

void decoder_lf(int mod[],      /* (i) : mode for each 20ms frame (mode[4] */
                int prm[],      /* (i) : parameters */
                int nbits_AVQ[],        /* (i) : for each frame (nbits_AVQ[4]) */
                int codec_mode, /* (i) : AMR-WB+ mode (see cnst.h) */
                int bad_frame[],        /* (i) : for each frame (bad_frame[4]) */
                float AqLF[],   /* (o) : decoded coefficients (AdLF[16]) */
                float fexc[],   /* (o) : decoded excitation */
                float fsynth[], /* (o) : decoded synthesis */
                int pitch[],    /* (o) : decoded pitch (pitch[16]) */
                float pit_gain[],       /* (o) : decoded pitch gain (pit_gain[16]) */
                int fscale,
                Decoder_State_Plus * st);    /* i/o : coder memory state */

void init_bass_postfilter(Decoder_State_Plus * st);
void bass_postfilter(float *synth_in,   /* (i) : 12.8kHz synthesis to postfilter */
                     int *T_sf, /* (i) : Pitch period for all subframe (T_sf[16]) */
                     float *gainT_sf,   /* (i) : Pitch gain for all subframe (gainT_sf[16]) */
                     float *synth_out,  /* (o) : filtered synthesis (with delay=L_SUBFR+L_FILT) */
                     int fscale, Decoder_State_Plus * st);        /* i/o : decoder memory state */

/*---------------------------------------------------------------------*
 *              high freq band routines (6400Hz..10800Hz)              *
 *---------------------------------------------------------------------*/

void init_coder_hf(Coder_StState * st);
void coder_hf(int mod[],        /* (i) : mode for each 20ms frame (mode[4] */
              float AqLF[],     /* (i) : Q coeff in lower band (AdLF[16]) */
              float speech[],   /* (i) : speech vector [-M..L_FRAME_PLUS] */
              float speech_hf[],        /* (i) : HF speech vec [-MHF..L_FRAME_PLUS+L_NEXT] */
              float synth_hf[], /* (o) : HF synthesis [0..L_FRAME_PLUS] */
              float window[],   /* (i) : window for LPC analysis */
              int param[],      /* (o) : parameters (NB_DIV*NPRM_HF_DIV) */
              int fscale, Coder_StState * st);       /* i/o : coder memory state */

void init_decoder_hf(Decoder_StState * st);
void decoder_hf(int mod[],      /* (i) : mode for each 20ms frame (mode[4] */
                int param[],    /* (i) : parameters */
                int param_other[],      /* (i) : parameters for the right channel in case of mono decoding with stereo bitstream */
                int mono_dec_stereo,    /* 1=Mono decoding with stereo bitstream */
                int bad_frame[],        /* (i) : for each frame (bad_frame[4]) */
                float AqLF[],   /* (i) : decoded coefficients (AdLF[16]) */
                float exc[],    /* (i) : decoded excitation */
                float fsynth_hf[],      /* (o) : decoded synthesis */
				float mem_lpc_hf[],
				float *mem_gain_hf,
				short *ramp_state,
                Decoder_StState * st    /* i/o : decoder memory state */
    );

/*---------------------------------------------------------------------*
 *                   stereo routines (0..6400Hz)                       *
 *---------------------------------------------------------------------*/

/*-----------------------------------------------------------------*
 * Function coder_stereo                                            *
 * ~~~~~~~~~~~~~~~~~~~~                                            *
 *   ->Principle stereo coder routine (working at fs=12.8kHz).     *
 *                                                                 *
 * Note: HF band are encoded twice (2 channels) using 0.8kbps BWE. *
 *       Usage of 2xBWE for stereo provide better time domain      *
 *       stereo definition in HF without increasing the bit-rate.  *
 *       Another advantage is that the stereo decoder is limited   *
 *       to the lower band (fs=12.8kHz) and this reduce the        *
 *       overall complexity of the AMR-WB+ codec.  Also, this      *
 *       solution is not dependent of the AMR-WB+ mode where many  *
 *       different sampling frequencies are used (16, 24, 32 kHz). *
 *-----------------------------------------------------------------*/

void coder_stereo_x(float speech_hi[],  /* (i) : Mixed channel, hi */
                    float chan_hi[],    /* (i) : Right channel, hi */
                    float speech_2k[],  /* (i) : Mixed channel, lo */
                    float chan_2k[],    /* (i) : Right channel, lo */
                    float AqLF[], int brMode, int param[],      /* (o) : Encoded parameters */
                    int fscale, Coder_State_Plus * st);   /* (i/o): Encoder states */

/*-----------------------------------------------------------------*
 * Function  init_coder_stereo                                      *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~                                      *
 *   ->Initialization of variables for the stereo coder.           *
 *-----------------------------------------------------------------*/
void init_coder_stereo_x(Coder_State_Plus * st); /* (i/o) : Encoder states. */

/*-----------------------------------------------------------------*
 * Function  end_prm_stereo									       *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~                                      *
 *   ->Encoding of stereo parameters.					           *
 *-----------------------------------------------------------------*/

void enc_prm_stereo(int param[],        /* (i) : parameters */
                    short serial[],     /* (o) : serial bits stream */
                    int nbits_pack,     /* (i) : number of bits per packet of 20ms */
                    int brMode, Coder_State_Plus * st        /* (i) : Encoder states */
    );

void enc_prm_stereo_x(int param[],      /* (i) : parameters */
                      short serial[],   /* (o) : serial bits stream */
                      int nbits_pack,   /* (i) : number of bits per packet of 20ms */
                      int nbits_bwe,    /* (i) : number of BWE bits per 20ms  */
                      int brMode);

void filt_design(float *spL,    /* (i) : Speech input (L) */
                 float *spR,    /* (i) : Speech input (R) */
                 float *spM,    /* (i) : Speech input (M) */
                 float *filter, /* (o) : Filter coeff output */
                 Coder_State_Plus * st,      /* (i/o): Filter states */
                 int frame_length, int lb,      /* (i) : Look-back */
                 int anaframe_length    /* (i) : Analysis frame length */
    );

void enc_quant_frame(int *prm, short *ptr, Coder_State_Plus * st);

void init_decoder_stereo_x(Decoder_State_Plus * st);

void decoder_stereo_x(int param[],
                      int bad_frame[],
                      float sig_left[], float sig_right[], float AqLF[], int StbrMode, int fscale, Decoder_State_Plus * st);

void conceal_filt(float *filt_lo_ptr, float *filt_hi_ptr, Decoder_State_Plus * st);

void dec_quant_frame(int *prm, short *ptr, Decoder_State_Plus * st);

/*---------------------------------------------------------------------*
 *             Parameters encoding/decoding routines                   *
 *---------------------------------------------------------------------*/

void enc_prm(int mode[],        /* (i) : frame mode (mode[4], 4 division) */
             int codec_mode,    /* (i) : AMR-WB+ mode (see cnst.h) */
             int param[],       /* (i) : parameters */
             short serial[],    /* (o) : serial bits stream */
             int nbits_pack     /* (i) : number of bits per packet of 20ms */
    );
void enc_prm_hf(int mod[],      /* (i) : frame mode (mode[4], 4 division) */
                int param[],    /* (i) : parameters */
                short serial[], /* (o) : serial bits stream */
                int nbits_pack  /* (i) : number of bits per packet of 20ms */
    );
void enc_prm_stereo(int param[],        /* (i) : parameters */
                    short serial[],     /* (o) : serial bits stream */
                    int nbits_pack,     /* (i) : number of bits per packet of 20ms */
                    int brMode, Coder_State_Plus * st        /* (i) : Encoder states */
    );

void enc_prm_stereo_x(int param[],      /* (i) : parameters */
                      short serial[],   /* (o) : serial bits stream */
                      int nbits_pack,   /* (i) : number of bits per packet of 20ms */
                      int nbits_bwe,    /* (i) : number of BWE bits per 20ms  */
                      int brMode);

void dec_prm(int mod[],         /* (i) : frame mode (mode[4], 4 frames) */
             int bad_frame[],   /* (i) : bfi for 4 frames (bad_frame[4]) */
             short serial[],    /* (i) : serial bits stream */
             int nbits_pack,    /* (i) : number of bits per packet of 20ms */
             int codec_mode,    /* (i) : AMR-WB+ mode (see cnst.h) */
             int param[],       /* (o) : decoded parameters */
             int nbits_AVQ[]);  /* (o) : nb of bits for AVQ (4 division) */

void dec_prm_hf(int mod[],      /* (i) : frame mode (mode[4], 4 frames) */
                int bad_frame[],        /* (i) : bfi for 4 frames (bad_frame[4]) */
                short serial[], /* (i) : serial bits stream */
                int nbits_pack, /* (i) : number of bits per packet of 20ms */
                int param[]);   /* (o) : decoded parameters */

void dec_prm_stereo(int bad_frame[],    /* (i) : bfi for 4 frames (bad_frame[4]) */
                    short serial[],     /* (i) : serial bits stream */
                    int nbits_pack,     /* (i) : number of bits per packet of 20ms */
                    int param[],        /* (o) : decoded parameters */
                    int brMode, Decoder_State_Plus * st);

void dec_prm_stereo_x(int bad_frame[],  /* (i) : bfi for 4 frames (bad_frame[4]) */
                      short serial[],   /* (i) : serial bits stream */
                      int nbits_pack,   /* (i) : number of bits per packet of 20ms */
                      int nbits_bwe,    /* (i) : number of BWE bits per 20ms  */
                      int param[],      /* (o) : decoded parameters */
                      int brMode, Decoder_State_Plus * st);

/*---------------------------------------------------------------------*
 *              ACELP routines                                         *
 *---------------------------------------------------------------------*/

void coder_acelp(float A[],     /* input: coefficients 4xAz[M+1] */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -