Home | History | Annotate | Download | only in src
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 /****************************************************************************************
     19 Portions of this file are derived from the following 3GPP standard:
     20 
     21     3GPP TS 26.073
     22     ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
     23     Available from http://www.3gpp.org
     24 
     25 (C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
     26 Permission to distribute, modify and use this file under the standard license
     27 terms listed above has been obtained from the copyright holder.
     28 ****************************************************************************************/
     29 /*
     30 ------------------------------------------------------------------------------
     31 
     32 
     33 
     34  Filename: /audio/gsm_amr/c/include/gain_q.h
     35 
     36      Date: 02/05/2002
     37 
     38 ------------------------------------------------------------------------------
     39  REVISION HISTORY
     40 
     41  Description: Placed header file in the proper template format.  Added
     42  parameter pOverflow.
     43 
     44  Description: Changed definition of...
     45 
     46     gc_predState     gc_predSt;
     47     gc_predState     gc_predUnqSt;
     48 
     49   in the structure typedef.  These are no longer pointers, which avoids
     50   the need to malloc memory for the pointers.  They are, rather, the actual
     51   structure declared within the gainQuantState structure.
     52 
     53  Description:  Replaced "int" and/or "char" with OSCL defined types.
     54 
     55  Description: Moved _cplusplus #ifdef after Include section.
     56 
     57  Description:
     58 
     59 ------------------------------------------------------------------------------
     60  INCLUDE DESCRIPTION
     61 
     62  This file contains all the constant definitions and prototype definitions
     63  needed by the file, gain_q.c
     64 
     65 ------------------------------------------------------------------------------
     66 */
     67 
     68 /*----------------------------------------------------------------------------
     69 ; CONTINUE ONLY IF NOT ALREADY DEFINED
     70 ----------------------------------------------------------------------------*/
     71 #ifndef gain_q_h
     72 #define gain_q_h "$Id $"
     73 
     74 /*----------------------------------------------------------------------------
     75 ; INCLUDES
     76 ----------------------------------------------------------------------------*/
     77 #include "typedef.h"
     78 #include "mode.h"
     79 #include "gc_pred.h"
     80 #include "g_adapt.h"
     81 
     82 /*--------------------------------------------------------------------------*/
     83 #ifdef __cplusplus
     84 extern "C"
     85 {
     86 #endif
     87 
     88     /*----------------------------------------------------------------------------
     89     ; MACROS
     90     ; Define module specific macros here
     91     ----------------------------------------------------------------------------*/
     92 
     93     /*----------------------------------------------------------------------------
     94     ; DEFINES
     95     ; Include all pre-processor statements here.
     96     ----------------------------------------------------------------------------*/
     97 
     98     /*----------------------------------------------------------------------------
     99     ; EXTERNAL VARIABLES REFERENCES
    100     ; Declare variables used in this module but defined elsewhere
    101     ----------------------------------------------------------------------------*/
    102 
    103     /*----------------------------------------------------------------------------
    104     ; SIMPLE TYPEDEF'S
    105     ----------------------------------------------------------------------------*/
    106 
    107     /*----------------------------------------------------------------------------
    108     ; ENUMERATED TYPEDEF'S
    109     ----------------------------------------------------------------------------*/
    110 
    111     /*----------------------------------------------------------------------------
    112     ; STRUCTURES TYPEDEF'S
    113     ----------------------------------------------------------------------------*/
    114     typedef struct
    115     {
    116         Word16 sf0_exp_gcode0;
    117         Word16 sf0_frac_gcode0;
    118         Word16 sf0_exp_target_en;
    119         Word16 sf0_frac_target_en;
    120         Word16 sf0_exp_coeff[5];
    121         Word16 sf0_frac_coeff[5];
    122         Word16 *gain_idx_ptr;
    123 
    124         gc_predState     gc_predSt;
    125         gc_predState     gc_predUnqSt;
    126         GainAdaptState   *adaptSt;
    127     } gainQuantState;
    128 
    129     /*----------------------------------------------------------------------------
    130     ; GLOBAL FUNCTION DEFINITIONS
    131     ; Function Prototype declaration
    132     ----------------------------------------------------------------------------*/
    133     Word16 gainQuant_init(gainQuantState **st);
    134     /* initialize one instance of the pre processing state.
    135        Stores pointer to filter status struct in *st. This pointer has to
    136        be passed to gainQuant in each call.
    137        returns 0 on success
    138      */
    139     Word16 gainQuant_reset(gainQuantState *st);
    140     /* reset of pre processing state (i.e. set state memory to zero)
    141        returns 0 on success
    142      */
    143     void gainQuant_exit(gainQuantState **st);
    144     /* de-initialize pre processing state (i.e. free status struct)
    145        stores NULL in *st
    146      */
    147 
    148     void gainQuant(
    149         gainQuantState *st,   /* i/o : State struct                      */
    150         enum Mode mode,       /* i   : coder mode                        */
    151         Word16 res[],         /* i   : LP residual,                 Q0   */
    152         Word16 exc[],         /* i   : LTP excitation (unfiltered), Q0   */
    153         Word16 code[],        /* i   : CB innovation (unfiltered),  Q13  */
    154         /*       (unsharpened for MR475)           */
    155         Word16 xn[],          /* i   : Target vector.                    */
    156         Word16 xn2[],         /* i   : Target vector.                    */
    157         Word16 y1[],          /* i   : Adaptive codebook.                */
    158         Word16 Y2[],          /* i   : Filtered innovative vector.       */
    159         Word16 g_coeff[],     /* i   : Correlations <xn y1> <y1 y1>      */
    160         /*       Compute in G_pitch().             */
    161         Word16 even_subframe, /* i   : even subframe indicator flag      */
    162         Word16 gp_limit,      /* i   : pitch gain limit                  */
    163         Word16 *sf0_gain_pit, /* o   : Pitch gain sf 0.   MR475          */
    164         Word16 *sf0_gain_cod, /* o   : Code gain sf 0.    MR475          */
    165         Word16 *gain_pit,     /* i/o : Pitch gain.                       */
    166         Word16 *gain_cod,     /* o   : Code gain.                        */
    167         /*       MR475: gain_* unquantized in even */
    168         /*       subframes, quantized otherwise    */
    169         Word16 **anap,        /* o   : Index of quantization             */
    170         Flag   *pOverflow     /* o   : overflow indicator                */
    171     );
    172 
    173     /*----------------------------------------------------------------------------
    174     ; END
    175     ----------------------------------------------------------------------------*/
    176 #ifdef __cplusplus
    177 }
    178 #endif
    179 
    180 #endif /* gain_q_h */
    181 
    182 
    183