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: bgnscd.h 35 36 ------------------------------------------------------------------------------ 37 INCLUDE DESCRIPTION 38 39 File : bgnscd.h 40 Purpose : Background noise source charateristic detector (SCD) 41 42 ------------------------------------------------------------------------------ 43 */ 44 45 #ifndef _BGNSCD_H_ 46 #define _BGNSCD_H_ 47 48 /*---------------------------------------------------------------------------- 49 ; INCLUDES 50 ----------------------------------------------------------------------------*/ 51 #include "typedef.h" 52 #include "cnst.h" 53 54 /*--------------------------------------------------------------------------*/ 55 #ifdef __cplusplus 56 extern "C" 57 { 58 #endif 59 60 /*---------------------------------------------------------------------------- 61 ; MACROS 62 ; [Define module specific macros here] 63 ----------------------------------------------------------------------------*/ 64 65 /*---------------------------------------------------------------------------- 66 ; DEFINES 67 ; [Include all pre-processor statements here.] 68 ----------------------------------------------------------------------------*/ 69 #define L_ENERGYHIST 60 70 #define INV_L_FRAME 102 71 72 73 /* 2*(160*x)^2 / 65536 where x is FLP values 150,5 and 50 */ 74 #define FRAMEENERGYLIMIT 17578 /* 150 */ 75 #define LOWERNOISELIMIT 20 /* 5 */ 76 #define UPPERNOISELIMIT 1953 /* 50 */ 77 78 79 /*---------------------------------------------------------------------------- 80 ; EXTERNAL VARIABLES REFERENCES 81 ; [Declare variables used in this module but defined elsewhere] 82 ----------------------------------------------------------------------------*/ 83 84 /*---------------------------------------------------------------------------- 85 ; SIMPLE TYPEDEF'S 86 ----------------------------------------------------------------------------*/ 87 88 /*---------------------------------------------------------------------------- 89 ; ENUMERATED TYPEDEF'S 90 ----------------------------------------------------------------------------*/ 91 92 /*---------------------------------------------------------------------------- 93 ; STRUCTURES TYPEDEF'S 94 ----------------------------------------------------------------------------*/ 95 typedef struct 96 { 97 /* history vector of past synthesis speech energy */ 98 Word16 frameEnergyHist[L_ENERGYHIST]; 99 100 /* state flags */ 101 Word16 bgHangover; /* counter; number of frames after last speech frame */ 102 103 } Bgn_scdState; 104 105 /*---------------------------------------------------------------------------- 106 ; GLOBAL FUNCTION DEFINITIONS 107 ; [List function prototypes here] 108 ----------------------------------------------------------------------------*/ 109 /* 110 * Function : Bgn_scd_init 111 * Purpose : Allocates initializes state memory 112 * Description : Stores pointer to filter status struct in *st. This 113 * pointer has to be passed to Bgn_scd in each call. 114 * Returns : 0 on success 115 */ 116 Word16 Bgn_scd_init(Bgn_scdState **st); 117 118 /* 119 * Function : Bgn_scd_reset 120 * Purpose : Resets state memory 121 * Returns : 0 on success 122 */ 123 Word16 Bgn_scd_reset(Bgn_scdState *st); 124 125 /* 126 * Function : Bgn_scd_exit 127 * Purpose : The memory used for state memory is freed 128 * Description : Stores NULL in *s 129 * Returns : void 130 */ 131 void Bgn_scd_exit(Bgn_scdState **st); 132 133 /* 134 * Function : Bgn_scd 135 * Purpose : Charaterice synthesis speech and detect background noise 136 * Returns : background noise decision; 0 = bgn, 1 = no bgn 137 */ 138 Word16 Bgn_scd(Bgn_scdState *st, /* i : State variables for bgn SCD */ 139 Word16 ltpGainHist[], /* i : LTP gain history */ 140 Word16 speech[], /* o : synthesis speech frame */ 141 Word16 *voicedHangover,/* o : # of frames after last voiced frame */ 142 Flag *pOverflow 143 ); 144 145 146 #ifdef __cplusplus 147 } 148 #endif 149 150 #endif /* _BGNSCD_H_ */ 151