ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sb_celp.h Source File

sb_celp.h

Go to the documentation of this file.
00001 /* Copyright (C) 2002-2006 Jean-Marc Valin */
00002 /**
00003    @file sb_celp.h
00004    @brief Sub-band CELP mode used for wideband encoding
00005 */
00006 /*
00007    Redistribution and use in source and binary forms, with or without
00008    modification, are permitted provided that the following conditions
00009    are met:
00010    
00011    - Redistributions of source code must retain the above copyright
00012    notice, this list of conditions and the following disclaimer.
00013    
00014    - Redistributions in binary form must reproduce the above copyright
00015    notice, this list of conditions and the following disclaimer in the
00016    documentation and/or other materials provided with the distribution.
00017    
00018    - Neither the name of the Xiph.org Foundation nor the names of its
00019    contributors may be used to endorse or promote products derived from
00020    this software without specific prior written permission.
00021    
00022    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00026    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00030    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 #ifndef SB_CELP_H
00037 #define SB_CELP_H
00038 
00039 #include "modes.h"
00040 #include <speex/speex_bits.h>
00041 #include "nb_celp.h"
00042 
00043 /**Structure representing the full state of the sub-band encoder*/
00044 typedef struct SBEncState {
00045    const SpeexMode *mode;         /**< Pointer to the mode (containing for vtable info) */
00046    void *st_low;                  /**< State of the low-band (narrowband) encoder */
00047    int    full_frame_size;        /**< Length of full-band frames*/
00048    int    frame_size;             /**< Length of high-band frames*/
00049    int    subframeSize;           /**< Length of high-band sub-frames*/
00050    int    nbSubframes;            /**< Number of high-band sub-frames*/
00051    int    windowSize;             /**< Length of high-band LPC window*/
00052    int    lpcSize;                /**< Order of high-band LPC analysis */
00053    int    bufSize;                /**< Buffer size */
00054    int    first;                  /**< First frame? */
00055    float  lag_factor;             /**< Lag-windowing control parameter */
00056    spx_word16_t  lpc_floor;       /**< Controls LPC analysis noise floor */
00057    spx_word16_t  gamma1;          /**< Perceptual weighting coef 1 */
00058    spx_word16_t  gamma2;          /**< Perceptual weighting coef 2 */
00059 
00060    char  *stack;                  /**< Temporary allocation stack */
00061    spx_word16_t *high;               /**< High-band signal (buffer) */
00062    spx_word16_t *h0_mem, *h1_mem;
00063 
00064    const spx_word16_t *window;    /**< LPC analysis window */
00065    spx_word16_t *lagWindow;       /**< Auto-correlation window */
00066    spx_lsp_t *old_lsp;            /**< LSPs of previous frame */
00067    spx_lsp_t *old_qlsp;           /**< Quantized LSPs of previous frame */
00068    spx_coef_t *interp_qlpc;       /**< Interpolated quantized LPCs for current sub-frame */
00069 
00070    spx_mem_t *mem_sp;             /**< Synthesis signal memory */
00071    spx_mem_t *mem_sp2;
00072    spx_mem_t *mem_sw;             /**< Perceptual signal memory */
00073    spx_word32_t *pi_gain;
00074    spx_word16_t *exc_rms;
00075    spx_word16_t *innov_rms_save;         /**< If non-NULL, innovation is copied here */
00076 
00077    float  vbr_quality;            /**< Quality setting for VBR encoding */
00078    int    vbr_enabled;            /**< 1 for enabling VBR, 0 otherwise */
00079    spx_int32_t vbr_max;           /**< Max bit-rate allowed in VBR mode (total) */
00080    spx_int32_t vbr_max_high;      /**< Max bit-rate allowed in VBR mode for the high-band */
00081    spx_int32_t abr_enabled;       /**< ABR setting (in bps), 0 if off */
00082    float  abr_drift;
00083    float  abr_drift2;
00084    float  abr_count;
00085    int    vad_enabled;            /**< 1 for enabling VAD, 0 otherwise */
00086    float  relative_quality;
00087 
00088    int    encode_submode;
00089    const SpeexSubmode * const *submodes;
00090    int    submodeID;
00091    int    submodeSelect;
00092    int    complexity;
00093    spx_int32_t sampling_rate;
00094 
00095 } SBEncState;
00096 
00097 
00098 /**Structure representing the full state of the sub-band decoder*/
00099 typedef struct SBDecState {
00100    const SpeexMode *mode;            /**< Pointer to the mode (containing for vtable info) */
00101    void *st_low;               /**< State of the low-band (narrowband) encoder */
00102    int    full_frame_size;
00103    int    frame_size;
00104    int    subframeSize;
00105    int    nbSubframes;
00106    int    lpcSize;
00107    int    first;
00108    spx_int32_t sampling_rate;
00109    int    lpc_enh_enabled;
00110 
00111    char  *stack;
00112    spx_word32_t *g0_mem, *g1_mem;
00113 
00114    spx_word16_t *excBuf;
00115    spx_lsp_t *old_qlsp;
00116    spx_coef_t *interp_qlpc;
00117 
00118    spx_mem_t *mem_sp;
00119    spx_word32_t *pi_gain;
00120    spx_word16_t *exc_rms;
00121    spx_word16_t *innov_save;      /** If non-NULL, innovation is copied here */
00122    
00123    spx_word16_t last_ener;
00124    spx_int32_t seed;
00125 
00126    int    encode_submode;
00127    const SpeexSubmode * const *submodes;
00128    int    submodeID;
00129 } SBDecState;
00130 
00131 
00132 /**Initializes encoder state*/
00133 void *sb_encoder_init(const SpeexMode *m);
00134 
00135 /**De-allocates encoder state resources*/
00136 void sb_encoder_destroy(void *state);
00137 
00138 /**Encodes one frame*/
00139 int sb_encode(void *state, void *in, SpeexBits *bits);
00140 
00141 
00142 /**Initializes decoder state*/
00143 void *sb_decoder_init(const SpeexMode *m);
00144 
00145 /**De-allocates decoder state resources*/
00146 void sb_decoder_destroy(void *state);
00147 
00148 /**Decodes one frame*/
00149 int sb_decode(void *state, SpeexBits *bits, void *out);
00150 
00151 int sb_encoder_ctl(void *state, int request, void *ptr);
00152 
00153 int sb_decoder_ctl(void *state, int request, void *ptr);
00154 
00155 #endif