changeset 374:61047a2912a2

libtwamr: integrate mac_32.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 04:09:45 +0000
parents 128ec87489b6
children 1d2b39027b70
files libtwamr/Makefile libtwamr/mac_32.c libtwamr/mac_32.h libtwamr/namespace.list
diffstat 4 files changed, 179 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libtwamr/Makefile	Mon May 06 04:03:21 2024 +0000
+++ b/libtwamr/Makefile	Mon May 06 04:09:45 2024 +0000
@@ -7,8 +7,8 @@
 	d_gain_p.o d_plsf.o d_plsf_3.o d_plsf_5.o dec_gain.o dec_lag3.o \
 	dec_lag6.o dhf_check.o dhf_tables.o e_homing.o ec_gains.o enc_lag3.o \
 	enc_lag6.o ex_ctrl.o g_adapt.o g_code.o g_pitch.o gains_tab.o gc_pred.o\
-	gmed_n.o graytab.o inv_sqrt.o log2.o lsfwt.o lsp_lsf.o oper_32b.o \
-	pow2.o prmno.o q_gain_c.o q_gain_p.o q_plsf.o q_plsf3_tab.o \
+	gmed_n.o graytab.o inv_sqrt.o log2.o lsfwt.o lsp_lsf.o mac_32.o \
+	oper_32b.o pow2.o prmno.o q_gain_c.o q_gain_p.o q_plsf.o q_plsf3_tab.o \
 	q_plsf5_tab.o q_plsf_3.o q_plsf_5.o qua_gain_tab.o reorder.o s10_8pf.o \
 	set_sign.o sqrt_l.o tls_flags.o window.o
 HDRS=	namespace.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/mac_32.c	Mon May 06 04:09:45 2024 +0000
