Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include <math.h>       //sqrt
  2.  
  3. static float csa[8][2];         /* antialias */
  4.  
  5. void alias_init()
  6. {
  7.         float Ci[8] =
  8.         {
  9.                 -0.6f, -0.535f, -0.33f, -0.185f, -0.095f, -0.041f, -0.0142f, -0.0037f
  10.         };
  11.  
  12.         int i;
  13.  
  14.         for (i = 0; i < 8; i++)
  15.         {
  16.                 csa[i][0] = (float) (1.0 / sqrt(1.0 + Ci[i] * Ci[i]));
  17.                 csa[i][1] = (float) (Ci[i] / sqrt(1.0 + Ci[i] * Ci[i]));
  18.         }
  19. }
  20.  
  21. void antialias(float x[], int n)
  22. {
  23.    int i, k;
  24.    float a, b;
  25.  
  26.    for (k = 0; k < n; k++)
  27.    {
  28.       for (i = 0; i < 8; i++)
  29.       {
  30.          a = x[17 - i];
  31.          b = x[18 + i];
  32.          x[17 - i] = a * csa[i][0] - b * csa[i][1];
  33.          x[18 + i] = b * csa[i][0] + a * csa[i][1];
  34.       }
  35.       x += 18;
  36.    }
  37.  
  38. }
  39.