annotate libtwamr/mac_32.c @ 483:4f13db3a7086

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