summaryrefslogtreecommitdiffstats
path: root/baseline/source/adpcm_dec
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
commit386b7d3366f1359a265da207a9cafa3edf553b64 (patch)
treec76120c2c138faed822e4ae386be6ef22a738a78 /baseline/source/adpcm_dec
parent54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff)
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'baseline/source/adpcm_dec')
-rw-r--r--baseline/source/adpcm_dec/ChangeLog.txt32
-rw-r--r--baseline/source/adpcm_dec/adpcm_dec.c719
-rw-r--r--baseline/source/adpcm_dec/timedTest.txt100
3 files changed, 851 insertions, 0 deletions
diff --git a/baseline/source/adpcm_dec/ChangeLog.txt b/baseline/source/adpcm_dec/ChangeLog.txt
new file mode 100644
index 0000000..b9c4f96
--- /dev/null
+++ b/baseline/source/adpcm_dec/ChangeLog.txt
@@ -0,0 +1,32 @@
1File: minver.c
2Original provenience: SNU-RT Benchmark Suite for Worst Case Timing Analysis
3
42016-02-26:
5 - Added TACLeBench header to line 1
6 - Rename global variable a to minver_a
7 - Rename global variable b to minver_b
8 - Rename global variable c to minver_c
9 - Rename global variable aa to minver_aa
10 - Rename global variable a_i to minver_a_i
11 - Rename global variable e to minver_e
12 - Rename global variable det to minver_det
13 - Renamed function minver to minver_minver
14 - Renamed function mmul to minver_mmul
15 - Renamed function fabs to minver_fabs
16 - Renamed function main to minver_main
17 - Created new function main, calling minver_init, minver_main and
18 returning minver_return
19 - Reordered functions in source code: initialization- and
20 return-value-related functions first, followed by algorithm core
21 functions, followed by main functions
22 - Applied code formatting with astyle as in the example
23
242016-03-09:
25 - Removed static keyword for global variables
26 - Renamed global variables, prepended adpcm_dec
27
28 2016-05-23:
29 - Check sum added and checked against the expected value
30
31 2016-05-25:
32 - Corrected expected value \ No newline at end of file
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
202/*
203 Arithmetic math functions
204*/
205
206
207/* MAX: 1 */
208int adpcm_dec_fabs( int n )
209{
210 int f;
211
212
213 if ( n >= 0 )
214 f = n;
215 else
216 f = -n;
217
218 return f;
219}
220
221
222int adpcm_dec_sin( int rad )
223{
224 int diff;
225 int app = 0;
226 int inc = 1;
227
228
229 /* MAX dependent on rad's value, say 50 */
230 _Pragma( "loopbound min 0 max 0" )
231 while ( rad > 2 * PI )
232 rad -= 2 * PI;
233
234 _Pragma( "loopbound min 0 max 1999" )
235 while ( rad < -2 * PI )
236 rad += 2 * PI;
237
238 diff = rad;
239 app = diff;
240 diff = ( diff * ( -( rad * rad ) ) ) / ( ( 2 * inc ) * ( 2 * inc + 1 ) );
241 app = app + diff;
242 inc++;
243
244 /* REALLY: while(my_fabs(diff) >= 0.00001) { */
245 /* MAX: 1000 */
246 _Pragma( "loopbound min 849 max 2424" )
247 while ( adpcm_dec_fabs( diff ) >= 1 ) {
248 diff = ( diff * ( -( rad * rad ) ) ) / ( ( 2 * inc ) * ( 2 * inc + 1 ) );
249 app = app + diff;
250 inc++;
251 }
252
253 return app;
254}
255
256
257int adpcm_dec_cos( int rad )
258{
259 return ( adpcm_dec_sin( PI / 2 - rad ) );
260}
261
262
263/*
264 Algorithm core functions
265*/
266
267/* decode function, result in xout1 and xout2 */
268void adpcm_dec_decode( int input )
269{
270 int i;
271 long int xa1, xa2; /* qmf accumulators */
272 int *h_ptr, *ac_ptr, *ac_ptr1, *ad_ptr, *ad_ptr1;
273
274
275 /* split transmitted word from input into ilr and ih */
276 adpcm_dec_ilr = input & 0x3f;
277 adpcm_dec_ih = input >> 6;
278
279 /* LOWER SUB_BAND DECODER */
280
281 /* filtez: compute predictor output for zero section */
282 adpcm_dec_dec_szl = adpcm_dec_filtez( adpcm_dec_dec_del_bpl,
283 adpcm_dec_dec_del_dltx );
284
285 /* filtep: compute predictor output signal for pole section */
286 adpcm_dec_dec_spl = adpcm_dec_filtep( adpcm_dec_dec_rlt1, adpcm_dec_dec_al1,
287 adpcm_dec_dec_rlt2, adpcm_dec_dec_al2 );
288
289 adpcm_dec_dec_sl = adpcm_dec_dec_spl + adpcm_dec_dec_szl;
290
291 /* invqxl: compute quantized difference signal for adaptive predic */
292 adpcm_dec_dec_dlt = ( ( long )adpcm_dec_dec_detl *
293 adpcm_dec_qq4_code4_table[adpcm_dec_ilr
294 >> 2] ) >> 15;
295
296 /* invqxl: compute quantized difference signal for decoder output */
297 adpcm_dec_dl = ( ( long )adpcm_dec_dec_detl *
298 adpcm_dec_qq6_code6_table[adpcm_dec_il] ) >>
299 15;
300
301 adpcm_dec_rl = adpcm_dec_dl + adpcm_dec_dec_sl;
302
303 /* logscl: quantizer scale factor adaptation in the lower sub-band */
304 adpcm_dec_dec_nbl = adpcm_dec_logscl( adpcm_dec_ilr, adpcm_dec_dec_nbl );
305
306 /* scalel: computes quantizer scale factor in the lower sub band */
307 adpcm_dec_dec_detl = adpcm_dec_scalel( adpcm_dec_dec_nbl, 8 );
308
309 /* parrec - add pole predictor output to quantized diff. signal */
310 /* for partially reconstructed signal */
311 adpcm_dec_dec_plt = adpcm_dec_dec_dlt + adpcm_dec_dec_szl;
312
313 /* upzero: update zero section predictor coefficients */
314 adpcm_dec_upzero( adpcm_dec_dec_dlt, adpcm_dec_dec_del_dltx,
315 adpcm_dec_dec_del_bpl );
316
317 /* uppol2: update second predictor coefficient apl2 and delay it as al2 */
318 adpcm_dec_dec_al2 = adpcm_dec_uppol2( adpcm_dec_dec_al1, adpcm_dec_dec_al2,
319 adpcm_dec_dec_plt, adpcm_dec_dec_plt1,
320 adpcm_dec_dec_plt2 );
321
322 /* uppol1: update first predictor coef. (pole setion) */
323 adpcm_dec_dec_al1 = adpcm_dec_uppol1( adpcm_dec_dec_al1, adpcm_dec_dec_al2,
324 adpcm_dec_dec_plt, adpcm_dec_dec_plt1 );
325
326 /* recons : compute recontructed signal for adaptive predictor */
327 adpcm_dec_dec_rlt = adpcm_dec_dec_sl + adpcm_dec_dec_dlt;
328
329 /* done with lower sub band decoder, implement delays for next time */
330 adpcm_dec_dec_rlt2 = adpcm_dec_dec_rlt1;
331 adpcm_dec_dec_rlt1 = adpcm_dec_dec_rlt;
332 adpcm_dec_dec_plt2 = adpcm_dec_dec_plt1;
333 adpcm_dec_dec_plt1 = adpcm_dec_dec_plt;
334
335 /* HIGH SUB-BAND DECODER */
336
337 /* filtez: compute predictor output for zero section */
338 adpcm_dec_dec_szh = adpcm_dec_filtez( adpcm_dec_dec_del_bph,
339 adpcm_dec_dec_del_dhx );
340
341 /* filtep: compute predictor output signal for pole section */
342 adpcm_dec_dec_sph = adpcm_dec_filtep( adpcm_dec_dec_rh1, adpcm_dec_dec_ah1,
343 adpcm_dec_dec_rh2, adpcm_dec_dec_ah2 );
344
345 /* predic:compute the predictor output value in the higher sub_band decoder */
346 adpcm_dec_dec_sh = adpcm_dec_dec_sph + adpcm_dec_dec_szh;
347
348 /* invqah: in-place compute the quantized difference signal */
349 adpcm_dec_dec_dh = ( ( long )adpcm_dec_dec_deth *
350 adpcm_dec_qq2_code2_table[adpcm_dec_ih] ) >> 15L ;
351
352 /* logsch: update logarithmic quantizer scale factor in hi sub band */
353 adpcm_dec_dec_nbh = adpcm_dec_logsch( adpcm_dec_ih, adpcm_dec_dec_nbh );
354
355 /* scalel: compute the quantizer scale factor in the higher sub band */
356 adpcm_dec_dec_deth = adpcm_dec_scalel( adpcm_dec_dec_nbh, 10 );
357
358 /* parrec: compute partially recontructed signal */
359 adpcm_dec_dec_ph = adpcm_dec_dec_dh + adpcm_dec_dec_szh;
360
361 /* upzero: update zero section predictor coefficients */
362 adpcm_dec_upzero( adpcm_dec_dec_dh, adpcm_dec_dec_del_dhx,
363 adpcm_dec_dec_del_bph );
364
365 /* uppol2: update second predictor coefficient aph2 and delay it as ah2 */
366 adpcm_dec_dec_ah2 = adpcm_dec_uppol2( adpcm_dec_dec_ah1, adpcm_dec_dec_ah2,
367 adpcm_dec_dec_ph, adpcm_dec_dec_ph1, adpcm_dec_dec_ph2 );
368
369 /* uppol1: update first predictor coef. (pole setion) */
370 adpcm_dec_dec_ah1 = adpcm_dec_uppol1( adpcm_dec_dec_ah1, adpcm_dec_dec_ah2,
371 adpcm_dec_dec_ph, adpcm_dec_dec_ph1 );
372
373 /* recons : compute recontructed signal for adaptive predictor */
374 adpcm_dec_rh = adpcm_dec_dec_sh + adpcm_dec_dec_dh;
375
376 /* done with high band decode, implementing delays for next time here */
377 adpcm_dec_dec_rh2 = adpcm_dec_dec_rh1;
378 adpcm_dec_dec_rh1 = adpcm_dec_rh;
379 adpcm_dec_dec_ph2 = adpcm_dec_dec_ph1;
380 adpcm_dec_dec_ph1 = adpcm_dec_dec_ph;
381
382 /* end of higher sub_band decoder */
383
384 /* end with receive quadrature mirror filters */
385 adpcm_dec_xd = adpcm_dec_rl - adpcm_dec_rh;
386 adpcm_dec_xs = adpcm_dec_rl + adpcm_dec_rh;
387
388 /* receive quadrature mirror filters implemented here */
389 h_ptr = adpcm_dec_h;
390 ac_ptr = adpcm_dec_accumc;
391 ad_ptr = adpcm_dec_accumd;
392 xa1 = ( long ) adpcm_dec_xd * ( *h_ptr++ );
393 xa2 = ( long ) adpcm_dec_xs * ( *h_ptr++ );
394
395 /* main multiply accumulate loop for samples and coefficients */
396 _Pragma( "loopbound min 10 max 10" )
397 for ( i = 0; i < 10; i++ ) {
398 xa1 += ( long )( *ac_ptr++ ) * ( *h_ptr++ );
399 xa2 += ( long )( *ad_ptr++ ) * ( *h_ptr++ );
400 }
401
402 /* final mult/accumulate */
403 xa1 += ( long )( *ac_ptr ) * ( *h_ptr++ );
404 xa2 += ( long )( *ad_ptr ) * ( *h_ptr++ );
405
406 /* scale by 2^14 */
407 adpcm_dec_xout1 = xa1 >> 14;
408 adpcm_dec_xout2 = xa2 >> 14;
409
410 /* update delay lines */
411 ac_ptr1 = ac_ptr - 1;
412 ad_ptr1 = ad_ptr - 1;
413
414 _Pragma( "loopbound min 10 max 10" )
415 for ( i = 0; i < 10; i++ ) {
416 *ac_ptr-- = *ac_ptr1--;
417 *ad_ptr-- = *ad_ptr1--;
418 }
419
420 *ac_ptr = adpcm_dec_xd;
421 *ad_ptr = adpcm_dec_xs;
422
423 return;
424}
425
426
427/* filtez - compute predictor output signal (zero section) */
428/* input: bpl1-6 and dlt1-6, output: szl */
429int adpcm_dec_filtez( int *bpl, int *dlt )
430{
431 int i;
432 long int zl;
433
434
435 zl = ( long )( *bpl++ ) * ( *dlt++ );
436
437 /* MAX: 5 */
438 _Pragma( "loopbound min 5 max 5" )
439 for ( i = 1; i < 6; i++ )
440 zl += ( long )( *bpl++ ) * ( *dlt++ );
441
442 return ( ( int )( zl >> 14 ) ); /* x2 here */
443}
444
445
446/* filtep - compute predictor output signal (pole section) */
447/* input rlt1-2 and al1-2, output spl */
448int adpcm_dec_filtep( int rlt1, int al1, int rlt2, int al2 )
449{
450 long int pl, pl2;
451
452
453 pl = 2 * rlt1;
454 pl = ( long ) al1 * pl;
455 pl2 = 2 * rlt2;
456 pl += ( long ) al2 * pl2;
457
458 return ( ( int )( pl >> 15 ) );
459}
460
461
462/* logscl - update log quantizer scale factor in lower sub-band */
463/* note that nbl is passed and returned */
464int adpcm_dec_logscl( int il, int nbl )
465{
466 long int wd;
467
468
469 wd = ( ( long )nbl * 127L ) >> 7L; /* leak factor 127/128 */
470 nbl = ( int )wd + adpcm_dec_wl_code_table[il >> 2];
471
472 if ( nbl < 0 )
473 nbl = 0;
474 if ( nbl > 18432 )
475 nbl = 18432;
476
477 return ( nbl );
478}
479
480
481/* scalel: compute quantizer scale factor in lower or upper sub-band*/
482int adpcm_dec_scalel( int nbl, int shift_constant )
483{
484 int wd1, wd2, wd3;
485
486
487 wd1 = ( nbl >> 6 ) & 31;
488 wd2 = nbl >> 11;
489 wd3 = adpcm_dec_ilb_table[wd1] >> ( shift_constant + 1 - wd2 );
490
491 return ( wd3 << 3 );
492}
493
494
495/* upzero - inputs: dlt, dlti[0-5], bli[0-5], outputs: updated bli[0-5] */
496/* also implements delay of bli and update of dlti from dlt */
497void adpcm_dec_upzero( int dlt, int *dlti, int *bli )
498{
499 int i, wd2, wd3;
500
501
502 /*if dlt is zero, then no sum into bli */
503 if ( dlt == 0 ) {
504 _Pragma( "loopbound min 6 max 6" )
505 for ( i = 0; i < 6; i++ ) {
506 bli[i] = ( int )( ( 255L * bli[i] ) >> 8L ); /* leak factor of 255/256 */
507 }
508
509 } else {
510 _Pragma( "loopbound min 6 max 6" )
511 for ( i = 0; i < 6; i++ ) {
512 if ( ( long )dlt * dlti[i] >= 0 )
513 wd2 = 128;
514 else
515 wd2 = -128;
516
517 wd3 = ( int )( ( 255L * bli[i] ) >> 8L ); /* leak factor of 255/256 */
518 bli[i] = wd2 + wd3;
519 }
520
521 }
522
523 /* implement delay line for dlt */
524 dlti[5] = dlti[4];
525 dlti[4] = dlti[3];
526 dlti[3] = dlti[2];
527 dlti[1] = dlti[0];
528 dlti[0] = dlt;
529
530 return;
531}
532
533
534/* uppol2 - update second predictor coefficient (pole section) */
535/* inputs: al1, al2, plt, plt1, plt2. outputs: apl2 */
536int adpcm_dec_uppol2( int al1, int al2, int plt, int plt1, int plt2 )
537{
538 long int wd2, wd4;
539 int apl2;
540
541
542 wd2 = 4L * ( long )al1;
543 if ( ( long )plt * plt1 >= 0L )
544 wd2 = -wd2; /* check same sign */
545 wd2 = wd2 >> 7; /* gain of 1/128 */
546
547 if ( ( long )plt * plt2 >= 0L ) {
548 wd4 = wd2 + 128; /* same sign case */
549 } else
550 wd4 = wd2 - 128;
551 apl2 = wd4 + ( 127L * ( long )al2 >> 7L ); /* leak factor of 127/128 */
552
553 /* apl2 is limited to +-.75 */
554 if ( apl2 > 12288 )
555 apl2 = 12288;
556 if ( apl2 < -12288 )
557 apl2 = -12288;
558
559 return ( apl2 );
560}
561
562
563/* uppol1 - update first predictor coefficient (pole section) */
564/* inputs: al1, apl2, plt, plt1. outputs: apl1 */
565int adpcm_dec_uppol1( int al1, int apl2, int plt, int plt1 )
566{
567 long int wd2;
568 int wd3, apl1;
569
570
571 wd2 = ( ( long )al1 * 255L ) >> 8L; /* leak factor of 255/256 */
572 if ( ( long )plt * plt1 >= 0L ) {
573 apl1 = ( int )wd2 + 192; /* same sign case */
574 } else
575 apl1 = ( int )wd2 - 192;
576
577 /* note: wd3= .9375-.75 is always positive */
578 wd3 = 15360 - apl2; /* limit value */
579 if ( apl1 > wd3 )
580 apl1 = wd3;
581 if ( apl1 < -wd3 )
582 apl1 = -wd3;
583
584 return ( apl1 );
585}
586
587
588/* logsch - update log quantizer scale factor in higher sub-band */
589/* note that nbh is passed and returned */
590int adpcm_dec_logsch( int ih, int nbh )
591{
592 int wd;
593
594
595 wd = ( ( long )nbh * 127L ) >> 7L; /* leak factor 127/128 */
596 nbh = wd + adpcm_dec_wh_code_table[ih];
597
598 if ( nbh < 0 )
599 nbh = 0;
600 if ( nbh > 22528 )
601 nbh = 22528;
602
603 return ( nbh );
604}
605
606/*
607 Initialization- and return-value-related functions
608*/
609
610/* clear all storage locations */
611
612void adpcm_dec_reset()
613{
614 int i;
615
616
617 adpcm_dec_detl = adpcm_dec_dec_detl = 32; /* reset to min scale factor */
618 adpcm_dec_deth = adpcm_dec_dec_deth = 8;
619 adpcm_dec_nbl = adpcm_dec_al1 = adpcm_dec_al2 = adpcm_dec_plt1 = adpcm_dec_plt2
620 = adpcm_dec_rlt1 = adpcm_dec_rlt2 = 0;
621 adpcm_dec_nbh = adpcm_dec_ah1 = adpcm_dec_ah2 = adpcm_dec_ph1 = adpcm_dec_ph2 =
622 adpcm_dec_rh1 = adpcm_dec_rh2 = 0;
623 adpcm_dec_dec_nbl = adpcm_dec_dec_al1 = adpcm_dec_dec_al2 = adpcm_dec_dec_plt1 =
624 adpcm_dec_dec_plt2 = adpcm_dec_dec_rlt1 = adpcm_dec_dec_rlt2 = 0;
625 adpcm_dec_dec_nbh = adpcm_dec_dec_ah1 = adpcm_dec_dec_ah2 = adpcm_dec_dec_ph1 =
626 adpcm_dec_dec_ph2 = adpcm_dec_dec_rh1 = adpcm_dec_dec_rh2 = 0;
627
628 _Pragma( "loopbound min 6 max 6" )
629 for ( i = 0; i < 6; i++ ) {
630 ////delay_dltx[i] = 0;
631 adpcm_dec_delay_dhx[i] = 0;
632 adpcm_dec_dec_del_dltx[i] = 0;
633 adpcm_dec_dec_del_dhx[i] = 0;
634 }
635
636 _Pragma( "loopbound min 6 max 6" )
637 for ( i = 0; i < 6; i++ ) {
638 //delay_bpl[i] = 0;
639 adpcm_dec_delay_bph[i] = 0;
640 adpcm_dec_dec_del_bpl[i] = 0;
641 adpcm_dec_dec_del_bph[i] = 0;
642 }
643
644 _Pragma( "loopbound min 11 max 11" )
645 for ( i = 0; i < 11; i++ ) {
646 adpcm_dec_accumc[i] = 0;
647 adpcm_dec_accumd[i] = 0;
648 }
649
650 return;
651}
652
653void adpcm_dec_init()
654{
655 int i, j, f;
656 volatile int x = 0;
657 /* read in amplitude and frequency for test data */
658 j = 10;
659 f = 2000;
660
661 /* reset, initialize required memory */
662 adpcm_dec_reset();
663
664 /* 16 KHz sample rate */
665 /* XXmain_0, MAX: 2 */
666 /* Since the number of times we loop in adpcm_dec_sin depends on the
667 argument we add the fact: xxmain_0:[]: */
668 _Pragma( "loopbound min 3 max 3" )
669 for ( i = 0 ; i < SIZE ; i++ ) {
670 adpcm_dec_test_data[i] = ( int ) j * adpcm_dec_cos( f * PI * i );
671
672 /* avoid constant-propagation optimizations */
673 adpcm_dec_test_data[i] += x;
674 }
675}
676
677int adpcm_dec_return()
678{
679 int i;
680 int check_sum = 0;
681
682 for (i = 0; i < IN_END; i += 2)
683 {
684 check_sum += ( adpcm_dec_result[i] + adpcm_dec_result[i + 1] );
685 }
686
687 return check_sum != -2;
688}
689
690/*
691 Main functions
692*/
693
694void _Pragma( "entrypoint" ) adpcm_dec_main( void )
695{
696 int i;
697
698 _Pragma( "loopbound min 2 max 2" )
699 for ( i = 0 ; i < IN_END ; i += 2 ) {
700 adpcm_dec_decode( adpcm_dec_compressed[i / 2] );
701 adpcm_dec_result[i] = adpcm_dec_xout1;
702 adpcm_dec_result[i + 1] = adpcm_dec_xout2;
703 }
704
705}
706
707
708int main(int argc, char **argv)
709{
710 SET_UP
711 for (jobsComplete=-1; jobsComplete<maxJobs; jobsComplete++){
712 START_LOOP
713 adpcm_dec_init();
714 adpcm_dec_main();
715 STOP_LOOP
716}
717WRITE_TO_FILE
718 return ( adpcm_dec_return() );
719}
diff --git a/baseline/source/adpcm_dec/timedTest.txt b/baseline/source/adpcm_dec/timedTest.txt
new file mode 100644
index 0000000..82c0948
--- /dev/null
+++ b/baseline/source/adpcm_dec/timedTest.txt
@@ -0,0 +1,100 @@
1adpcm_dec none 7 none 100 123133 timedTest 0 (null)
2adpcm_dec none 7 none 100 123203 timedTest 1 (null)
3adpcm_dec none 7 none 100 123482 timedTest 2 (null)
4adpcm_dec none 7 none 100 138289 timedTest 3 (null)
5adpcm_dec none 7 none 100 123272 timedTest 4 (null)
6adpcm_dec none 7 none 100 122924 timedTest 5 (null)
7adpcm_dec none 7 none 100 123064 timedTest 6 (null)
8adpcm_dec none 7 none 100 123343 timedTest 7 (null)
9adpcm_dec none 7 none 100 123553 timedTest 8 (null)
10adpcm_dec none 7 none 100 123483 timedTest 9 (null)
11adpcm_dec none 7 none 100 123692 timedTest 10 (null)
12adpcm_dec none 7 none 100 123762 timedTest 11 (null)
13adpcm_dec none 7 none 100 123622 timedTest 12 (null)
14adpcm_dec none 7 none 100 138569 timedTest 13 (null)
15adpcm_dec none 7 none 100 123831 timedTest 14 (null)
16adpcm_dec none 7 none 100 123343 timedTest 15 (null)
17adpcm_dec none 7 none 100 123552 timedTest 16 (null)
18adpcm_dec none 7 none 100 123622 timedTest 17 (null)
19adpcm_dec none 7 none 100 123761 timedTest 18 (null)
20adpcm_dec none 7 none 100 123343 timedTest 19 (null)
21adpcm_dec none 7 none 100 123692 timedTest 20 (null)
22adpcm_dec none 7 none 100 123972 timedTest 21 (null)
23adpcm_dec none 7 none 100 123762 timedTest 22 (null)
24adpcm_dec none 7 none 100 123622 timedTest 23 (null)
25adpcm_dec none 7 none 100 123482 timedTest 24 (null)
26adpcm_dec none 7 none 100 123552 timedTest 25 (null)
27adpcm_dec none 7 none 100 123832 timedTest 26 (null)
28adpcm_dec none 7 none 100 123971 timedTest 27 (null)
29adpcm_dec none 7 none 100 123692 timedTest 28 (null)
30adpcm_dec none 7 none 100 123832 timedTest 29 (null)
31adpcm_dec none 7 none 100 123762 timedTest 30 (null)
32adpcm_dec none 7 none 100 123902 timedTest 31 (null)
33adpcm_dec none 7 none 100 123692 timedTest 32 (null)
34adpcm_dec none 7 none 100 123762 timedTest 33 (null)
35adpcm_dec none 7 none 100 123762 timedTest 34 (null)
36adpcm_dec none 7 none 100 123832 timedTest 35 (null)
37adpcm_dec none 7 none 100 124041 timedTest 36 (null)
38adpcm_dec none 7 none 100 123762 timedTest 37 (null)
39adpcm_dec none 7 none 100 123553 timedTest 38 (null)
40adpcm_dec none 7 none 100 123692 timedTest 39 (null)
41adpcm_dec none 7 none 100 138709 timedTest 40 (null)
42adpcm_dec none 7 none 100 123762 timedTest 41 (null)
43adpcm_dec none 7 none 100 123971 timedTest 42 (null)
44adpcm_dec none 7 none 100 123832 timedTest 43 (null)
45adpcm_dec none 7 none 100 123622 timedTest 44 (null)
46adpcm_dec none 7 none 100 123692 timedTest 45 (null)
47adpcm_dec none 7 none 100 123692 timedTest 46 (null)
48adpcm_dec none 7 none 100 123622 timedTest 47 (null)
49adpcm_dec none 7 none 100 123971 timedTest 48 (null)
50adpcm_dec none 7 none 100 123762 timedTest 49 (null)
51adpcm_dec none 7 none 100 124042 timedTest 50 (null)
52adpcm_dec none 7 none 100 123971 timedTest 51 (null)
53adpcm_dec none 7 none 100 123482 timedTest 52 (null)
54adpcm_dec none 7 none 100 123832 timedTest 53 (null)
55adpcm_dec none 7 none 100 123692 timedTest 54 (null)
56adpcm_dec none 7 none 100 124041 timedTest 55 (null)
57adpcm_dec none 7 none 100 123902 timedTest 56 (null)
58adpcm_dec none 7 none 100 123972 timedTest 57 (null)
59adpcm_dec none 7 none 100 123901 timedTest 58 (null)
60adpcm_dec none 7 none 100 123692 timedTest 59 (null)
61adpcm_dec none 7 none 100 123553 timedTest 60 (null)
62adpcm_dec none 7 none 100 123692 timedTest 61 (null)
63adpcm_dec none 7 none 100 124041 timedTest 62 (null)
64adpcm_dec none 7 none 100 123971 timedTest 63 (null)
65adpcm_dec none 7 none 100 124251 timedTest 64 (null)
66adpcm_dec none 7 none 100 123622 timedTest 65 (null)
67adpcm_dec none 7 none 100 123972 timedTest 66 (null)
68adpcm_dec none 7 none 100 137870 timedTest 67 (null)
69adpcm_dec none 7 none 100 123622 timedTest 68 (null)
70adpcm_dec none 7 none 100 123553 timedTest 69 (null)
71adpcm_dec none 7 none 100 123901 timedTest 70 (null)
72adpcm_dec none 7 none 100 124041 timedTest 71 (null)
73adpcm_dec none 7 none 100 123483 timedTest 72 (null)
74adpcm_dec none 7 none 100 123831 timedTest 73 (null)
75adpcm_dec none 7 none 100 123971 timedTest 74 (null)
76adpcm_dec none 7 none 100 123413 timedTest 75 (null)
77adpcm_dec none 7 none 100 123622 timedTest 76 (null)
78adpcm_dec none 7 none 100 123553 timedTest 77 (null)
79adpcm_dec none 7 none 100 123692 timedTest 78 (null)
80adpcm_dec none 7 none 100 123692 timedTest 79 (null)
81adpcm_dec none 7 none 100 123832 timedTest 80 (null)
82adpcm_dec none 7 none 100 123692 timedTest 81 (null)
83adpcm_dec none 7 none 100 123692 timedTest 82 (null)
84adpcm_dec none 7 none 100 123482 timedTest 83 (null)
85adpcm_dec none 7 none 100 124251 timedTest 84 (null)
86adpcm_dec none 7 none 100 124111 timedTest 85 (null)
87adpcm_dec none 7 none 100 124041 timedTest 86 (null)
88adpcm_dec none 7 none 100 123692 timedTest 87 (null)
89adpcm_dec none 7 none 100 124111 timedTest 88 (null)
90adpcm_dec none 7 none 100 123972 timedTest 89 (null)
91adpcm_dec none 7 none 100 123832 timedTest 90 (null)
92adpcm_dec none 7 none 100 123483 timedTest 91 (null)
93adpcm_dec none 7 none 100 123483 timedTest 92 (null)
94adpcm_dec none 7 none 100 123692 timedTest 93 (null)
95adpcm_dec none 7 none 100 124390 timedTest 94 (null)
96adpcm_dec none 7 none 100 123831 timedTest 95 (null)
97adpcm_dec none 7 none 100 123762 timedTest 96 (null)
98adpcm_dec none 7 none 100 123692 timedTest 97 (null)
99adpcm_dec none 7 none 100 123692 timedTest 98 (null)
100adpcm_dec none 7 none 100 123902 timedTest 99 (null)