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 - Wideband (AMR-WB) speech codec
23 Available from http://www.3gpp.org
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 ****************************************************************************************/
30 ------------------------------------------------------------------------------
34 Filename: deemphasis_32.cpp
36 ------------------------------------------------------------------------------
37 INPUT AND OUTPUT DEFINITIONS
39 int16 x_hi[], (i) : input signal (bit31..16)
40 int16 x_lo[], (i) : input signal (bit15..4)
41 int16 y[], (o) : output signal (x16)
42 int16 mu, (i) Q15 : deemphasis factor
43 int16 L, (i) : vector size
44 int16 * mem (i/o) : memory (y[-1])
46 ------------------------------------------------------------------------------
49 32-bits filtering through 1/(1-mu z^-1)
51 ------------------------------------------------------------------------------
55 ------------------------------------------------------------------------------
58 ------------------------------------------------------------------------------
61 Deemphasis H(z) = 1/(1 - 0.68z^(-1)) where mu = 0.67999 in Q15
63 ------------------------------------------------------------------------------
67 /*----------------------------------------------------------------------------
69 ----------------------------------------------------------------------------*/
71 #include "pv_amr_wb_type_defs.h"
72 #include "pvamrwbdecoder_basic_op.h"
73 #include "pvamrwb_math_op.h"
74 #include "pvamrwbdecoder_acelp.h"
76 /*----------------------------------------------------------------------------
78 ; Define module specific macros here
79 ----------------------------------------------------------------------------*/
82 /*----------------------------------------------------------------------------
84 ; Include all pre-processor statements here. Include conditional
85 ; compile variables also.
86 ----------------------------------------------------------------------------*/
88 /*----------------------------------------------------------------------------
89 ; LOCAL FUNCTION DEFINITIONS
90 ; Function Prototype declaration
91 ----------------------------------------------------------------------------*/
93 /*----------------------------------------------------------------------------
94 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
95 ; Variable declaration - defined here and used outside this module
96 ----------------------------------------------------------------------------*/
98 /*----------------------------------------------------------------------------
99 ; EXTERNAL FUNCTION REFERENCES
100 ; Declare functions defined elsewhere and referenced in this module
101 ----------------------------------------------------------------------------*/
103 /*----------------------------------------------------------------------------
104 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
105 ; Declare variables used in this module but defined elsewhere
106 ----------------------------------------------------------------------------*/
108 /*----------------------------------------------------------------------------
110 ----------------------------------------------------------------------------*/
113 int16 x_hi[], /* (i) : input signal (bit31..16) */
114 int16 x_lo[], /* (i) : input signal (bit15..4) */
115 int16 y[], /* (o) : output signal (x16) */
116 int16 mu, /* (i) Q15 : deemphasis factor */
117 int16 L, /* (i) : vector size */
118 int16 * mem /* (i/o) : memory (y[-1]) */
125 L_tmp = ((int32)x_hi[0]) << 16;
126 L_tmp += ((int32)x_lo[0]) << 4;
127 L_tmp = shl_int32(L_tmp, 3);
129 L_tmp = fxp_mac_16by16(*mem, mu, L_tmp),
131 L_tmp = shl_int32(L_tmp, 1); /* saturation can occur here */
132 y[0] = amr_wb_round(L_tmp);
136 for (i = 1; i < L - 1; i++)
138 L_tmp = ((int32)hi) << 16;
139 L_tmp += ((int32)lo) << 4;
140 L_tmp = shl_int32(L_tmp, 3);
141 L_tmp = fxp_mac_16by16(y[i - 1], mu, L_tmp),
142 L_tmp = shl_int32(L_tmp, 1); /* saturation can occur here */
143 y[i] = amr_wb_round(L_tmp);
147 L_tmp = ((int32)hi) << 16;
148 L_tmp += ((int32)lo) << 4;
149 L_tmp = shl_int32(L_tmp, 3);
150 L_tmp = fxp_mac_16by16(y[i - 1], mu, L_tmp),
151 L_tmp = shl_int32(L_tmp, 1); /* saturation can occur here */
152 y[i] = amr_wb_round(L_tmp);