示例#1
0
        public static EriSinCos[] CreateRevolveParameter(int nDegreeDCT)
        {
            int nDegreeNum = 1 << nDegreeDCT;
            int lc         = 1;

            for (int n = nDegreeNum / 2; n >= 8; n /= 8)
            {
                ++lc;
            }
            EriSinCos[] ptrRevolve = new EriSinCos[lc * 8];

            double k          = Math.PI / (nDegreeNum * 2);
            int    ptrNextRev = 0;
            int    nStep      = 2;

            do
            {
                for (int i = 0; i < 7; i++)
                {
                    double ws = 1.0;
                    double a  = 0.0;
                    for (int j = 0; j < i; j++)
                    {
                        a += nStep;
                        ws = ws * ptrRevolve[ptrNextRev + j].rSin + ptrRevolve[ptrNextRev + j].rCos * Math.Cos(a * k);
                    }
                    double r = Math.Atan2(ws, Math.Cos((a + nStep) * k));
                    ptrRevolve[ptrNextRev + i].rSin = (float)Math.Sin(r);
                    ptrRevolve[ptrNextRev + i].rCos = (float)Math.Cos(r);
                }
                ptrNextRev += 7;
                nStep      *= 8;
            }while (nStep < nDegreeNum);
            return(ptrRevolve);
        }
示例#2
0
 public static void OddGivensInverseMatrix(float[] ptrSrc, int src, EriSinCos[] ptrRevolve, int nDegreeDCT)
 {
     int nDegreeNum = 1 << nDegreeDCT;
     int index = 1;
     int nStep = 2;
     int lc = (nDegreeNum / 2) / 8;
     int resolve_idx = 0;
     for (;;)
     {
         resolve_idx += 7;
         index += nStep * 7;
         nStep *= 8;
         if (lc <= 8)
             break;
         lc /= 8;
     }
     int k = index + nStep * (lc - 2);
     int j;
     float r1, r2;
     for (j = lc - 2; j >= 0; j--)
     {
         r1 = ptrSrc[src + k];
         r2 = ptrSrc[src + k + nStep];
         ptrSrc[src + k] = r1 * ptrRevolve[resolve_idx+j].rCos + r2 * ptrRevolve[resolve_idx+j].rSin;
         ptrSrc[src + k + nStep] = r2 * ptrRevolve[resolve_idx+j].rCos - r1 * ptrRevolve[resolve_idx+j].rSin;
         k -= nStep;
     }
     for (; lc <= (nDegreeNum / 2) / 8; lc *= 8)
     {
         resolve_idx -= 7;
         nStep /= 8;
         index -= nStep * 7;
         for (int i = 0; i < lc; i++)
         {
             k = i * (nStep * 8) + index + nStep * 6;
             for ( j = 6; j >= 0; j -- )
             {
                 r1 = ptrSrc[src + k];
                 r2 = ptrSrc[src + k + nStep];
                 ptrSrc[src + k]         =
                     r1 * ptrRevolve[resolve_idx+j].rCos + r2 * ptrRevolve[resolve_idx+j].rSin;
                 ptrSrc[src + k + nStep] =
                     r2 * ptrRevolve[resolve_idx+j].rCos - r1 * ptrRevolve[resolve_idx+j].rSin;
                 k -= nStep;
             }
         }
     }
 }
示例#3
0
        public static EriSinCos[] CreateRevolveParameter(int nDegreeDCT)
        {
            int nDegreeNum = 1 << nDegreeDCT;
            int lc = 1;
            for (int n = nDegreeNum / 2; n >= 8; n /= 8)
            {
                ++lc;
            }
            EriSinCos[] ptrRevolve = new EriSinCos[lc*8];

            double k = Math.PI / (nDegreeNum * 2);
            int ptrNextRev = 0;
            int nStep = 2;
            do
            {
                for (int i = 0; i < 7; i++)
                {
                    double ws = 1.0;
                    double a = 0.0;
                    for (int j = 0; j < i; j++)
                    {
                        a += nStep;
                        ws = ws * ptrRevolve[ptrNextRev+j].rSin + ptrRevolve[ptrNextRev+j].rCos * Math.Cos (a * k);
                    }
                    double r = Math.Atan2 (ws, Math.Cos ((a + nStep) * k));
                    ptrRevolve[ptrNextRev+i].rSin = (float)Math.Sin (r);
                    ptrRevolve[ptrNextRev+i].rCos = (float)Math.Cos (r);
                }
                ptrNextRev += 7;
                nStep *= 8;
            }
            while (nStep < nDegreeNum);
            return ptrRevolve;
        }