Ignore:
Timestamp:
Jul 26, 2006 5:04:54 PM (18 years ago)
Author:
bennylp
Message:
  • Bring speex codec up to date with their SVN trunk
  • Speex codec should work in FIXED_POINT mode when PJ_HAS_FLOATING_POINT is set to zero.
  • ulaw2linear will return zero if zero is given (this would make the VAD works better, and it also fixed click noise when call is established/hangup).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/speex/nb_celp.h

    r278 r628  
    4949/**Structure representing the full state of the narrowband encoder*/ 
    5050typedef struct EncState { 
    51    const SpeexMode *mode;       /**< Mode corresponding to the state */ 
    52    int    first;          /**< Is this the first frame? */ 
    53    int    frameSize;      /**< Size of frames */ 
    54    int    subframeSize;   /**< Size of sub-frames */ 
    55    int    nbSubframes;    /**< Number of sub-frames */ 
    56    int    windowSize;     /**< Analysis (LPC) window length */ 
    57    int    lpcSize;        /**< LPC order */ 
    58    int    min_pitch;      /**< Minimum pitch value allowed */ 
    59    int    max_pitch;      /**< Maximum pitch value allowed */ 
     51   const SpeexMode *mode;        /**< Mode corresponding to the state */ 
     52   int    first;                 /**< Is this the first frame? */ 
     53   int    frameSize;             /**< Size of frames */ 
     54   int    subframeSize;          /**< Size of sub-frames */ 
     55   int    nbSubframes;           /**< Number of sub-frames */ 
     56   int    windowSize;            /**< Analysis (LPC) window length */ 
     57   int    lpcSize;               /**< LPC order */ 
     58   int    min_pitch;             /**< Minimum pitch value allowed */ 
     59   int    max_pitch;             /**< Maximum pitch value allowed */ 
    6060 
    61    int    safe_pitch;     /**< Don't use too large values for pitch (in case we lose a packet) */ 
    62    int    bounded_pitch;  /**< Next frame should not rely on previous frames for pitch */ 
    63    int    ol_pitch;       /**< Open-loop pitch */ 
    64    int    ol_voiced;      /**< Open-loop voiced/non-voiced decision */ 
     61   spx_word32_t cumul_gain;      /**< Product of previously used pitch gains (Q10) */ 
     62   int    bounded_pitch;         /**< Next frame should not rely on previous frames for pitch */ 
     63   int    ol_pitch;              /**< Open-loop pitch */ 
     64   int    ol_voiced;             /**< Open-loop voiced/non-voiced decision */ 
    6565   int   *pitch; 
    6666 
     
    7171#ifdef VORBIS_PSYCHO 
    7272   VorbisPsy *psy; 
     73   float *psy_window; 
    7374   float *curve; 
    7475   float *old_curve; 
     
    7778   spx_word16_t  gamma1;         /**< Perceptual filter: A(z/gamma1) */ 
    7879   spx_word16_t  gamma2;         /**< Perceptual filter: A(z/gamma2) */ 
    79    float  lag_factor;     /**< Lag windowing Gaussian width */ 
     80   float  lag_factor;            /**< Lag windowing Gaussian width */ 
    8081   spx_word16_t  lpc_floor;      /**< Noise floor multiplier for A[0] in LPC analysis*/ 
    81    char  *stack;          /**< Pseudo-stack allocation for temporary memory */ 
    82    spx_sig_t *inBuf;          /**< Input buffer (original signal) */ 
    83    spx_sig_t *frame;          /**< Start of original frame */ 
    84    spx_sig_t *excBuf;         /**< Excitation buffer */ 
    85    spx_sig_t *exc;            /**< Start of excitation frame */ 
    86    spx_sig_t *swBuf;          /**< Weighted signal buffer */ 
    87    spx_sig_t *sw;             /**< Start of weighted signal frame */ 
    88    spx_sig_t *innov;          /**< Innovation for the frame */ 
    89    spx_word16_t *window;         /**< Temporary (Hanning) window */ 
    90    spx_word16_t *autocorr;       /**< auto-correlation */ 
     82   char  *stack;                 /**< Pseudo-stack allocation for temporary memory */ 
     83   spx_word16_t *winBuf;         /**< Input buffer (original signal) */ 
     84   spx_word16_t *excBuf;         /**< Excitation buffer */ 
     85   spx_word16_t *exc;            /**< Start of excitation frame */ 
     86   spx_word16_t *swBuf;          /**< Weighted signal buffer */ 
     87   spx_word16_t *sw;             /**< Start of weighted signal frame */ 
     88   const spx_word16_t *window;   /**< Temporary (Hanning) window */ 
    9189   spx_word16_t *lagWindow;      /**< Window applied to auto-correlation */ 
    92    spx_coef_t *lpc;            /**< LPCs for current frame */ 
    93    spx_lsp_t *lsp;            /**< LSPs for current frame */ 
    94    spx_lsp_t *qlsp;           /**< Quantized LSPs for current frame */ 
    95    spx_lsp_t *old_lsp;        /**< LSPs for previous frame */ 
    96    spx_lsp_t *old_qlsp;       /**< Quantized LSPs for previous frame */ 
    97    spx_lsp_t *interp_lsp;     /**< Interpolated LSPs */ 
    98    spx_lsp_t *interp_qlsp;    /**< Interpolated quantized LSPs */ 
    99    spx_coef_t *interp_lpc;     /**< Interpolated LPCs */ 
    100    spx_coef_t *interp_qlpc;    /**< Interpolated quantized LPCs */ 
    101    spx_coef_t *bw_lpc1;        /**< LPCs after bandwidth expansion by gamma1 for perceptual weighting*/ 
    102    spx_coef_t *bw_lpc2;        /**< LPCs after bandwidth expansion by gamma2 for perceptual weighting*/ 
    103    spx_mem_t *mem_sp;         /**< Filter memory for signal synthesis */ 
    104    spx_mem_t *mem_sw;         /**< Filter memory for perceptually-weighted signal */ 
    105    spx_mem_t *mem_sw_whole;   /**< Filter memory for perceptually-weighted signal (whole frame)*/ 
    106    spx_mem_t *mem_exc;        /**< Filter memory for excitation (whole frame) */ 
     90   spx_lsp_t *old_lsp;           /**< LSPs for previous frame */ 
     91   spx_lsp_t *old_qlsp;          /**< Quantized LSPs for previous frame */ 
     92   spx_mem_t *mem_sp;            /**< Filter memory for signal synthesis */ 
     93   spx_mem_t *mem_sw;            /**< Filter memory for perceptually-weighted signal */ 
     94   spx_mem_t *mem_sw_whole;      /**< Filter memory for perceptually-weighted signal (whole frame)*/ 
     95   spx_mem_t *mem_exc;           /**< Filter memory for excitation (whole frame) */ 
     96   spx_mem_t *mem_exc2;          /**< Filter memory for excitation (whole frame) */ 
    10797   spx_word32_t *pi_gain;        /**< Gain of LPC filter at theta=pi (fe/2) */ 
    108  
    109    VBRState *vbr;         /**< State of the VBR data */ 
    110    float  vbr_quality;    /**< Quality setting for VBR encoding */ 
    111    float  relative_quality; /**< Relative quality that will be needed by VBR */ 
    112    int    vbr_enabled;    /**< 1 for enabling VBR, 0 otherwise */ 
    113    int    vad_enabled;    /**< 1 for enabling VAD, 0 otherwise */ 
    114    int    dtx_enabled;    /**< 1 for enabling DTX, 0 otherwise */ 
    115    int    dtx_count;      /**< Number of consecutive DTX frames */ 
    116    int    abr_enabled;    /**< ABR setting (in bps), 0 if off */ 
     98   spx_sig_t *innov_save;        /**< If non-NULL, innovation is copied here */ 
     99          
     100   VBRState *vbr;                /**< State of the VBR data */ 
     101   float  vbr_quality;           /**< Quality setting for VBR encoding */ 
     102   float  relative_quality;      /**< Relative quality that will be needed by VBR */ 
     103   int    vbr_enabled;           /**< 1 for enabling VBR, 0 otherwise */ 
     104   spx_int32_t vbr_max;          /**< Max bit-rate allowed in VBR mode */ 
     105   int    vad_enabled;           /**< 1 for enabling VAD, 0 otherwise */ 
     106   int    dtx_enabled;           /**< 1 for enabling DTX, 0 otherwise */ 
     107   int    dtx_count;             /**< Number of consecutive DTX frames */ 
     108   spx_int32_t abr_enabled;      /**< ABR setting (in bps), 0 if off */ 
    117109   float  abr_drift; 
    118110   float  abr_drift2; 
    119111   float  abr_count; 
    120    int    complexity;     /**< Complexity setting (0-10 from least complex to most complex) */ 
    121    int    sampling_rate; 
     112   int    complexity;            /**< Complexity setting (0-10 from least complex to most complex) */ 
     113   spx_int32_t sampling_rate; 
    122114   int    plc_tuning; 
    123115   int    encode_submode; 
    124116   const SpeexSubmode * const *submodes; /**< Sub-mode data */ 
    125    int    submodeID;      /**< Activated sub-mode */ 
    126    int    submodeSelect;  /**< Mode chosen by the user (may differ from submodeID if VAD is on) */ 
     117   int    submodeID;             /**< Activated sub-mode */ 
     118   int    submodeSelect;         /**< Mode chosen by the user (may differ from submodeID if VAD is on) */ 
    127119} EncState; 
    128120 
     
    130122typedef struct DecState { 
    131123   const SpeexMode *mode;       /**< Mode corresponding to the state */ 
    132    int    first;          /**< Is this the first frame? */ 
    133    int    count_lost;     /**< Was the last frame lost? */ 
    134    int    frameSize;      /**< Size of frames */ 
    135    int    subframeSize;   /**< Size of sub-frames */ 
    136    int    nbSubframes;    /**< Number of sub-frames */ 
    137    int    lpcSize;        /**< LPC order */ 
    138    int    min_pitch;      /**< Minimum pitch value allowed */ 
    139    int    max_pitch;      /**< Maximum pitch value allowed */ 
    140    int    sampling_rate; 
     124   int    first;                /**< Is this the first frame? */ 
     125   int    count_lost;           /**< Was the last frame lost? */ 
     126   int    frameSize;            /**< Size of frames */ 
     127   int    subframeSize;         /**< Size of sub-frames */ 
     128   int    nbSubframes;          /**< Number of sub-frames */ 
     129   int    lpcSize;              /**< LPC order */ 
     130   int    min_pitch;            /**< Minimum pitch value allowed */ 
     131   int    max_pitch;            /**< Maximum pitch value allowed */ 
     132   spx_int32_t sampling_rate; 
    141133 
    142134#ifdef EPIC_48K 
     
    144136#endif 
    145137 
    146    spx_word16_t  last_ol_gain;   /**< Open-loop gain for previous frame */ 
     138   spx_word16_t  last_ol_gain;  /**< Open-loop gain for previous frame */ 
    147139 
    148    char  *stack;          /**< Pseudo-stack allocation for temporary memory */ 
    149    spx_sig_t *inBuf;          /**< Input buffer (original signal) */ 
    150    spx_sig_t *frame;          /**< Start of original frame */ 
    151    spx_sig_t *excBuf;         /**< Excitation buffer */ 
    152    spx_sig_t *exc;            /**< Start of excitation frame */ 
    153    spx_sig_t *innov;          /**< Innovation for the frame */ 
    154    spx_lsp_t *qlsp;           /**< Quantized LSPs for current frame */ 
    155    spx_lsp_t *old_qlsp;       /**< Quantized LSPs for previous frame */ 
    156    spx_lsp_t *interp_qlsp;    /**< Interpolated quantized LSPs */ 
    157    spx_coef_t *interp_qlpc;    /**< Interpolated quantized LPCs */ 
    158    spx_mem_t *mem_sp;         /**< Filter memory for synthesis signal */ 
    159    spx_word32_t *pi_gain;        /**< Gain of LPC filter at theta=pi (fe/2) */ 
    160    int    last_pitch;     /**< Pitch of last correctly decoded frame */ 
     140   char  *stack;                /**< Pseudo-stack allocation for temporary memory */ 
     141   spx_word16_t *excBuf;        /**< Excitation buffer */ 
     142   spx_word16_t *exc;           /**< Start of excitation frame */ 
     143   spx_lsp_t *old_qlsp;         /**< Quantized LSPs for previous frame */ 
     144   spx_coef_t *interp_qlpc;     /**< Interpolated quantized LPCs */ 
     145   spx_mem_t *mem_sp;           /**< Filter memory for synthesis signal */ 
     146   spx_word32_t *pi_gain;       /**< Gain of LPC filter at theta=pi (fe/2) */ 
     147   spx_sig_t *innov_save;       /** If non-NULL, innovation is copied here */ 
     148    
     149   /* This is used in packet loss concealment */ 
     150   int    last_pitch;           /**< Pitch of last correctly decoded frame */ 
    161151   spx_word16_t  last_pitch_gain; /**< Pitch gain of last correctly decoded frame */ 
    162    spx_word16_t  pitch_gain_buf[3];  /**< Pitch gain of last decoded frames */ 
    163    int    pitch_gain_buf_idx; /**< Tail of the buffer */ 
    164    spx_int32_t seed;          /** Seed used for random number generation */ 
     152   spx_word16_t  pitch_gain_buf[3]; /**< Pitch gain of last decoded frames */ 
     153   int    pitch_gain_buf_idx;   /**< Tail of the buffer */ 
     154   spx_int32_t seed;            /** Seed used for random number generation */ 
    165155    
    166156   int    encode_submode; 
    167157   const SpeexSubmode * const *submodes; /**< Sub-mode data */ 
    168    int    submodeID;      /**< Activated sub-mode */ 
    169    int    lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */ 
    170    CombFilterMem *comb_mem; 
     158   int    submodeID;            /**< Activated sub-mode */ 
     159   int    lpc_enh_enabled;      /**< 1 when LPC enhancer is on, 0 otherwise */ 
    171160   SpeexCallback speex_callbacks[SPEEX_MAX_CALLBACKS]; 
    172161 
     
    174163 
    175164   /*Vocoder data*/ 
    176    float  voc_m1; 
    177    float  voc_m2; 
     165   spx_word16_t  voc_m1; 
     166   spx_word32_t  voc_m2; 
    178167   float  voc_mean; 
    179168   int    voc_offset; 
Note: See TracChangeset for help on using the changeset viewer.