summaryrefslogtreecommitdiffstats
path: root/baseline/source/gsm_dec/add.h
diff options
context:
space:
mode:
Diffstat (limited to 'baseline/source/gsm_dec/add.h')
-rw-r--r--baseline/source/gsm_dec/add.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/baseline/source/gsm_dec/add.h b/baseline/source/gsm_dec/add.h
new file mode 100644
index 0000000..ffe79b7
--- /dev/null
+++ b/baseline/source/gsm_dec/add.h
@@ -0,0 +1,55 @@
1#ifndef GSM_DEC_ADD_H
2#define GSM_DEC_ADD_H
3
4#define GSM_MULT_R(a, b) /* word a, word b, !(a == b == MIN_WORD) */ \
5 (SASR( ((longword)(a) * (longword)(b) + 16384), 15 ))
6
7# define GSM_MULT(a,b) /* word a, word b, !(a == b == MIN_WORD) */ \
8 (SASR( ((longword)(a) * (longword)(b)), 15 ))
9
10# define GSM_L_MULT(a, b) /* word a, word b */ \
11 (((longword)(a) * (longword)(b)) << 1)
12
13# define GSM_L_ADD(a, b) \
14 ( (a) < 0 ? ( (b) >= 0 ? (a) + (b) \
15 : (utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1)) \
16 >= MAX_LONGWORD ? MIN_LONGWORD : -(longword)utmp-2 ) \
17 : ((b) <= 0 ? (a) + (b) \
18 : (utmp = (ulongword)(a) + (ulongword)(b)) >= MAX_LONGWORD \
19 ? MAX_LONGWORD : utmp))
20
21/*
22 # define GSM_ADD(a, b) \
23 ((ltmp = (longword)(a) + (longword)(b)) >= MAX_WORD \
24 ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp)
25*/
26/* Nonportable, but faster: */
27
28#define GSM_ADD(a, b) \
29 ((ulongword)((ltmp = (longword)(a) + (longword)(b)) - MIN_WORD) > \
30 MAX_WORD - MIN_WORD ? (ltmp > 0 ? MAX_WORD : MIN_WORD) : ltmp)
31
32# define GSM_SUB(a, b) \
33 ((ltmp = (longword)(a) - (longword)(b)) >= MAX_WORD \
34 ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp)
35
36# define GSM_ABS(a) ((a) < 0 ? ((a) == MIN_WORD ? MAX_WORD : -(a)) : (a))
37
38#define saturate(x) \
39 ((x) < MIN_WORD ? MIN_WORD : (x) > MAX_WORD ? MAX_WORD: (x))
40
41/* Use these if necessary:
42
43 # define GSM_MULT_R(a, b) gsm_mult_r(a, b)
44 # define GSM_MULT(a, b) gsm_mult(a, b)
45 # define GSM_L_MULT(a, b) gsm_L_mult(a, b)
46
47 # define GSM_L_ADD(a, b) gsm_L_add(a, b)
48 # define GSM_ADD(a, b) gsm_add(a, b)
49 # define GSM_SUB(a, b) gsm_sub(a, b)
50
51 # define GSM_ABS(a) gsm_abs(a)
52
53*/
54
55#endif /* GSM_DEC_ADD_H */