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/agc.h 35 36 Date: 12/07/2001 37 38 ------------------------------------------------------------------------------ 39 REVISION HISTORY 40 41 Description: Removed unneeded sections of the standard template. 42 Updated function prototype for agc() and agc2() to match new 43 interface 44 45 Description: Changed paramter name from "overflow" to "pOverflow" for 46 functions agc() and agc2() 47 48 Description: Replaced "int" and/or "char" with OSCL defined types. 49 50 51 Description: Moved _cplusplus #ifdef after Include section. 52 53 Description: 54 55 ------------------------------------------------------------------------------ 56 INCLUDE DESCRIPTION 57 58 File : agc.h 59 Purpose : Scales the postfilter output on a subframe basis 60 : by automatic control of the subframe gain. 61 62 ------------------------------------------------------------------------------ 63 */ 64 65 #ifndef _AGC_H_ 66 #define _AGC_H_ 67 68 /*---------------------------------------------------------------------------- 69 ; INCLUDES 70 ----------------------------------------------------------------------------*/ 71 #include "typedef.h" 72 73 /*--------------------------------------------------------------------------*/ 74 #ifdef __cplusplus 75 extern "C" 76 { 77 #endif 78 79 /*---------------------------------------------------------------------------- 80 ; MACROS 81 ; [Define module specific macros here] 82 ----------------------------------------------------------------------------*/ 83 84 /*---------------------------------------------------------------------------- 85 ; DEFINES 86 ; [Include all pre-processor statements here.] 87 ----------------------------------------------------------------------------*/ 88 89 /*---------------------------------------------------------------------------- 90 ; EXTERNAL VARIABLES REFERENCES 91 ; [Declare variables used in this module but defined elsewhere] 92 ----------------------------------------------------------------------------*/ 93 94 /*---------------------------------------------------------------------------- 95 ; SIMPLE TYPEDEF'S 96 ----------------------------------------------------------------------------*/ 97 98 /*---------------------------------------------------------------------------- 99 ; ENUMERATED TYPEDEF'S 100 ----------------------------------------------------------------------------*/ 101 102 /*---------------------------------------------------------------------------- 103 ; STRUCTURES TYPEDEF'S 104 ----------------------------------------------------------------------------*/ 105 typedef struct 106 { 107 Word16 past_gain; 108 } agcState; 109 110 /*---------------------------------------------------------------------------- 111 ; GLOBAL FUNCTION DEFINITIONS 112 ; [List function prototypes here] 113 ----------------------------------------------------------------------------*/ 114 /*---------------------------------------------------------------------------- 115 ; 116 ; Function : agc_reset 117 ; Purpose : Reset of agc (i.e. set state memory to 1.0) 118 ; Returns : 0 on success 119 ; 120 ----------------------------------------------------------------------------*/ 121 Word16 agc_reset(agcState *st); 122 123 124 /*---------------------------------------------------------------------------- 125 ; 126 ; Function : agc 127 ; Purpose : Scales the postfilter output on a subframe basis 128 ; Description : sig_out[n] = sig_out[n] * gain[n]; 129 ; where gain[n] is the gain at the nth sample given by 130 ; gain[n] = agc_fac * gain[n-1] + (1 - agc_fac) g_in/g_out 131 ; g_in/g_out is the square root of the ratio of energy at 132 ; the input and output of the postfilter. 133 ; 134 ----------------------------------------------------------------------------*/ 135 void agc( 136 agcState *st, /* i/o : agc state */ 137 Word16 *sig_in, /* i : postfilter input signal, (l_trm) */ 138 Word16 *sig_out, /* i/o : postfilter output signal, (l_trm) */ 139 Word16 agc_fac, /* i : AGC factor */ 140 Word16 l_trm, /* i : subframe size */ 141 Flag *pOverflow /* i : overflow flag */ 142 ); 143 144 /*---------------------------------------------------------------------------- 145 ; 146 ; Function: agc2 147 ; Purpose: Scales the excitation on a subframe basis 148 ; 149 ----------------------------------------------------------------------------*/ 150 void agc2( 151 Word16 *sig_in, /* i : postfilter input signal */ 152 Word16 *sig_out, /* i/o : postfilter output signal */ 153 Word16 l_trm, /* i : subframe size */ 154 Flag *pOverflow /* i : overflow flag */ 155 ); 156 157 #ifdef __cplusplus 158 } 159 #endif 160 161 #endif /* _AGC_H_ */ 162 163 164