| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include "xa_gsm_state.h" |
| 10 |
|
| 11 |
typedef short word; |
| 12 |
typedef int longword; |
| 13 |
|
| 14 |
typedef unsigned short uword; |
| 15 |
typedef unsigned int ulongword; |
| 16 |
|
| 17 |
typedef struct { |
| 18 |
|
| 19 |
word dp0[ 280 ]; |
| 20 |
|
| 21 |
word z1; |
| 22 |
longword L_z2; |
| 23 |
int mp; |
| 24 |
|
| 25 |
word u[8]; |
| 26 |
word LARpp[2][8]; |
| 27 |
word j; |
| 28 |
|
| 29 |
word ltp_cut; |
| 30 |
word nrp; |
| 31 |
word v[9]; |
| 32 |
word msr; |
| 33 |
|
| 34 |
char verbose; |
| 35 |
char fast; |
| 36 |
|
| 37 |
char wav_fmt; |
| 38 |
unsigned char frame_index; |
| 39 |
unsigned char frame_chain; |
| 40 |
} XA_GSM_STATE; |
| 41 |
|
| 42 |
|
| 43 |
#define MIN_WORD (-32767 - 1) |
| 44 |
#define MAX_WORD 32767 |
| 45 |
|
| 46 |
#define MIN_LONGWORD (-2147483647 - 1) |
| 47 |
#define MAX_LONGWORD 2147483647 |
| 48 |
|
| 49 |
#ifdef SASR |
| 50 |
#undef SASR |
| 51 |
#define SASR(x, by) ((x) >> (by)) |
| 52 |
#else |
| 53 |
#define SASR(x, by) ((x) >= 0 ? (x) >> (by) : (~(-((x) + 1) >> (by)))) |
| 54 |
#endif |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
#define GSM_MULT_R(a, b) \ |
| 67 |
(SASR( ((longword)(a) * (longword)(b) + 16384), 15 )) |
| 68 |
|
| 69 |
# define GSM_MULT(a,b) \ |
| 70 |
(SASR( ((longword)(a) * (longword)(b)), 15 )) |
| 71 |
|
| 72 |
# define GSM_L_MULT(a, b) \ |
| 73 |
(((longword)(a) * (longword)(b)) << 1) |
| 74 |
|
| 75 |
# define GSM_L_ADD(a, b) \ |
| 76 |
( (a) < 0 ? ( (b) >= 0 ? (a) + (b) \ |
| 77 |
: (utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1)) \ |
| 78 |
>= MAX_LONGWORD ? MIN_LONGWORD : -(longword)utmp-2 ) \ |
| 79 |
: ((b) <= 0 ? (a) + (b) \ |
| 80 |
: (utmp = (ulongword)(a) + (ulongword)(b)) >= MAX_LONGWORD \ |
| 81 |
? MAX_LONGWORD : utmp)) |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
#define GSM_ADD(a, b) \ |
| 91 |
((ulongword)((ltmp = (longword)(a) + (longword)(b)) - MIN_WORD) > \ |
| 92 |
MAX_WORD - MIN_WORD ? (ltmp > 0 ? MAX_WORD : MIN_WORD) : ltmp) |
| 93 |
|
| 94 |
# define GSM_SUB(a, b) \ |
| 95 |
((ltmp = (longword)(a) - (longword)(b)) >= MAX_WORD \ |
| 96 |
? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp) |
| 97 |
|
| 98 |
# define GSM_ABS(a) ((a) < 0 ? ((a) == MIN_WORD ? MAX_WORD : -(a)) : (a)) |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|