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