summaryrefslogtreecommitdiffstats
path: root/baseline/source/adpcm_dec/adpcm_dec.c
diff options
context:
space:
mode:
Diffstat (limited to 'baseline/source/adpcm_dec/adpcm_dec.c')
-rw-r--r--baseline/source/adpcm_dec/adpcm_dec.c719
1 files changed, 719 insertions, 0 deletions
diff --git a/baseline/source/adpcm_dec/adpcm_dec.c b/baseline/source/adpcm_dec/adpcm_dec.c
new file mode 100644
index 0000000..6811e69
--- /dev/null
+++ b/baseline/source/adpcm_dec/adpcm_dec.c
@@ -0,0 +1,719 @@
1/*
2
3 This program is part of the TACLeBench benchmark suite.
4 Version V 1.x
5
6 Name: adpcm_dec
7
8 Author: Sung-Soo Lim
9
10 Function:
11 CCITT G.722 ADPCM (Adaptive Differential Pulse Code Modulation)
12 algorithm.
13 16khz sample rate data is stored in the array test_data[SIZE].
14 Results are stored in the array compressed[SIZE] and result[SIZE].
15 Execution time is determined by the constant SIZE (default value
16 is 2000).
17
18 Source: SNU-RT Benchmark Suite
19
20 Changes: adpcm benchmark was split into decode and encode benchmark
21
22 License: may be used, modified, and re-distributed freely, but
23 the SNU-RT Benchmark Suite must be acknowledged
24
25*/
26
27/*
28 This program is derived from the SNU-RT Benchmark Suite for Worst
29 Case Timing Analysis by Sung-Soo Lim
30
31 Original source: C Algorithms for Real-Time DSP by P. M. Embree
32*/
33
34/*
35 Forward declaration of functions
36*/
37
38#include "../extra.h"
39
40void adpcm_dec_decode( int );
41int adpcm_dec_filtez( int *bpl, int *dlt );
42void adpcm_dec_upzero( int dlt, int *dlti, int *bli );
43int adpcm_dec_filtep( int rlt1, int al1, int rlt2, int al2 );
44
45int adpcm_dec_logscl( int il, int nbl );
46int adpcm_dec_scalel( int nbl, int shift_constant );
47int adpcm_dec_uppol2( int al1, int al2, int plt, int plt1, int plt2 );
48int adpcm_dec_uppol1( int al1, int apl2, int plt, int plt1 );
49
50int adpcm_dec_logsch( int ih, int nbh );
51void adpcm_dec_reset();
52int adpcm_dec_fabs( int n );
53int adpcm_dec_cos( int n );
54int adpcm_dec_sin( int n );
55
56void adpcm_dec_init();
57int adpcm_dec_return();
58void adpcm_dec_main();
59//int main( void );
60
61
62/*
63 Declaration of macros
64*/
65/* common sampling rate for sound cards on IBM/PC */
66#define SAMPLE_RATE 11025
67#define PI 3141
68#define SIZE 3
69#define IN_END 4
70
71/*
72 Declaration of global variables
73*/
74
75int adpcm_dec_test_data[SIZE * 2], adpcm_dec_result[SIZE * 2];
76
77/* Input data for the decoder usually generated by the encoder. */
78int adpcm_dec_compressed[SIZE] = { 0, 253, 32 };
79
80/* G722 C code */
81
82/* QMF filter coefficients:
83 scaled by a factor of 4 compared to G722 CCITT recommendation */
84int adpcm_dec_h[24] = {
85 12, -44, -44, 212, 48, -624, 128, 1448,
86 -840, -3220, 3804, 15504, 15504, 3804, -3220, -840,
87 1448, 128, -624, 48, 212, -44, -44, 12
88};
89
90//int xl,xh;
91
92/* variables for receive quadrature mirror filter here */
93int adpcm_dec_accumc[11], adpcm_dec_accumd[11];
94
95/* outputs of decode() */
96int adpcm_dec_xout1, adpcm_dec_xout2;
97
98int adpcm_dec_xs, adpcm_dec_xd;
99
100/* variables for encoder (hi and lo) here */
101
102int adpcm_dec_il, adpcm_dec_szl, adpcm_dec_spl, adpcm_dec_sl, adpcm_dec_el;
103
104int adpcm_dec_qq4_code4_table[16] = {
105 0, -20456, -12896, -8968, -6288, -4240, -2584, -1200,
106 20456, 12896, 8968, 6288, 4240, 2584, 1200, 0
107};
108
109
110int adpcm_dec_qq6_code6_table[64] = {
111 -136, -136, -136, -136, -24808, -21904, -19008, -16704,
112 -14984, -13512, -12280, -11192, -10232, -9360, -8576, -7856,
113 -7192, -6576, -6000, -5456, -4944, -4464, -4008, -3576,
114 -3168, -2776, -2400, -2032, -1688, -1360, -1040, -728,
115 24808, 21904, 19008, 16704, 14984, 13512, 12280, 11192,
116 10232, 9360, 8576, 7856, 7192, 6576, 6000, 5456,
117 4944, 4464, 4008, 3576, 3168, 2776, 2400, 2032,
118 1688, 1360, 1040, 728, 432, 136, -432, -136
119};
120
121
122int adpcm_dec_wl_code_table[16] = {
123 -60, 3042, 1198, 538, 334, 172, 58, -30,
124 3042, 1198, 538, 334, 172, 58, -30, -60
125};
126
127
128int adpcm_dec_ilb_table[32] = {
129 2048, 2093, 2139, 2186, 2233, 2282, 2332, 2383,
130 2435, 2489, 2543, 2599, 2656, 2714, 2774, 2834,
131 2896, 2960, 3025, 3091, 3158, 3228, 3298, 3371,
132 3444, 3520, 3597, 3676, 3756, 3838, 3922, 4008
133};
134
135int adpcm_dec_nbl; /* delay line */
136int adpcm_dec_al1, adpcm_dec_al2;
137int adpcm_dec_plt, adpcm_dec_plt1, adpcm_dec_plt2;
138int adpcm_dec_rs;
139int adpcm_dec_dlt;
140int adpcm_dec_rlt, adpcm_dec_rlt1, adpcm_dec_rlt2;
141
142
143int adpcm_dec_detl;
144
145
146int adpcm_dec_deth;
147int adpcm_dec_sh; /* this comes from adaptive predictor */
148int adpcm_dec_eh;
149
150int adpcm_dec_qq2_code2_table[4] = {
151 -7408, -1616, 7408, 1616
152};
153
154int adpcm_dec_wh_code_table[4] = {
155 798, -214, 798, -214
156};
157
158
159int adpcm_dec_dh, adpcm_dec_ih;
160int adpcm_dec_nbh, adpcm_dec_szh;
161int adpcm_dec_sph, adpcm_dec_ph, adpcm_dec_yh, adpcm_dec_rh;
162
163int adpcm_dec_delay_dhx[6];
164
165int adpcm_dec_delay_bph[6];
166
167int adpcm_dec_ah1, adpcm_dec_ah2;
168int adpcm_dec_ph1, adpcm_dec_ph2;
169int adpcm_dec_rh1, adpcm_dec_rh2;
170
171/* variables for decoder here */
172int adpcm_dec_ilr, adpcm_dec_yl, adpcm_dec_rl;
173int adpcm_dec_dec_deth, adpcm_dec_dec_detl, adpcm_dec_dec_dlt;
174
175int adpcm_dec_dec_del_bpl[6];
176
177int adpcm_dec_dec_del_dltx[6];
178
179int adpcm_dec_dec_plt, adpcm_dec_dec_plt1, adpcm_dec_dec_plt2;
180int adpcm_dec_dec_szl, adpcm_dec_dec_spl, adpcm_dec_dec_sl;
181int adpcm_dec_dec_rlt1, adpcm_dec_dec_rlt2, adpcm_dec_dec_rlt;
182int adpcm_dec_dec_al1, adpcm_dec_dec_al2;
183int adpcm_dec_dl;
184int adpcm_dec_dec_nbl, adpcm_dec_dec_yh, adpcm_dec_dec_dh, adpcm_dec_dec_nbh;
185
186/* variables used in filtez */
187int adpcm_dec_dec_del_bph[6];
188
189int adpcm_dec_dec_del_dhx[6];
190
191int adpcm_dec_dec_szh;
192/* variables used in filtep */
193int adpcm_dec_dec_rh1, adpcm_dec_dec_rh2;
194int adpcm_dec_dec_ah1, adpcm_dec_dec_ah2;
195int adpcm_dec_dec_ph, adpcm_dec_dec_sph;
196
197int adpcm_dec_dec_sh, adpcm_dec_dec_rh;
198
199int adpcm_dec_dec_ph1, adpcm_dec_dec_ph2;
200
201