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 ****************************************************************************************/
30 ------------------------------------------------------------------------------
39 /*----------------------------------------------------------------------------
41 ----------------------------------------------------------------------------*/
47 /*----------------------------------------------------------------------------
49 ; Define module specific macros here
50 ----------------------------------------------------------------------------*/
52 /*----------------------------------------------------------------------------
54 ; Include all pre-processor statements here. Include conditional
55 ; compile variables also.
56 ----------------------------------------------------------------------------*/
58 /*----------------------------------------------------------------------------
59 ; LOCAL FUNCTION DEFINITIONS
60 ; Function Prototype declaration
61 ----------------------------------------------------------------------------*/
63 /*----------------------------------------------------------------------------
64 ; LOCAL VARIABLE DEFINITIONS
65 ; Variable declaration - defined here and used outside this module
66 ----------------------------------------------------------------------------*/
69 ------------------------------------------------------------------------------
71 ------------------------------------------------------------------------------
72 INPUT AND OUTPUT DEFINITIONS
75 st = pointer to pitchOLWghtState structure
76 vadSt = pointer to a vadState structure
77 mode = coder mode (Mode)
78 wsp = pointer to buffer of signal used to compute the Open loop pitch
79 T_op = pointer to open loop pitch lag
80 old_lags = pointer to history with old stored Cl lags (Word16)
81 ol_gain_flg = pointer to OL gain flag (Word16)
82 idx = 16 bit value specifies the frame index
83 dtx = Data of type 'Flag' used for dtx. Use dtx=1, do not use dtx=0
84 pOverflow = pointer to Overflow indicator (Flag)
87 pOverflow -> 1 if processing this funvction results in satuaration
92 Global Variables Used:
95 Local Variables Needed:
98 ------------------------------------------------------------------------------
101 This function computes the open loop pitch lag.
103 ------------------------------------------------------------------------------
108 ------------------------------------------------------------------------------
111 ol_ltp.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
113 ------------------------------------------------------------------------------
117 pitchOLWghtState *st, // i/o : State struct
118 vadState *vadSt, // i/o : VAD state struct
119 enum Mode mode, // i : coder mode
120 Word16 wsp[], // i : signal used to compute the OL pitch, Q0
121 // uses signal[-pit_max] to signal[-1]
122 Word16 *T_op, // o : open loop pitch lag, Q0
123 Word16 old_lags[], // i : history with old stored Cl lags
124 Word16 ol_gain_flg[], // i : OL gain flag
125 Word16 idx, // i : index
126 Flag dtx // i : dtx flag; use dtx=1, do not use dtx=0
129 if (sub ((Word16)mode, (Word16)MR102) != 0 )
135 if (sub ((Word16)mode, (Word16)MR475) == 0 || sub ((Word16)mode, (Word16)MR515) == 0 )
137 *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN, PIT_MAX, L_FRAME, idx, dtx);
141 if ( sub ((Word16)mode, (Word16)MR795) <= 0 )
143 *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2,
146 else if ( sub ((Word16)mode, (Word16)MR102) == 0 )
148 *T_op = Pitch_ol_wgh(st, vadSt, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2,
149 old_lags, ol_gain_flg, idx, dtx);
153 *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN_MR122, PIT_MAX,
154 L_FRAME_BY2, idx, dtx);
160 ------------------------------------------------------------------------------
162 [State any special notes, constraints or cautions for users of this function]
164 ------------------------------------------------------------------------------
168 /*----------------------------------------------------------------------------
170 ----------------------------------------------------------------------------*/
172 pitchOLWghtState *st, /* i/o : State struct */
173 vadState *vadSt, /* i/o : VAD state struct */
174 enum Mode mode, /* i : coder mode */
175 Word16 wsp[], /* i : signal used to compute the OL pitch, Q0 */
176 /* uses signal[-pit_max] to signal[-1] */
177 Word16 *T_op, /* o : open loop pitch lag, Q0 */
178 Word16 old_lags[], /* i : history with old stored Cl lags */
179 Word16 ol_gain_flg[], /* i : OL gain flag */
180 Word16 idx, /* i : index */
181 Flag dtx, /* i : dtx flag; use dtx=1, do not use dtx=0 */
182 Flag *pOverflow /* i/o : overflow indicator */
191 if ((mode == MR475) || (mode == MR515))
193 *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN, PIT_MAX, L_FRAME, idx, dtx,
200 *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2,
201 idx, dtx, pOverflow);
203 else if (mode == MR102)
205 *T_op = Pitch_ol_wgh(st, vadSt, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2,
206 old_lags, ol_gain_flg, idx, dtx, pOverflow);
210 *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN_MR122, PIT_MAX,
211 L_FRAME_BY2, idx, dtx, pOverflow);