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/src/include/c_g_aver.h 35 36 Date: 12/29/2002 37 38 ------------------------------------------------------------------------------ 39 REVISION HISTORY 40 41 Description: Moved _cplusplus #ifdef after Include section. 42 43 Description: 44 45 ------------------------------------------------------------------------------ 46 INCLUDE DESCRIPTION 47 48 File : c_g_aver.h 49 Purpose : Background noise source charateristic detector (SCD) 50 51 ------------------------------------------------------------------------------ 52 */ 53 54 #ifndef _C_G_AVER_H_ 55 #define _C_G_AVER_H_ 56 57 /*---------------------------------------------------------------------------- 58 ; INCLUDES 59 ----------------------------------------------------------------------------*/ 60 #include "typedef.h" 61 #include "mode.h" 62 #include "cnst.h" 63 64 /*--------------------------------------------------------------------------*/ 65 #ifdef __cplusplus 66 extern "C" 67 { 68 #endif 69 70 /*---------------------------------------------------------------------------- 71 ; MACROS 72 ; [Define module specific macros here] 73 ----------------------------------------------------------------------------*/ 74 75 /*---------------------------------------------------------------------------- 76 ; DEFINES 77 ; [Include all pre-processor statements here.] 78 ----------------------------------------------------------------------------*/ 79 #define L_CBGAINHIST 7 80 81 /*---------------------------------------------------------------------------- 82 ; EXTERNAL VARIABLES REFERENCES 83 ; [Declare variables used in this module but defined elsewhere] 84 ----------------------------------------------------------------------------*/ 85 86 /*---------------------------------------------------------------------------- 87 ; SIMPLE TYPEDEF'S 88 ----------------------------------------------------------------------------*/ 89 90 /*---------------------------------------------------------------------------- 91 ; ENUMERATED TYPEDEF'S 92 ----------------------------------------------------------------------------*/ 93 94 /*---------------------------------------------------------------------------- 95 ; STRUCTURES TYPEDEF'S 96 ----------------------------------------------------------------------------*/ 97 typedef struct 98 { 99 /* history vector of past synthesis speech energy */ 100 Word16 cbGainHistory[L_CBGAINHIST]; 101 102 /* state flags */ 103 Word16 hangVar; /* counter; */ 104 Word16 hangCount; /* counter; */ 105 106 } Cb_gain_averageState; 107 108 /*---------------------------------------------------------------------------- 109 ; GLOBAL FUNCTION DEFINITIONS 110 ; [List function prototypes here] 111 ----------------------------------------------------------------------------*/ 112 /* 113 * Function : Cb_gain_average_init 114 * Purpose : Allocates initializes state memory 115 * Description : Stores pointer to filter status struct in *st. This 116 * pointer has to be passed to Cb_gain_average in each call. 117 * Returns : 0 on success 118 */ 119 Word16 Cb_gain_average_init(Cb_gain_averageState **st); 120 121 /* 122 * Function : Cb_gain_average_reset 123 * Purpose : Resets state memory 124 * Returns : 0 on success 125 */ 126 Word16 Cb_gain_average_reset(Cb_gain_averageState *st); 127 128 /* 129 * Function : Cb_gain_average_exit 130 * Purpose : The memory used for state memory is freed 131 * Description : Stores NULL in *s 132 * Returns : void 133 */ 134 void Cb_gain_average_exit(Cb_gain_averageState **st); 135 136 /* 137 * Function : Cb_gain_average 138 * Purpose : Charaterice synthesis speech and detect background noise 139 * Returns : background noise decision; 0 = bgn, 1 = no bgn 140 */ 141 Word16 Cb_gain_average( 142 Cb_gain_averageState *st, /* i/o : State variables for CB gain avergeing */ 143 enum Mode mode, /* i : AMR mode */ 144 Word16 gain_code, /* i : CB gain Q1 */ 145 Word16 lsp[], /* i : The LSP for the current frame Q15 */ 146 Word16 lspAver[], /* i : The average of LSP for 8 frames Q15 */ 147 Word16 bfi, /* i : bad frame indication flag */ 148 Word16 prev_bf, /* i : previous bad frame indication flag */ 149 Word16 pdfi, /* i : potential degraded bad frame ind flag */ 150 Word16 prev_pdf, /* i : prev pot. degraded bad frame ind flag */ 151 Word16 inBackgroundNoise, /* i : background noise decision */ 152 Word16 voicedHangover, /* i : # of frames after last voiced frame */ 153 Flag *pOverflow 154 ); 155 156 157 #ifdef __cplusplus 158 } 159 #endif 160 161 #endif /* _C_G_AVER_H_ */ 162 163 164