1b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/* ------------------------------------------------------------------ 2b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * Copyright (C) 1998-2009 PacketVideo 3b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * 4b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 5b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * you may not use this file except in compliance with the License. 6b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * You may obtain a copy of the License at 7b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * 8b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * http://www.apache.org/licenses/LICENSE-2.0 9b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * 10b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * Unless required by applicable law or agreed to in writing, software 11b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 12b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * express or implied. 14b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * See the License for the specific language governing permissions 15b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * and limitations under the License. 16b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber * ------------------------------------------------------------------- 17b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber */ 18b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/**************************************************************************************** 19b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas HuberPortions of this file are derived from the following 3GPP standard: 20b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 21b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 3GPP TS 26.073 22b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec 23b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Available from http://www.3gpp.org 24b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 25b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber(C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC) 26b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas HuberPermission to distribute, modify and use this file under the standard license 27b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huberterms listed above has been obtained from the copyright holder. 28b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber****************************************************************************************/ 29b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/* 30b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------ 31b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 32b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 33b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 34b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Filename: /audio/gsm_amr/c/include/gain_q.h 35b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 36b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Date: 02/05/2002 37b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 38b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------ 39b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber REVISION HISTORY 40b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 41b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Description: Placed header file in the proper template format. Added 42b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber parameter pOverflow. 43b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 44b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Description: Changed definition of... 45b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 46b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber gc_predState gc_predSt; 47b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber gc_predState gc_predUnqSt; 48b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 49b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber in the structure typedef. These are no longer pointers, which avoids 50b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber the need to malloc memory for the pointers. They are, rather, the actual 51b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber structure declared within the gainQuantState structure. 52b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 53b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Description: Replaced "int" and/or "char" with OSCL defined types. 54b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 55b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Description: Moved _cplusplus #ifdef after Include section. 56b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 57b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Description: 58b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 59b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------ 60b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber INCLUDE DESCRIPTION 61b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 62b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber This file contains all the constant definitions and prototype definitions 63b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber needed by the file, gain_q.c 64b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 65b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber------------------------------------------------------------------------------ 66b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber*/ 67b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 68b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*---------------------------------------------------------------------------- 69b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; CONTINUE ONLY IF NOT ALREADY DEFINED 70b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber----------------------------------------------------------------------------*/ 71b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#ifndef gain_q_h 72b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#define gain_q_h "$Id $" 73b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 74b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*---------------------------------------------------------------------------- 75b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber; INCLUDES 76b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber----------------------------------------------------------------------------*/ 77b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#include "typedef.h" 78b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#include "mode.h" 79b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#include "gc_pred.h" 80b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#include "g_adapt.h" 81b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 82b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber/*--------------------------------------------------------------------------*/ 83b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#ifdef __cplusplus 84b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huberextern "C" 85b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber{ 86b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#endif 87b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 88b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /*---------------------------------------------------------------------------- 89b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; MACROS 90b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; Define module specific macros here 91b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ----------------------------------------------------------------------------*/ 92b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 93b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /*---------------------------------------------------------------------------- 94b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; DEFINES 95b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; Include all pre-processor statements here. 96b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ----------------------------------------------------------------------------*/ 97b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 98b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /*---------------------------------------------------------------------------- 99b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; EXTERNAL VARIABLES REFERENCES 100b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; Declare variables used in this module but defined elsewhere 101b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ----------------------------------------------------------------------------*/ 102b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 103b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /*---------------------------------------------------------------------------- 104b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; SIMPLE TYPEDEF'S 105b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ----------------------------------------------------------------------------*/ 106b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 107b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /*---------------------------------------------------------------------------- 108b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; ENUMERATED TYPEDEF'S 109b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ----------------------------------------------------------------------------*/ 110b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 111b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /*---------------------------------------------------------------------------- 112b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; STRUCTURES TYPEDEF'S 113b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ----------------------------------------------------------------------------*/ 114b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber typedef struct 115b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber { 116b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 sf0_exp_gcode0; 117b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 sf0_frac_gcode0; 118b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 sf0_exp_target_en; 119b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 sf0_frac_target_en; 120b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 sf0_exp_coeff[5]; 121b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 sf0_frac_coeff[5]; 122b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 *gain_idx_ptr; 123b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 124b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber gc_predState gc_predSt; 125b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber gc_predState gc_predUnqSt; 126b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber GainAdaptState *adaptSt; 127b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber } gainQuantState; 128b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 129b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /*---------------------------------------------------------------------------- 130b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; GLOBAL FUNCTION DEFINITIONS 131b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; Function Prototype declaration 132b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ----------------------------------------------------------------------------*/ 133b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 gainQuant_init(gainQuantState **st); 134b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /* initialize one instance of the pre processing state. 135b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Stores pointer to filter status struct in *st. This pointer has to 136b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber be passed to gainQuant in each call. 137b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber returns 0 on success 138b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber */ 139b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 gainQuant_reset(gainQuantState *st); 140b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /* reset of pre processing state (i.e. set state memory to zero) 141b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber returns 0 on success 142b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber */ 143b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber void gainQuant_exit(gainQuantState **st); 144b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /* de-initialize pre processing state (i.e. free status struct) 145b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber stores NULL in *st 146b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber */ 147b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 148b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber void gainQuant( 149b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber gainQuantState *st, /* i/o : State struct */ 150b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber enum Mode mode, /* i : coder mode */ 151b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 res[], /* i : LP residual, Q0 */ 152b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 exc[], /* i : LTP excitation (unfiltered), Q0 */ 153b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 code[], /* i : CB innovation (unfiltered), Q13 */ 154b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /* (unsharpened for MR475) */ 155b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 xn[], /* i : Target vector. */ 156b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 xn2[], /* i : Target vector. */ 157b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 y1[], /* i : Adaptive codebook. */ 158b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 Y2[], /* i : Filtered innovative vector. */ 159b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 g_coeff[], /* i : Correlations <xn y1> <y1 y1> */ 160b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /* Compute in G_pitch(). */ 161b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 even_subframe, /* i : even subframe indicator flag */ 162b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 gp_limit, /* i : pitch gain limit */ 163b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 *sf0_gain_pit, /* o : Pitch gain sf 0. MR475 */ 164b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 *sf0_gain_cod, /* o : Code gain sf 0. MR475 */ 165b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 *gain_pit, /* i/o : Pitch gain. */ 166b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 *gain_cod, /* o : Code gain. */ 167b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /* MR475: gain_* unquantized in even */ 168b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /* subframes, quantized otherwise */ 169b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Word16 **anap, /* o : Index of quantization */ 170b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber Flag *pOverflow /* o : overflow indicator */ 171b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ); 172b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 173b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber /*---------------------------------------------------------------------------- 174b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ; END 175b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber ----------------------------------------------------------------------------*/ 176b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#ifdef __cplusplus 177b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber} 178b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#endif 179b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 180b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber#endif /* gain_q_h */ 181b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 182b841f14f8e51f2365945281fbfa54ef6a1b1b5a6Andreas Huber 183