summaryrefslogtreecommitdiffstats
path: root/baseline/source/adpcm_enc/adpcm_enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'baseline/source/adpcm_enc/adpcm_enc.c')
-rw-r--r--baseline/source/adpcm_enc/adpcm_enc.c756
1 files changed, 0 insertions, 756 deletions
diff --git a/baseline/source/adpcm_enc/adpcm_enc.c b/baseline/source/adpcm_enc/adpcm_enc.c
deleted file mode 100644
index 118382f..0000000
--- a/baseline/source/adpcm_enc/adpcm_enc.c
+++ /dev/null
@@ -1,756 +0,0 @@
1/*
2
3 This program is part of the TACLeBench benchmark suite.
4 Version V 2.0
5
6 Name: adpcm_enc
7
8 Author: Sung-Soo Lim
9
10 Function: CCITT G.722 ADPCM (Adaptive Differential Pulse Code Modulation)
11 algorithm. 16khz sample rate data is stored in the array test_data[SIZE].
12 Results are stored in the array compressed[SIZE].
13 Execution time is determined by the constant SIZE (default value is 2000).
14
15
16 Source: C Algorithms for Real-Time DSP by P. M. Embree
17 and SNU-RT Benchmark Suite for Worst Case Timing Analysis
18 collected and modified by S.-S. Lim <sslim@archi.snu.ac.kr>
19
20 Original name: adpcm_encoder
21
22 Changes: no major functional changes
23
24 License: may be used, modified, and re-distributed freely, but the
25 SNU-RT Benchmark Suite must be acknowledged
26
27*/
28
29
30/* common sampling rate for sound cards on IBM/PC */
31
32#include "extra.h"
33#define SAMPLE_RATE 11025
34
35#define PI 3141
36#define SIZE 3
37#define IN_END 4
38
39
40/*
41 Forward declaration of functions
42*/
43
44int adpcm_enc_encode( int, int );
45int adpcm_enc_filtez( int *bpl, int *dlt );
46void adpcm_enc_upzero( int dlt, int *dlti, int *bli );
47int adpcm_enc_filtep( int rlt1, int al1, int rlt2, int al2 );
48int adpcm_enc_quantl( int el, int detl );
49int adpcm_enc_logscl( int il, int nbl );
50int adpcm_enc_scalel( int nbl, int shift_constant );
51int adpcm_enc_uppol2( int al1, int al2, int plt, int plt1, int plt2 );
52int adpcm_enc_uppol1( int al1, int apl2, int plt, int plt1 );
53int adpcm_enc_logsch( int ih, int nbh );
54void adpcm_enc_reset();
55int adpcm_enc_fabs( int n );
56int adpcm_enc_cos( int n );
57int adpcm_enc_sin( int n );
58int adpcm_enc_abs( int n );
59void adpcm_enc_init(void);
60void adpcm_enc_main(void);
61int adpcm_enc_return(void);
62//int main(void);
63
64/*
65 Forward declaration of global variables
66*/
67
68int adpcm_enc_test_data[SIZE * 2], adpcm_enc_compressed[SIZE];
69
70
71/* G722 C code */
72
73/* variables for transimit quadrature mirror filter here */
74int adpcm_enc_tqmf[24];
75
76/* QMF filter coefficients:
77scaled by a factor of 4 compared to G722 CCITT recommendation */
78int adpcm_enc_h[24] = {
79 12, -44, -44, 212, 48, -624, 128, 1448,
80 -840, -3220, 3804, 15504, 15504, 3804, -3220, -840,
81 1448, 128, -624, 48, 212, -44, -44, 12
82};
83
84int adpcm_enc_xl, adpcm_enc_xh;
85
86/* variables for encoder (hi and lo) here */
87
88int adpcm_enc_il, adpcm_enc_szl, adpcm_enc_spl, adpcm_enc_sl, adpcm_enc_el;
89
90int adpcm_enc_qq4_code4_table[16] = {
91 0, -20456, -12896, -8968, -6288, -4240, -2584, -1200,
92 20456, 12896, 8968, 6288, 4240, 2584, 1200, 0
93};
94
95int adpcm_enc_qq5_code5_table[32] = {
96 -280, -280, -23352, -17560, -14120, -11664, -9752, -8184,
97 -6864, -5712, -4696, -3784, -2960, -2208, -1520, -880,
98 23352, 17560, 14120, 11664, 9752, 8184, 6864, 5712,
99 4696, 3784, 2960, 2208, 1520, 880, 280, -280
100};
101
102int adpcm_enc_qq6_code6_table[64] = {
103 -136, -136, -136, -136, -24808, -21904, -19008, -16704,
104-14984, -13512, -12280, -11192, -10232, -9360, -8576, -7856,
105 -7192, -6576, -6000, -5456, -4944, -4464, -4008, -3576,
106 -3168, -2776, -2400, -2032, -1688, -1360, -1040, -728,
107 24808, 21904, 19008, 16704, 14984, 13512, 12280, 11192,
108 10232, 9360, 8576, 7856, 7192, 6576, 6000, 5456,
109 4944, 4464, 4008, 3576, 3168, 2776, 2400, 2032,
110 1688, 1360, 1040, 728, 432, 136, -432, -136
111};
112
113int adpcm_enc_delay_bpl[6];
114
115int adpcm_enc_delay_dltx[6];
116
117int adpcm_enc_wl_code_table[16] = {
118 -60, 3042, 1198, 538, 334, 172, 58, -30,
119 3042, 1198, 538, 334, 172, 58, -30, -60
120};
121
122int adpcm_enc_ilb_table[32] = {
123 2048, 2093, 2139, 2186, 2233, 2282, 2332, 2383,
124 2435, 2489, 2543, 2599, 2656, 2714, 2774, 2834,
125 2896, 2960, 3025, 3091, 3158, 3228, 3298, 3371,
126 3444, 3520, 3597, 3676, 3756, 3838, 3922, 4008
127};
128
129int adpcm_enc_nbl; /* delay line */
130int adpcm_enc_al1, adpcm_enc_al2;
131int adpcm_enc_plt, adpcm_enc_plt1, adpcm_enc_plt2;
132int adpcm_enc_dlt;
133int adpcm_enc_rlt, adpcm_enc_rlt1, adpcm_enc_rlt2;
134
135/* decision levels - pre-multiplied by 8, 0 to indicate end */
136int adpcm_enc_decis_levl[30] = {
137 280, 576, 880, 1200, 1520, 1864, 2208, 2584,
138 2960, 3376, 3784, 4240, 4696, 5200, 5712, 6288,
139 6864, 7520, 8184, 8968, 9752, 10712, 11664, 12896,
140 14120, 15840, 17560, 20456, 23352, 32767
141};
142
143int adpcm_enc_detl;
144
145/* quantization table 31 long to make quantl look-up easier,
146last entry is for mil=30 case when wd is max */
147int adpcm_enc_quant26bt_pos[31] = {
148 61, 60, 59, 58, 57, 56, 55, 54,
149 53, 52, 51, 50, 49, 48, 47, 46,
150 45, 44, 43, 42, 41, 40, 39, 38,
151 37, 36, 35, 34, 33, 32, 32
152};
153
154/* quantization table 31 long to make quantl look-up easier,
155last entry is for mil=30 case when wd is max */
156int adpcm_enc_quant26bt_neg[31] = {
157 63, 62, 31, 30, 29, 28, 27, 26,
158 25, 24, 23, 22, 21, 20, 19, 18,
159 17, 16, 15, 14, 13, 12, 11, 10,
160 9, 8, 7, 6, 5, 4, 4
161};
162
163
164int adpcm_enc_deth;
165int adpcm_enc_sh; /* this comes from adaptive predictor */
166int adpcm_enc_eh;
167
168int adpcm_enc_qq2_code2_table[4] = {
169 -7408, -1616, 7408, 1616
170};
171
172int adpcm_enc_wh_code_table[4] = {
173 798, -214, 798, -214
174};
175
176
177int adpcm_enc_dh, adpcm_enc_ih;
178int adpcm_enc_nbh, adpcm_enc_szh;
179int adpcm_enc_sph, adpcm_enc_ph, adpcm_enc_yh;
180
181int adpcm_enc_delay_dhx[6];
182int adpcm_enc_delay_bph[6];
183
184int adpcm_enc_ah1, adpcm_enc_ah2;
185int adpcm_enc_ph1, adpcm_enc_ph2;
186int adpcm_enc_rh1, adpcm_enc_rh2;
187
188
189/* G722 encode function two ints in, one 8 bit output */
190
191/* put input samples in xin1 = first value, xin2 = second value */
192/* returns il and ih stored together */
193
194
195/* MAX: 1 */
196int adpcm_enc_abs( int n )
197{
198 int m;
199
200
201 if ( n >= 0 )
202 m = n;