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_plsf.c
     35  Functions:
     36 
     37 
     38      Date: 04/14/2000
     39 
     40 ------------------------------------------------------------------------------
     41  REVISION HISTORY
     42 
     43  Description: Removed the functions d_plsf_init and d_plsf_exit.
     44  The d_plsf related structure is no longer dynamically allocated.
     45 
     46  Description: Removed q_plsf_5.tab from Include section and added
     47               q_plsf_5_tbl.h to Include section. Changed "mean_lsf"
     48               to "mean_lsf_5" in D_plsf_reset().
     49 
     50  Description:  Replaced OSCL mem type functions and eliminated include
     51                files that now are chosen by OSCL definitions
     52 
     53  Description:  Replaced "int" and/or "char" with OSCL defined types.
     54 
     55  Description:
     56 
     57 ------------------------------------------------------------------------------
     58  MODULE DESCRIPTION
     59 
     60  common part (reset) of LSF decoder
     61  module (rest in d_plsf_3.c and d_plsf_5.c)
     62 ------------------------------------------------------------------------------
     63 */
     64 
     65 /*----------------------------------------------------------------------------
     66 ; INCLUDES
     67 ----------------------------------------------------------------------------*/
     68 #include "typedef.h"
     69 #include "basic_op.h"
     70 #include "cnst.h"
     71 #include "copy.h"
     72 #include "d_plsf.h"
     73 #include "q_plsf_5_tbl.h"
     74 
     75 
     76 /*----------------------------------------------------------------------------
     77 ; MACROS
     78 ; Define module specific macros here
     79 ----------------------------------------------------------------------------*/
     80 
     81 /*----------------------------------------------------------------------------
     82 ; DEFINES
     83 ; Include all pre-processor statements here. Include conditional
     84 ; compile variables also.
     85 ----------------------------------------------------------------------------*/
     86 
     87 /*----------------------------------------------------------------------------
     88 ; LOCAL FUNCTION DEFINITIONS
     89 ; Function Prototype declaration
     90 ----------------------------------------------------------------------------*/
     91 
     92 /*----------------------------------------------------------------------------
     93 ; LOCAL VARIABLE DEFINITIONS
     94 ; Variable declaration - defined here and used outside this module
     95 ----------------------------------------------------------------------------*/
     96 
     97 /*----------------------------------------------------------------------------
     98 ; EXTERNAL FUNCTION REFERENCES
     99 ; Declare functions defined elsewhere and referenced in this module
    100 ----------------------------------------------------------------------------*/
    101 
    102 /*----------------------------------------------------------------------------
    103 ; EXTERNAL VARIABLES REFERENCES
    104 ; Declare variables used in this module but defined elsewhere
    105 ----------------------------------------------------------------------------*/
    106 
    107 /*
    108 ------------------------------------------------------------------------------
    109  FUNCTION NAME: D_plsf_reset
    110 ------------------------------------------------------------------------------
    111  INPUT AND OUTPUT DEFINITIONS
    112 
    113  Inputs:
    114     state = pointer to structure of type D_plsf_reset
    115 
    116  Outputs:
    117     fields of the structure pointed to by state is initialized to zero
    118 
    119  Returns:
    120     return_value = 0, if reset was successful; -1, otherwise (int)
    121 
    122  Global Variables Used:
    123     None
    124 
    125  Local Variables Needed:
    126     None
    127 
    128 ------------------------------------------------------------------------------
    129  FUNCTION DESCRIPTION
    130 
    131  Resets state memory
    132 
    133 ------------------------------------------------------------------------------
    134  REQUIREMENTS
    135 
    136  None
    137 
    138 ------------------------------------------------------------------------------
    139  REFERENCES
    140 
    141  d_plsf.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
    142 
    143 ------------------------------------------------------------------------------
    144  PSEUDO-CODE
    145 
    146 int D_plsf_reset (D_plsfState *state)
    147 {
    148   Word16 i;
    149 
    150   if (state == (D_plsfState *) NULL){
    151       // fprintf(stderr, "D_plsf_reset: invalid parameter\n");
    152       return -1;
    153   }
    154 
    155   for (i = 0; i < M; i++){
    156       state->past_r_q[i] = 0;             // Past quantized prediction error
    157   }
    158 
    159   // Past dequantized lsfs
    160   Copy(mean_lsf, &state->past_lsf_q[0], M);
    161 
    162   return 0;
    163 }
    164 ------------------------------------------------------------------------------
    165  RESOURCES USED [optional]
    166 
    167  When the code is written for a specific target processor the
    168  the resources used should be documented below.
    169 
    170  HEAP MEMORY USED: x bytes
    171 
    172  STACK MEMORY USED: x bytes
    173 
    174  CLOCK CYCLES: (cycle count equation for this function) + (variable
    175                 used to represent cycle count for each subroutine
    176                 called)
    177      where: (cycle count variable) = cycle count for [subroutine
    178                                      name]
    179 
    180 ------------------------------------------------------------------------------
    181  CAUTION [optional]
    182  [State any special notes, constraints or cautions for users of this function]
    183 
    184 ------------------------------------------------------------------------------
    185 */
    186 
    187 Word16 D_plsf_reset(D_plsfState *state)
    188 {
    189     Word16 i;
    190 
    191     if (state == (D_plsfState *) NULL)
    192     {
    193         /* fprintf(stderr, "D_plsf_reset: invalid parameter\n"); */
    194         return -1;
    195     }
    196 
    197     for (i = 0; i < M; i++)
    198     {
    199         state->past_r_q[i] = 0;             /* Past quantized prediction error */
    200     }
    201 
    202     /* Past dequantized lsfs */
    203     Copy(mean_lsf_5, &state->past_lsf_q[0], M);
    204 
    205     return 0;
    206 
    207 }
    208