[xiph-commits] r11651 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Sun Jun 25 08:51:11 PDT 2006


Author: jm
Date: 2006-06-25 08:51:07 -0700 (Sun, 25 Jun 2006)
New Revision: 11651

Modified:
   trunk/speex/libspeex/nb_celp.c
   trunk/speex/libspeex/nb_celp.h
   trunk/speex/libspeex/sb_celp.c
   trunk/speex/libspeex/sb_celp.h
Log:
SPEEX_SET_VBR_MAX_BITRATE partially implemented for wideband (still doesn't 
work)


Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2006-06-25 12:14:04 UTC (rev 11650)
+++ trunk/speex/libspeex/nb_celp.c	2006-06-25 15:51:07 UTC (rev 11651)
@@ -1911,7 +1911,8 @@
    case SPEEX_GET_VBR_MAX_BITRATE:
       (*(spx_int32_t*)ptr) = st->vbr_max;
       break;
-         
+
+
    /* This is all internal stuff past this point */
    case SPEEX_GET_PI_GAIN:
       {

Modified: trunk/speex/libspeex/nb_celp.h
===================================================================
--- trunk/speex/libspeex/nb_celp.h	2006-06-25 12:14:04 UTC (rev 11650)
+++ trunk/speex/libspeex/nb_celp.h	2006-06-25 15:51:07 UTC (rev 11651)
@@ -48,20 +48,20 @@
 
 /**Structure representing the full state of the narrowband encoder*/
 typedef struct EncState {
-   const SpeexMode *mode;       /**< Mode corresponding to the state */
-   int    first;          /**< Is this the first frame? */
-   int    frameSize;      /**< Size of frames */
-   int    subframeSize;   /**< Size of sub-frames */
-   int    nbSubframes;    /**< Number of sub-frames */
-   int    windowSize;     /**< Analysis (LPC) window length */
-   int    lpcSize;        /**< LPC order */
-   int    min_pitch;      /**< Minimum pitch value allowed */
-   int    max_pitch;      /**< Maximum pitch value allowed */
+   const SpeexMode *mode;        /**< Mode corresponding to the state */
+   int    first;                 /**< Is this the first frame? */
+   int    frameSize;             /**< Size of frames */
+   int    subframeSize;          /**< Size of sub-frames */
+   int    nbSubframes;           /**< Number of sub-frames */
+   int    windowSize;            /**< Analysis (LPC) window length */
+   int    lpcSize;               /**< LPC order */
+   int    min_pitch;             /**< Minimum pitch value allowed */
+   int    max_pitch;             /**< Maximum pitch value allowed */
 
-   spx_word32_t cumul_gain; /**< Product of previously used pitch gains (Q10) */
-   int    bounded_pitch;  /**< Next frame should not rely on previous frames for pitch */
-   int    ol_pitch;       /**< Open-loop pitch */
-   int    ol_voiced;      /**< Open-loop voiced/non-voiced decision */
+   spx_word32_t cumul_gain;      /**< Product of previously used pitch gains (Q10) */
+   int    bounded_pitch;         /**< Next frame should not rely on previous frames for pitch */
+   int    ol_pitch;              /**< Open-loop pitch */
+   int    ol_voiced;             /**< Open-loop voiced/non-voiced decision */
    int   *pitch;
 
 #ifdef EPIC_48K
@@ -95,7 +95,7 @@
    spx_mem_t *mem_exc;           /**< Filter memory for excitation (whole frame) */
    spx_mem_t *mem_exc2;          /**< Filter memory for excitation (whole frame) */
    spx_word32_t *pi_gain;        /**< Gain of LPC filter at theta=pi (fe/2) */
-   spx_sig_t *innov_save;        /** If non-NULL, innovation is copied here */
+   spx_sig_t *innov_save;        /**< If non-NULL, innovation is copied here */
          
    VBRState *vbr;                /**< State of the VBR data */
    float  vbr_quality;           /**< Quality setting for VBR encoding */
@@ -121,42 +121,42 @@
 /**Structure representing the full state of the narrowband decoder*/
 typedef struct DecState {
    const SpeexMode *mode;       /**< Mode corresponding to the state */
-   int    first;          /**< Is this the first frame? */
-   int    count_lost;     /**< Was the last frame lost? */
-   int    frameSize;      /**< Size of frames */
-   int    subframeSize;   /**< Size of sub-frames */
-   int    nbSubframes;    /**< Number of sub-frames */
-   int    lpcSize;        /**< LPC order */
-   int    min_pitch;      /**< Minimum pitch value allowed */
-   int    max_pitch;      /**< Maximum pitch value allowed */
+   int    first;                /**< Is this the first frame? */
+   int    count_lost;           /**< Was the last frame lost? */
+   int    frameSize;            /**< Size of frames */
+   int    subframeSize;         /**< Size of sub-frames */
+   int    nbSubframes;          /**< Number of sub-frames */
+   int    lpcSize;              /**< LPC order */
+   int    min_pitch;            /**< Minimum pitch value allowed */
+   int    max_pitch;            /**< Maximum pitch value allowed */
    int    sampling_rate;
 
 #ifdef EPIC_48K
    int    lbr_48k;
 #endif
 
-   spx_word16_t  last_ol_gain;   /**< Open-loop gain for previous frame */
+   spx_word16_t  last_ol_gain;  /**< Open-loop gain for previous frame */
 
-   char  *stack;          /**< Pseudo-stack allocation for temporary memory */
-   spx_word16_t *excBuf;         /**< Excitation buffer */
-   spx_word16_t *exc;            /**< Start of excitation frame */
-   spx_lsp_t *old_qlsp;       /**< Quantized LSPs for previous frame */
-   spx_coef_t *interp_qlpc;    /**< Interpolated quantized LPCs */
-   spx_mem_t *mem_sp;         /**< Filter memory for synthesis signal */
-   spx_word32_t *pi_gain;        /**< Gain of LPC filter at theta=pi (fe/2) */
-   spx_sig_t *innov_save;      /** If non-NULL, innovation is copied here */
+   char  *stack;                /**< Pseudo-stack allocation for temporary memory */
+   spx_word16_t *excBuf;        /**< Excitation buffer */
+   spx_word16_t *exc;           /**< Start of excitation frame */
+   spx_lsp_t *old_qlsp;         /**< Quantized LSPs for previous frame */
+   spx_coef_t *interp_qlpc;     /**< Interpolated quantized LPCs */
+   spx_mem_t *mem_sp;           /**< Filter memory for synthesis signal */
+   spx_word32_t *pi_gain;       /**< Gain of LPC filter at theta=pi (fe/2) */
+   spx_sig_t *innov_save;       /** If non-NULL, innovation is copied here */
    
    /* This is used in packet loss concealment */
-   int    last_pitch;     /**< Pitch of last correctly decoded frame */
+   int    last_pitch;           /**< Pitch of last correctly decoded frame */
    spx_word16_t  last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
-   spx_word16_t  pitch_gain_buf[3];  /**< Pitch gain of last decoded frames */
-   int    pitch_gain_buf_idx; /**< Tail of the buffer */
-   spx_int32_t seed;          /** Seed used for random number generation */
+   spx_word16_t  pitch_gain_buf[3]; /**< Pitch gain of last decoded frames */
+   int    pitch_gain_buf_idx;   /**< Tail of the buffer */
+   spx_int32_t seed;            /** Seed used for random number generation */
    
    int    encode_submode;
    const SpeexSubmode * const *submodes; /**< Sub-mode data */
-   int    submodeID;      /**< Activated sub-mode */
-   int    lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */
+   int    submodeID;            /**< Activated sub-mode */
+   int    lpc_enh_enabled;      /**< 1 when LPC enhancer is on, 0 otherwise */
    SpeexCallback speex_callbacks[SPEEX_MAX_CALLBACKS];
 
    SpeexCallback user_callback;

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2006-06-25 12:14:04 UTC (rev 11650)
+++ trunk/speex/libspeex/sb_celp.c	2006-06-25 15:51:07 UTC (rev 11651)
@@ -308,6 +308,7 @@
 
    st->vbr_quality = 8;
    st->vbr_enabled = 0;
+   st->vbr_max = 0;
    st->vad_enabled = 0;
    st->abr_enabled = 0;
    st->relative_quality=0;
@@ -1351,7 +1352,8 @@
       break;
    case SPEEX_SET_BITRATE:
       {
-         int i=10, rate, target;
+         int i=10;
+         spx_int32_t rate, target;
          target = (*(int*)ptr);
          while (i>=0)
          {
@@ -1408,6 +1410,42 @@
       speex_encoder_ctl(st->st_low, SPEEX_GET_LOOKAHEAD, ptr);
       (*(int*)ptr) = 2*(*(int*)ptr) + QMF_ORDER - 1;
       break;
+   case SPEEX_SET_PLC_TUNING:
+      speex_encoder_ctl(st->st_low, SPEEX_SET_PLC_TUNING, ptr);
+      break;
+   case SPEEX_GET_PLC_TUNING:
+      speex_encoder_ctl(st->st_low, SPEEX_GET_PLC_TUNING, ptr);
+      break;
+   case SPEEX_SET_VBR_MAX_BITRATE:
+      {
+         int high_mode;
+         spx_int32_t high_rate;
+         st->vbr_max = (*(spx_int32_t*)ptr);
+         if (SPEEX_SET_VBR_MAX_BITRATE<1)
+            speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_MAX_BITRATE, &st->vbr_max);
+         else {
+            if (st->vbr_max > 42200)
+            {
+               high_mode = 4;
+            } else if (st->vbr_max > 27800)
+            {
+               high_mode = 3;
+            } else if (st->vbr_max > 20600)
+            {
+               high_mode = 2;
+            } else high_mode = 1;
+            high_rate = st->sampling_rate*st->submodes[high_mode]->bits_per_frame/st->full_frame_size;
+            high_rate = st->vbr_max - high_rate;
+            speex_encoder_ctl(st->st_low, SPEEX_SET_VBR_MAX_BITRATE, &high_rate);
+         }
+      }
+      break;
+   case SPEEX_GET_VBR_MAX_BITRATE:
+      (*(spx_int32_t*)ptr) = st->vbr_max;
+      break;
+
+
+   /* This is all internal stuff past this point */
    case SPEEX_GET_PI_GAIN:
       {
          int i;

Modified: trunk/speex/libspeex/sb_celp.h
===================================================================
--- trunk/speex/libspeex/sb_celp.h	2006-06-25 12:14:04 UTC (rev 11650)
+++ trunk/speex/libspeex/sb_celp.h	2006-06-25 15:51:07 UTC (rev 11651)
@@ -42,61 +42,62 @@
 
 /**Structure representing the full state of the sub-band encoder*/
 typedef struct SBEncState {
-   const SpeexMode *mode;            /**< Pointer to the mode (containing for vtable info) */
-   void *st_low;               /**< State of the low-band (narrowband) encoder */
-   int    full_frame_size;     /**< Length of full-band frames*/
-   int    frame_size;          /**< Length of high-band frames*/
-   int    subframeSize;        /**< Length of high-band sub-frames*/
-   int    nbSubframes;         /**< Number of high-band sub-frames*/
-   int    windowSize;          /**< Length of high-band LPC window*/
-   int    lpcSize;             /**< Order of high-band LPC analysis */
-   int    bufSize;             /**< Buffer size */
-   int    first;               /**< First frame? */
-   float  lag_factor;          /**< Lag-windowing control parameter */
-   spx_word16_t  lpc_floor;           /**< Controls LPC analysis noise floor */
-   spx_word16_t  gamma1;              /**< Perceptual weighting coef 1 */
-   spx_word16_t  gamma2;              /**< Perceptual weighting coef 2 */
+   const SpeexMode *mode;         /**< Pointer to the mode (containing for vtable info) */
+   void *st_low;                  /**< State of the low-band (narrowband) encoder */
+   int    full_frame_size;        /**< Length of full-band frames*/
+   int    frame_size;             /**< Length of high-band frames*/
+   int    subframeSize;           /**< Length of high-band sub-frames*/
+   int    nbSubframes;            /**< Number of high-band sub-frames*/
+   int    windowSize;             /**< Length of high-band LPC window*/
+   int    lpcSize;                /**< Order of high-band LPC analysis */
+   int    bufSize;                /**< Buffer size */
+   int    first;                  /**< First frame? */
+   float  lag_factor;             /**< Lag-windowing control parameter */
+   spx_word16_t  lpc_floor;       /**< Controls LPC analysis noise floor */
+   spx_word16_t  gamma1;          /**< Perceptual weighting coef 1 */
+   spx_word16_t  gamma2;          /**< Perceptual weighting coef 2 */
 
-   char  *stack;               /**< Temporary allocation stack */
-   spx_sig_t *x0d, *x1d; /**< QMF filter signals*/
-   spx_sig_t *high;                /**< High-band signal (buffer) */
-   spx_sig_t *y0, *y1;             /**< QMF synthesis signals */
+   char  *stack;                  /**< Temporary allocation stack */
+   spx_sig_t *x0d, *x1d;          /**< QMF filter signals*/
+   spx_sig_t *high;               /**< High-band signal (buffer) */
+   spx_sig_t *y0, *y1;            /**< QMF synthesis signals */
    spx_word16_t *h0_mem, *h1_mem;
    spx_word32_t *g0_mem, *g1_mem; /**< QMF memories */
 
-   spx_sig_t *excBuf;              /**< High-band excitation */
-   spx_sig_t *exc;                 /**< High-band excitation (for QMF only)*/
-   spx_sig_t *res;                 /**< Zero-input response (ringing) */
-   spx_sig_t *sw;                  /**< Perceptually weighted signal */
-   const spx_word16_t *window;              /**< LPC analysis window */
-   spx_word16_t *lagWindow;           /**< Auto-correlation window */
-   spx_word16_t *autocorr;            /**< Auto-correlation (for LPC analysis) */
-   spx_coef_t *lpc;                 /**< LPC coefficients */
-   spx_lsp_t *lsp;                 /**< LSP coefficients */
-   spx_lsp_t *qlsp;                /**< Quantized LSPs */
-   spx_lsp_t *old_lsp;             /**< LSPs of previous frame */
-   spx_lsp_t *old_qlsp;            /**< Quantized LSPs of previous frame */
-   spx_lsp_t *interp_lsp;          /**< Interpolated LSPs for current sub-frame */
-   spx_lsp_t *interp_qlsp;         /**< Interpolated quantized LSPs for current sub-frame */
-   spx_coef_t *interp_lpc;          /**< Interpolated LPCs for current sub-frame */
-   spx_coef_t *interp_qlpc;         /**< Interpolated quantized LPCs for current sub-frame */
-   spx_coef_t *bw_lpc1;             /**< Bandwidth-expanded version of LPCs (#1) */
-   spx_coef_t *bw_lpc2;             /**< Bandwidth-expanded version of LPCs (#2) */
+   spx_sig_t *excBuf;             /**< High-band excitation */
+   spx_sig_t *exc;                /**< High-band excitation (for QMF only)*/
+   spx_sig_t *res;                /**< Zero-input response (ringing) */
+   spx_sig_t *sw;                 /**< Perceptually weighted signal */
+   const spx_word16_t *window;    /**< LPC analysis window */
+   spx_word16_t *lagWindow;       /**< Auto-correlation window */
+   spx_word16_t *autocorr;        /**< Auto-correlation (for LPC analysis) */
+   spx_coef_t *lpc;               /**< LPC coefficients */
+   spx_lsp_t *lsp;                /**< LSP coefficients */
+   spx_lsp_t *qlsp;               /**< Quantized LSPs */
+   spx_lsp_t *old_lsp;            /**< LSPs of previous frame */
+   spx_lsp_t *old_qlsp;           /**< Quantized LSPs of previous frame */
+   spx_lsp_t *interp_lsp;         /**< Interpolated LSPs for current sub-frame */
+   spx_lsp_t *interp_qlsp;        /**< Interpolated quantized LSPs for current sub-frame */
+   spx_coef_t *interp_lpc;        /**< Interpolated LPCs for current sub-frame */
+   spx_coef_t *interp_qlpc;       /**< Interpolated quantized LPCs for current sub-frame */
+   spx_coef_t *bw_lpc1;           /**< Bandwidth-expanded version of LPCs (#1) */
+   spx_coef_t *bw_lpc2;           /**< Bandwidth-expanded version of LPCs (#2) */
 
-   spx_mem_t *mem_sp;              /**< Synthesis signal memory */
+   spx_mem_t *mem_sp;             /**< Synthesis signal memory */
    spx_mem_t *mem_sp2;
-   spx_mem_t *mem_sw;              /**< Perceptual signal memory */
+   spx_mem_t *mem_sw;             /**< Perceptual signal memory */
    spx_word32_t *pi_gain;
-   spx_sig_t *innov_save;      /** If non-NULL, innovation is copied here */
-   spx_sig_t *low_innov;       /** Lower-band innovation is copied here magically */
+   spx_sig_t *innov_save;         /**< If non-NULL, innovation is copied here */
+   spx_sig_t *low_innov;          /**< Lower-band innovation is copied here magically */
 
-   float  vbr_quality;         /**< Quality setting for VBR encoding */
-   int    vbr_enabled;         /**< 1 for enabling VBR, 0 otherwise */
-   int    abr_enabled;         /**< ABR setting (in bps), 0 if off */
+   float  vbr_quality;            /**< Quality setting for VBR encoding */
+   int    vbr_enabled;            /**< 1 for enabling VBR, 0 otherwise */
+   spx_int32_t vbr_max;           /**< Max bit-rate allowed in VBR mode */
+   int    abr_enabled;            /**< ABR setting (in bps), 0 if off */
    float  abr_drift;
    float  abr_drift2;
    float  abr_count;
-   int    vad_enabled;         /**< 1 for enabling VAD, 0 otherwise */
+   int    vad_enabled;            /**< 1 for enabling VAD, 0 otherwise */
    float  relative_quality;
 
    int    encode_submode;



More information about the commits mailing list