added some test programs
[libfirm] / ir / be / test / max.c
1 void dequant_h263_inter_c(      short * data,
2                                 const short * coeff,
3                                 const unsigned int quant)
4 {
5         const unsigned short quant_m_2 = quant << 1;
6         const unsigned short quant_add = (quant & 1 ? quant : quant - 1);
7         int i;
8
9         for (i = 0; i < 64; i++) {
10                 short acLevel = coeff[i];
11
12                 if (acLevel == 0) {
13                         data[i] = 0;
14                 } else if (acLevel < 0) {
15                         acLevel = acLevel * quant_m_2 - quant_add;
16                         data[i] = (acLevel > 2048 ? acLevel : 2048);
17                 } else {
18                         acLevel = acLevel * quant_m_2 + quant_add;
19                         data[i] = (acLevel <= 2047 ? acLevel : 2047);
20                 }
21         }
22 }
23
24 #define MAX 65536
25
26 int main(){
27   short cur[MAX];
28   short ref[MAX];
29   int numofruns = 10;
30   int i,ii;
31   for (i=0;i < numofruns; i++){
32     /* Reset cache. Alles andere ist unrealistisch. */
33     for(ii = 0; ii<MAX;ii++){
34       cur[ii]=0;
35       ref[ii]=(ii+i+3)&0xff;
36     }
37     dequant_h263_inter_c(cur, ref, 1024*(i&0x3));
38   }
39   for(ii = 0; ii<64;ii++){
40        printf("data[%i] = %i\n",ii, cur[ii]);
41   }
42   return 0 ;
43 }