1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
18 /****************************************************************************************
19 Portions of this file are derived from the following 3GPP standard:
22 ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23 Available from http://www.3gpp.org
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 ****************************************************************************************/
31 Filename: lflg_upd.cpp
32 Functions: LTP_flag_update
34 ------------------------------------------------------------------------------
37 LTP_flag update for AMR VAD option 2
38 ------------------------------------------------------------------------------
41 /*----------------------------------------------------------------------------
43 ----------------------------------------------------------------------------*/
46 #include "l_extract.h"
47 #include "mpy_32_16.h"
52 /*----------------------------------------------------------------------------
54 ; Define module specific macros here
55 ----------------------------------------------------------------------------*/
57 /*----------------------------------------------------------------------------
59 ; Include all pre-processor statements here. Include conditional
60 ; compile variables also.
61 ----------------------------------------------------------------------------*/
63 /*----------------------------------------------------------------------------
64 ; LOCAL FUNCTION DEFINITIONS
65 ; Function Prototype declaration
66 ----------------------------------------------------------------------------*/
68 /*----------------------------------------------------------------------------
69 ; LOCAL VARIABLE DEFINITIONS
70 ; Variable declaration - defined here and used outside this module
71 ----------------------------------------------------------------------------*/
75 ------------------------------------------------------------------------------
77 ------------------------------------------------------------------------------
78 INPUT AND OUTPUT DEFINITIONS
81 st -- Pointer to vadState2
82 mode -- Word16 -- AMR mode
85 st -- Pointer to vadState2
86 pOverflow -- Pointer to Flag -- overflow indicator
91 Global Variables Used:
94 Local Variables Needed:
97 ------------------------------------------------------------------------------
100 LTP_flag update for AMR VAD option 2
104 Set LTP_flag if the LTP gain > LTP_THRESHOLD, where the value of
105 LTP_THRESHOLD depends on the LTP analysis window length.
114 LTP maximum autocorrelation
118 Set if LTP gain > LTP_THRESHOLD
125 ------------------------------------------------------------------------------
130 ------------------------------------------------------------------------------
133 lflg_upd.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
135 ------------------------------------------------------------------------------
139 ------------------------------------------------------------------------------
141 [State any special notes, constraints or cautions for users of this function]
143 ------------------------------------------------------------------------------
146 void LTP_flag_update(
156 if ((mode == MR475) || (mode == MR515))
158 thresh = 18022; /* (Word16)(32768.0*0.55); */
160 else if (mode == MR102)
162 thresh = 19660; /* (Word16)(32768.0*0.60); */
166 thresh = 21299; /* (Word16)(32768.0*0.65); */
169 L_Extract(st->L_R0, &hi1, &lo1, pOverflow);
171 Ltmp = Mpy_32_16(hi1, lo1, thresh, pOverflow);
173 if (st->L_Rmax > Ltmp)
179 st->LTP_flag = FALSE;