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  Pathname: ./audio/gsm-amr/c/src/d_gain_p.c
     35  Functions: d_gain_p
     36 
     37      Date: 01/31/2002
     38 
     39 ------------------------------------------------------------------------------
     40  REVISION HISTORY
     41 
     42  Description:
     43  (1) Removed extra includes
     44  (2) Replaced function calls to basic math operations with ANSI C standard
     45      mathemtical operations.
     46  (3) Placed code in the proper software template.
     47 
     48  Description:  Replaced "int" and/or "char" with OSCL defined types.
     49 
     50  Description: Added #ifdef __cplusplus around extern'ed table.
     51 
     52  Description:
     53 
     54  ------------------------------------------------------------------------------
     55  INPUT AND OUTPUT DEFINITIONS
     56 
     57  Inputs:
     58     mode  -- enumerated type -- AMR mode
     59     index -- Word16          -- index of quantization
     60  Outputs:
     61     None
     62 
     63  Returns:
     64     Word16 gain -- (Q14)
     65 
     66  Global Variables Used:
     67     None
     68 
     69  Local Variables Needed:
     70     None
     71 
     72 ------------------------------------------------------------------------------
     73  FUNCTION DESCRIPTION
     74 
     75  Function    : d_gain_pitch
     76  Purpose     : Decodes the pitch gain using the received index.
     77                output is in Q14
     78 
     79 ------------------------------------------------------------------------------
     80  REQUIREMENTS
     81 
     82 
     83 
     84 ------------------------------------------------------------------------------
     85  REFERENCES
     86 
     87  d_gain_p.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
     88 
     89 ------------------------------------------------------------------------------
     90  PSEUDO-CODE
     91 
     92 
     93 
     94 ------------------------------------------------------------------------------
     95  RESOURCES USED
     96    When the code is written for a specific target processor the
     97      the resources used should be documented below.
     98 
     99  STACK USAGE: [stack count for this module] + [variable to represent
    100           stack usage for each subroutine called]
    101 
    102      where: [stack usage variable] = stack usage for [subroutine
    103          name] (see [filename].ext)
    104 
    105  DATA MEMORY USED: x words
    106 
    107  PROGRAM MEMORY USED: x words
    108 
    109  CLOCK CYCLES: [cycle count equation for this module] + [variable
    110            used to represent cycle count for each subroutine
    111            called]
    112 
    113      where: [cycle count variable] = cycle count for [subroutine
    114         name] (see [filename].ext)
    115 
    116 ------------------------------------------------------------------------------
    117 */
    118 
    119 
    120 /*----------------------------------------------------------------------------
    121 ; INCLUDES
    122 ----------------------------------------------------------------------------*/
    123 #include "d_gain_p.h"
    124 #include "typedef.h"
    125 #include "mode.h"
    126 
    127 /*--------------------------------------------------------------------------*/
    128 #ifdef __cplusplus
    129 extern "C"
    130 {
    131 #endif
    132 
    133     /*----------------------------------------------------------------------------
    134     ; MACROS
    135     ; Define module specific macros here
    136     ----------------------------------------------------------------------------*/
    137 
    138 
    139     /*----------------------------------------------------------------------------
    140     ; DEFINES
    141     ; Include all pre-processor statements here. Include conditional
    142     ; compile variables also.
    143     ----------------------------------------------------------------------------*/
    144 
    145     /*----------------------------------------------------------------------------
    146     ; LOCAL FUNCTION DEFINITIONS
    147     ; Function Prototype declaration
    148     ----------------------------------------------------------------------------*/
    149 
    150 
    151     /*----------------------------------------------------------------------------
    152     ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
    153     ; Variable declaration - defined here and used outside this module
    154     ----------------------------------------------------------------------------*/
    155 
    156     /*----------------------------------------------------------------------------
    157     ; EXTERNAL FUNCTION REFERENCES
    158     ; Declare functions defined elsewhere and referenced in this module
    159     ----------------------------------------------------------------------------*/
    160 
    161     /*----------------------------------------------------------------------------
    162     ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
    163     ; Declare variables used in this module but defined elsewhere
    164     ----------------------------------------------------------------------------*/
    165     extern const Word16 qua_gain_pitch[];
    166 
    167     /*--------------------------------------------------------------------------*/
    168 #ifdef __cplusplus
    169 }
    170 #endif
    171 
    172 /*----------------------------------------------------------------------------
    173 ; FUNCTION CODE
    174 ----------------------------------------------------------------------------*/
    175 
    176 Word16 d_gain_pitch(       /* return value: gain (Q14)                */
    177     enum Mode mode,        /* i   : AMR mode                          */
    178     Word16 index           /* i   : index of quantization             */
    179 )
    180 {
    181     Word16 gain;
    182 
    183     gain = qua_gain_pitch[index];
    184 
    185     if (mode == MR122)
    186     {
    187         /* clear 2 LSBits */
    188         gain &= 0xFFFC;
    189     }
    190 
    191     return gain;
    192 }
    193