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.173
22 ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec
23 Available from http://www.3gpp.org
24
25 (C) 2007, 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: interpolate_isp.cpp
35
36 Date: 05/08/2004
37
38 ------------------------------------------------------------------------------
39 REVISION HISTORY
40
41
42 Description:
43
44 ------------------------------------------------------------------------------
45 INPUT AND OUTPUT DEFINITIONS
46
47 int16 isp_old[], input : isps from past frame
48 int16 isp_new[], input : isps from present frame
49 const int16 frac[], input : fraction for 3 first subfr (Q15)
50 int16 Az[] output: LP coefficients in 4 subframes
51
52
53 ------------------------------------------------------------------------------
54 FUNCTION DESCRIPTION
55
56 Interpolation of the LP parameters in 4 subframes
57
58
59 ------------------------------------------------------------------------------
60 REQUIREMENTS
61
62
63 ------------------------------------------------------------------------------
64 REFERENCES
65
66 ------------------------------------------------------------------------------
67 PSEUDO-CODE
68
69 ------------------------------------------------------------------------------
70 */
71
72
73 /*----------------------------------------------------------------------------
74 ; INCLUDES
75 ----------------------------------------------------------------------------*/
76
77 #include "pv_amr_wb_type_defs.h"
78 #include "pvamrwbdecoder_basic_op.h"
79 #include "pvamrwbdecoder_cnst.h"
80 #include "pvamrwbdecoder_acelp.h"
81
82 /*----------------------------------------------------------------------------
83 ; MACROS
84 ; Define module specific macros here
85 ----------------------------------------------------------------------------*/
86
87
88 /*----------------------------------------------------------------------------
89 ; DEFINES
90 ; Include all pre-processor statements here. Include conditional
91 ; compile variables also.
92 ----------------------------------------------------------------------------*/
93
94 #define MP1 (M+1)
95
96 /*----------------------------------------------------------------------------
97 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
98 ; Variable declaration - defined here and used outside this module
99 ----------------------------------------------------------------------------*/
100
101 /*----------------------------------------------------------------------------
102 ; EXTERNAL FUNCTION REFERENCES
103 ; Declare functions defined elsewhere and referenced in this module
104 ----------------------------------------------------------------------------*/
105
106 /*----------------------------------------------------------------------------
107 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
108 ; Declare variables used in this module but defined elsewhere
109 ----------------------------------------------------------------------------*/
110
111 /*----------------------------------------------------------------------------
112 ; FUNCTION CODE
113 ----------------------------------------------------------------------------*/
114
interpolate_isp(int16 isp_old[],int16 isp_new[],const int16 frac[],int16 Az[])115 void interpolate_isp(
116 int16 isp_old[], /* input : isps from past frame */
117 int16 isp_new[], /* input : isps from present frame */
118 const int16 frac[], /* input : fraction for 3 first subfr (Q15) */
119 int16 Az[] /* output: LP coefficients in 4 subframes */
120 )
121 {
122 int16 i, k, fac_old, fac_new;
123 int16 isp[M];
124 int32 L_tmp;
125
126 for (k = 0; k < 3; k++)
127 {
128 fac_new = frac[k];
129 fac_old = add_int16(sub_int16(32767, fac_new), 1); /* 1.0 - fac_new */
130
131 for (i = 0; i < M; i++)
132 {
133 L_tmp = mul_16by16_to_int32(isp_old[i], fac_old);
134 L_tmp = mac_16by16_to_int32(L_tmp, isp_new[i], fac_new);
135 isp[i] = amr_wb_round(L_tmp);
136 }
137 Isp_Az(isp, Az, M, 0);
138 Az += MP1;
139 }
140
141 /* 4th subframe: isp_new (frac=1.0) */
142
143 Isp_Az(isp_new, Az, M, 0);
144
145 return;
146 }
147