@@ -0,0 +1,95 @@
+/*
+********************************************************************************
+*
+*      GSM AMR-NB speech codec   R98   Version 7.6.0   December 12, 2001
+*                                R99   Version 3.3.0                
+*                                REL-4 Version 4.1.0                
+*
+********************************************************************************
+*
+*      File             : mac_32.c
+*      Purpose          : 32 x 32 and 32 x 16 bit DPF multiy & accumulate
+*                         (similar as Mpy_32 and Mpy_32_16 in oper_32b.c)
+*
+********************************************************************************
+*/
+
+/*
+********************************************************************************
+*                         MODULE INCLUDE FILE AND VERSION ID
+********************************************************************************
+*/
+#include "namespace.h"
+#include "mac_32.h"
+
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "typedef.h"
+#include "basic_op.h"
+#include "oper_32b.h"
+#include "no_count.h"
+
+/*
+********************************************************************************
+*                         PUBLIC PROGRAM CODE
+********************************************************************************
+*/
+
+/*****************************************************************************
+ * Function Mac_32()                                                         *
+ *                                                                           *
+ *   Multiply two 32 bit integers (DPF) and accumulate with (normal) 32 bit  *
+ *   integer. The multiplication result is divided by 2**31                  *
+ *                                                                           *
+ *   L_32 = L_32 + (hi1*hi2)<<1 + ( (hi1*lo2)>>15 + (lo1*hi2)>>15 )<<1       *
+ *                                                                           *
+ *   This operation can also be viewed as the multiplication of two Q31      *
+ *   number and the result is also in Q31.                                   *
+ *                                                                           *
+ * Arguments:                                                                *
+ *                                                                           *
+ *  hi1         hi part of first number                                      *
+ *  lo1         lo part of first number                                      *
+ *  hi2         hi part of second number                                     *
+ *  lo2         lo part of second number                                     *
+ *                                                                           *
+ *****************************************************************************
+*/
+
+Word32 Mac_32 (Word32 L_32, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
+{
+    L_32 = L_mac (L_32, hi1, hi2);
+    L_32 = L_mac (L_32, mult (hi1, lo2), 1);
+    L_32 = L_mac (L_32, mult (lo1, hi2), 1);
+
+    return (L_32);
+}
+
+/*****************************************************************************
+ * Function Mac_32_16()                                                      *
+ *                                                                           *
+ *   Multiply a 16 bit integer by a 32 bit (DPF) and accumulate with (normal)*
+ *   32 bit integer. The multiplication result is divided by 2**15           *
+ *                                                                           *
+ *                                                                           *
+ *   L_32 = L_32 + (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1                         *
+ *                                                                           *
+ * Arguments:                                                                *
+ *                                                                           *
+ *  hi          hi part of 32 bit number.                                    *
+ *  lo          lo part of 32 bit number.                                    *
+ *  n           16 bit number.                                               *
+ *                                                                           *
+ *****************************************************************************
+*/
+
+Word32 Mac_32_16 (Word32 L_32, Word16 hi, Word16 lo, Word16 n)
+{
+    L_32 = L_mac (L_32, hi, n);
+    L_32 = L_mac (L_32, mult (lo, n), 1);
+
+    return (L_32);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/mac_32.h	Mon May 06 04:09:45 2024 +0000
@@ -0,0 +1,81 @@
+/*
+********************************************************************************
+*
+*      GSM AMR-NB speech codec   R98   Version 7.6.0   December 12, 2001
+*                                R99   Version 3.3.0                
+*                                REL-4 Version 4.1.0                
+*
+********************************************************************************
+*
+*      File             : mac_32.h
+*      Purpose          : 32 x 32 and 32 x 16 bit DPF multiy & accumulate
+*                         (similar as Mpy_32 and Mpy_32_16 in oper_32b.c)
+*
+********************************************************************************
+*/
+
+/*
+********************************************************************************
+*                         MODULE INCLUDE FILE AND VERSION ID
+********************************************************************************
+*/
+#ifndef mac_32_h
+#define mac_32_h "$Id $"
+
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "typedef.h"
+
+/*
+********************************************************************************
+*                         PUBLIC PROGRAM CODE
+********************************************************************************
+*/
+
+/*****************************************************************************
+ * Function Mac_32()                                                         *
+ *                                                                           *
+ *   Multiply two 32 bit integers (DPF) and accumulate with (normal) 32 bit  *
+ *   integer. The multiplication result is divided by 2**31                  *
+ *                                                                           *
+ *   L_32 = L_32 + (hi1*hi2)<<1 + ( (hi1*lo2)>>15 + (lo1*hi2)>>15 )<<1       *
+ *                                                                           *
+ *   This operation can also be viewed as the multiplication of two Q31      *
+ *   number and the result is also in Q31.                                   *
+ *                                                                           *
+ * Arguments:                                                                *
+ *                                                                           *
+ *  hi1         hi part of first number                                      *
+ *  lo1         lo part of first number                                      *
+ *  hi2         hi part of second number                                     *
+ *  lo2         lo part of second number                                     *
+ *                                                                           *
+ *****************************************************************************
+*/
+
+Word32 Mac_32 (Word32 L_32, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2);
+
+/*****************************************************************************
+ * Function Mac_32_16()                                                      *
+ *                                                                           *
+ *   Multiply a 16 bit integer by a 32 bit (DPF) and accumulate with (normal)*
+ *   32 bit integer. The multiplication result is divided by 2**15           *
+ *                                                                           *
+ *                                                                           *
+ *   L_32 = L_32 + (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1                         *
+ *                                                                           *
+ * Arguments:                                                                *
+ *                                                                           *
+ *  hi          hi part of 32 bit number.                                    *
+ *  lo          lo part of 32 bit number.                                    *
+ *  n           16 bit number.                                               *
+ *                                                                           *
+ *****************************************************************************
+*/
+
+Word32 Mac_32_16 (Word32 L_32, Word16 hi, Word16 lo, Word16 n);
+
+#endif
--- a/libtwamr/namespace.list	Mon May 06 04:03:21 2024 +0000
+++ b/libtwamr/namespace.list	Mon May 06 04:09:45 2024 +0000
@@ -12,6 +12,7 @@
 L_deposit_h L_deposit_l L_shr_r L_abs L_sat
 norm_m div_s norm_l
 L_Extract L_Comp Mpy_32 Mpy_32_16 Div_32
+Mac_32 Mac_32_16
 
 Inv_sqrt Log2 Log2_norm Pow2