comparison libtwamr/mac_32.c @ 374:61047a2912a2

libtwamr: integrate mac_32.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 04:09:45 +0000
parents
children
comparison
equal deleted inserted replaced
373:128ec87489b6 374:61047a2912a2
1 /*
2 ********************************************************************************
3 *
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
5 * R99 Version 3.3.0
6 * REL-4 Version 4.1.0
7 *
8 ********************************************************************************
9 *
10 * File : mac_32.c
11 * Purpose : 32 x 32 and 32 x 16 bit DPF multiy & accumulate
12 * (similar as Mpy_32 and Mpy_32_16 in oper_32b.c)
13 *
14 ********************************************************************************
15 */
16
17 /*
18 ********************************************************************************
19 * MODULE INCLUDE FILE AND VERSION ID
20 ********************************************************************************
21 */
22 #include "namespace.h"
23 #include "mac_32.h"
24
25 /*
26 ********************************************************************************
27 * INCLUDE FILES
28 ********************************************************************************
29 */
30 #include "typedef.h"
31 #include "basic_op.h"
32 #include "oper_32b.h"
33 #include "no_count.h"
34
35 /*
36 ********************************************************************************
37 * PUBLIC PROGRAM CODE
38 ********************************************************************************
39 */
40
41 /*****************************************************************************
42 * Function Mac_32() *
43 * *
44 * Multiply two 32 bit integers (DPF) and accumulate with (normal) 32 bit *
45 * integer. The multiplication result is divided by 2**31 *
46 * *
47 * L_32 = L_32 + (hi1*hi2)<<1 + ( (hi1*lo2)>>15 + (lo1*hi2)>>15 )<<1 *
48 * *
49 * This operation can also be viewed as the multiplication of two Q31 *
50 * number and the result is also in Q31. *
51 * *
52 * Arguments: *
53 * *
54 * hi1 hi part of first number *
55 * lo1 lo part of first number *
56 * hi2 hi part of second number *
57 * lo2 lo part of second number *
58 * *
59 *****************************************************************************
60 */
61
62 Word32 Mac_32 (Word32 L_32, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
63 {
64 L_32 = L_mac (L_32, hi1, hi2);
65 L_32 = L_mac (L_32, mult (hi1, lo2), 1);
66 L_32 = L_mac (L_32, mult (lo1, hi2), 1);
67
68 return (L_32);
69 }
70
71 /*****************************************************************************
72 * Function Mac_32_16() *
73 * *
74 * Multiply a 16 bit integer by a 32 bit (DPF) and accumulate with (normal)*
75 * 32 bit integer. The multiplication result is divided by 2**15 *
76 * *
77 * *
78 * L_32 = L_32 + (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1 *
79 * *
80 * Arguments: *
81 * *
82 * hi hi part of 32 bit number. *
83 * lo lo part of 32 bit number. *
84 * n 16 bit number. *
85 * *
86 *****************************************************************************
87 */
88
89 Word32 Mac_32_16 (Word32 L_32, Word16 hi, Word16 lo, Word16 n)
90 {
91 L_32 = L_mac (L_32, hi, n);
92 L_32 = L_mac (L_32, mult (lo, n), 1);
93
94 return (L_32);
95 }