1 /******************************************************************************
2 * *
3 * Copyright (C) 2018 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *****************************************************************************
18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 #ifndef IXHEAACD_BASIC_OP_H
21 #define IXHEAACD_BASIC_OP_H
22
23 #define add_d(a, b) ((a) + (b))
24 #define sub_d(a, b) ((a) - (b))
25 #define ixheaacd_cbrt_calc(a) cbrt(1.0f / a)
26
msu32x16in32_dual(WORD32 a,WORD16 c1,WORD32 b,WORD16 c2)27 static PLATFORM_INLINE WORD32 msu32x16in32_dual(WORD32 a, WORD16 c1, WORD32 b,
28 WORD16 c2) {
29 WORD32 result;
30 WORD32 temp_result;
31 UWORD32 a_lsb;
32 WORD32 a_msb;
33 UWORD32 b_lsb;
34 WORD32 b_msb;
35
36 a_lsb = a & 65535;
37 a_msb = a >> 16;
38
39 b_lsb = b & 65535;
40 b_msb = b >> 16;
41 temp_result = ((UWORD32)a_lsb * (UWORD32)c1);
42 temp_result = temp_result - (UWORD32)b_lsb * (UWORD32)c2;
43 temp_result = ((WORD32)temp_result) >> 16;
44 result = temp_result + ((a_msb * (WORD32)c1) - (b_msb * (WORD32)c2));
45
46 return (result);
47 }
48
mac32x16in32_dual(WORD32 a,WORD16 c1,WORD32 b,WORD16 c2)49 static PLATFORM_INLINE WORD32 mac32x16in32_dual(WORD32 a, WORD16 c1, WORD32 b,
50 WORD16 c2) {
51 WORD32 result;
52 WORD32 temp_result;
53 UWORD32 a_lsb;
54 WORD32 a_msb;
55 UWORD32 b_lsb;
56 WORD32 b_msb;
57
58 a_lsb = a & 65535;
59 a_msb = a >> 16;
60
61 b_lsb = b & 65535;
62 b_msb = b >> 16;
63 temp_result = (UWORD32)a_lsb * (UWORD32)c1;
64 temp_result = temp_result + (UWORD32)b_lsb * (UWORD32)c2;
65 temp_result = ((UWORD32)temp_result) >> 16;
66 result = temp_result + ((a_msb * (WORD32)c1)) + ((b_msb * (WORD32)c2));
67 return (result);
68 }
69
mac32x32in64_dual(WORD32 a,WORD32 b,WORD64 c)70 static PLATFORM_INLINE WORD64 mac32x32in64_dual(WORD32 a, WORD32 b, WORD64 c) {
71 WORD64 result;
72 WORD64 temp_result;
73
74 temp_result = (WORD64)a * (WORD64)b;
75 result = c + (temp_result);
76 return (result);
77 }
78
79 #endif
80