1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2010 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 ****************************************************************************************/
33 ------------------------------------------------------------------------------
36 This file contains all the constant definitions and prototype definitions
37 needed by the Mpy_32 function.
39 ------------------------------------------------------------------------------
42 /*----------------------------------------------------------------------------
43 ; CONTINUE ONLY IF NOT ALREADY DEFINED
44 ----------------------------------------------------------------------------*/
48 /*----------------------------------------------------------------------------
50 ----------------------------------------------------------------------------*/
51 #include "basicop_malloc.h"
53 /*--------------------------------------------------------------------------*/
59 /*----------------------------------------------------------------------------
61 ; Define module specific macros here
62 ----------------------------------------------------------------------------*/
65 /*----------------------------------------------------------------------------
67 ; Include all pre-processor statements here.
68 ----------------------------------------------------------------------------*/
70 /*----------------------------------------------------------------------------
71 ; EXTERNAL VARIABLES REFERENCES
72 ; Declare variables used in this module but defined elsewhere
73 ----------------------------------------------------------------------------*/
75 /*----------------------------------------------------------------------------
77 ----------------------------------------------------------------------------*/
79 /*----------------------------------------------------------------------------
80 ; ENUMERATED TYPEDEF'S
81 ----------------------------------------------------------------------------*/
83 /*----------------------------------------------------------------------------
84 ; STRUCTURES TYPEDEF'S
85 ----------------------------------------------------------------------------*/
87 /*----------------------------------------------------------------------------
88 ; GLOBAL FUNCTION DEFINITIONS
89 ; Function Prototype declaration
90 ----------------------------------------------------------------------------*/
91 #if ((PV_CPU_ARCH_VERSION >=5) && (PV_COMPILER == EPV_ARM_GNUC))/* Instructions for ARM-linux cross-compiler*/
93 static inline Word32 Mpy_32(Word16 L_var1_hi,
99 register Word32 product32;
100 register Word32 L_sum;
101 register Word32 L_product, result;
102 register Word32 ra = L_var1_hi;
103 register Word32 rb = L_var1_lo;
104 register Word32 rc = L_var2_hi;
105 register Word32 rd = L_var2_lo;
109 OSCL_UNUSED_ARG(pOverflow);
111 asm volatile("smulbb %0, %1, %2"
115 asm volatile("mov %0, #0"
119 asm volatile("qdadd %0, %1, %2"
121 : "r"(result), "r"(L_product)
124 asm volatile("smulbb %0, %1, %2"
129 asm volatile("mov %0, %1, ASR #15"
133 asm volatile("qdadd %0, %1, %2"
135 : "r"(L_sum), "r"(ra)
138 asm volatile("smulbb %0, %1, %2"
143 asm volatile("mov %0, %1, ASR #15"
148 asm volatile("qdadd %0, %1, %2"
150 : "r"(L_product), "r"(rb)
156 #else /* C_EQUIVALENT */
158 __inline Word32 Mpy_32(Word16 L_var1_hi,
168 OSCL_UNUSED_ARG(pOverflow);
169 L_product = (Word32) L_var1_hi * L_var2_hi;
171 if (L_product != (Word32) 0x40000000L)
180 /* result = mult (L_var1_hi, L_var2_lo, pOverflow); */
181 product32 = ((Word32) L_var1_hi * L_var2_lo) >> 15;
183 /* L_product = L_mac (L_product, result, 1, pOverflow); */
184 L_sum = L_product + (product32 << 1);
186 if ((L_product ^ product32) > 0)
188 if ((L_sum ^ L_product) < 0)
190 L_sum = (L_product < 0) ? MIN_32 : MAX_32;
196 /* result = mult (L_var1_lo, L_var2_hi, pOverflow); */
197 product32 = ((Word32) L_var1_lo * L_var2_hi) >> 15;
199 /* L_product = L_mac (L_product, result, 1, pOverflow); */
200 L_sum = L_product + (product32 << 1);
202 if ((L_product ^ product32) > 0)
204 if ((L_sum ^ L_product) < 0)
206 L_sum = (L_product < 0) ? MIN_32 : MAX_32;
210 /*----------------------------------------------------------------------------
211 ; Return nothing or data or data pointer
212 ----------------------------------------------------------------------------*/
217 /*----------------------------------------------------------------------------
219 ----------------------------------------------------------------------------*/
224 #endif /* _MPY_32_H_ */