Logo Search packages:      
Sourcecode: iaxclient version File versions  Download package

modes.h

Go to the documentation of this file.
/* Copyright (C) 2002 Jean-Marc Valin */
/**
   @file modes.h
   @brief Describes the different modes of the codec
*/
/*
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
   are met:
   
   - Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
   
   - Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
   
   - Neither the name of the Xiph.org Foundation nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.
   
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

#ifndef MODES_H
#define MODES_H

#include <speex/speex.h>
#include <speex/speex_bits.h>
#include "misc.h"

#define NB_SUBMODES 16
#define NB_SUBMODE_BITS 4

#define SB_SUBMODES 8
#define SB_SUBMODE_BITS 3


/** Quantizes LSPs */
00051 typedef void (*lsp_quant_func)(spx_lsp_t *, spx_lsp_t *, int, SpeexBits *);

/** Decodes quantized LSPs */
00054 typedef void (*lsp_unquant_func)(spx_lsp_t *, int, SpeexBits *);


/** Long-term predictor quantization */
00058 typedef int (*ltp_quant_func)(spx_sig_t *, spx_sig_t *, spx_coef_t *, spx_coef_t *, 
                              spx_coef_t *, spx_sig_t *, const void *, int, int, spx_word16_t, 
                              int, int, SpeexBits*, char *, spx_sig_t *, spx_word16_t *, int, int, int);

/** Long-term un-quantize */
00063 typedef void (*ltp_unquant_func)(spx_sig_t *, int, int, spx_word16_t, const void *, int, int *,
                                 spx_word16_t *, SpeexBits*, char*, int, int, spx_word16_t, int);


/** Innovation quantization function */
00068 typedef void (*innovation_quant_func)(spx_sig_t *, spx_coef_t *, spx_coef_t *, spx_coef_t *, const void *, int, int, 
                                      spx_sig_t *, spx_word16_t *, SpeexBits *, char *, int, int);

/** Innovation unquantization function */
00072 typedef void (*innovation_unquant_func)(spx_sig_t *, const void *, int, SpeexBits*, char *);

/** Description of a Speex sub-mode (wither narrowband or wideband */
00075 typedef struct SpeexSubmode {
00076    int     lbr_pitch;          /**< Set to -1 for "normal" modes, otherwise encode pitch using a global pitch and allowing a +- lbr_pitch variation (for low not-rates)*/
00077    int     forced_pitch_gain;  /**< Use the same (forced) pitch gain for all sub-frames */
00078    int     have_subframe_gain; /**< Number of bits to use as sub-frame innovation gain */
00079    int     double_codebook;    /**< Apply innovation quantization twice for higher quality (and higher bit-rate)*/
   /*LSP functions*/
00081    lsp_quant_func    lsp_quant; /**< LSP quantization function */
00082    lsp_unquant_func  lsp_unquant; /**< LSP unquantization function */

   /*Lont-term predictor functions*/
00085    ltp_quant_func    ltp_quant; /**< Long-term predictor (pitch) quantizer */
00086    ltp_unquant_func  ltp_unquant; /**< Long-term predictor (pitch) un-quantizer */
00087    const void             *ltp_params; /**< Pitch parameters (options) */

   /*Quantization of innovation*/
00090    innovation_quant_func innovation_quant; /**< Innovation quantization */
00091    innovation_unquant_func innovation_unquant; /**< Innovation un-quantization */
00092    const void             *innovation_params; /**< Innovation quantization parameters*/

   /*Synthesis filter enhancement*/
00095    spx_word16_t      lpc_enh_k1; /**< Enhancer constant */
00096    spx_word16_t      lpc_enh_k2; /**< Enhancer constant */
00097    spx_word16_t      lpc_enh_k3; /**< Enhancer constant */
00098    spx_word16_t      comb_gain;  /**< Gain of enhancer comb filter */

00100    int               bits_per_frame; /**< Number of bits per frame after encoding*/
} SpeexSubmode;

/** Struct defining the encoding/decoding mode*/
00104 typedef struct SpeexNBMode {
00105    int     frameSize;      /**< Size of frames used for encoding */
00106    int     subframeSize;   /**< Size of sub-frames used for encoding */
00107    int     lpcSize;        /**< Order of LPC filter */
00108    int     pitchStart;     /**< Smallest pitch value allowed */
00109    int     pitchEnd;       /**< Largest pitch value allowed */

00111    spx_word16_t gamma1;    /**< Perceptual filter parameter #1 */
00112    spx_word16_t gamma2;    /**< Perceptual filter parameter #2 */
00113    float   lag_factor;     /**< Lag-windowing parameter */
00114    float   lpc_floor;      /**< Noise floor for LPC analysis */

#ifdef EPIC_48K
   int     lbr48k;         /**< 1 for the special 4.8 kbps mode */
#endif

00120    const SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */
00121    int     defaultSubmode; /**< Default sub-mode to use when encoding */
00122    int     quality_map[11]; /**< Mode corresponding to each quality setting */
} SpeexNBMode;


/** Struct defining the encoding/decoding mode for SB-CELP (wideband) */
00127 typedef struct SpeexSBMode {
00128    const SpeexMode *nb_mode;    /**< Embedded narrowband mode */
00129    int     frameSize;     /**< Size of frames used for encoding */
00130    int     subframeSize;  /**< Size of sub-frames used for encoding */
00131    int     lpcSize;       /**< Order of LPC filter */
00132    int     bufSize;       /**< Signal buffer size in encoder */
00133    spx_word16_t gamma1;   /**< Perceptual filter parameter #1 */
00134    spx_word16_t gamma2;   /**< Perceptual filter parameter #1 */
00135    float   lag_factor;    /**< Lag-windowing parameter */
00136    float   lpc_floor;     /**< Noise floor for LPC analysis */
   float   folding_gain;

00139    const SpeexSubmode *submodes[SB_SUBMODES]; /**< Sub-mode data for the mode */
00140    int     defaultSubmode; /**< Default sub-mode to use when encoding */
00141    int     low_quality_map[11]; /**< Mode corresponding to each quality setting */
00142    int     quality_map[11]; /**< Mode corresponding to each quality setting */
   const float (*vbr_thresh)[11];
   int     nb_modes;
} SpeexSBMode;

int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits);
int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out);

int nb_mode_query(const void *mode, int request, void *ptr);
int wb_mode_query(const void *mode, int request, void *ptr);

#endif

Generated by  Doxygen 1.6.0   Back to index