⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 antipredictorhigh.cpp

📁 Lossless Audio 缩解压 window
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    for (q = 13; q < NumberOfElements; q++) 
    {
        IP0 = pOutputArray[q] + ((p4 * m4) >> 9) - ((p6 * m6) >> 10);
        (pOutputArray[q] ^ p4) >= 0 ? m4++ : m4--;
        (pOutputArray[q] ^ p6) >= 0 ? m6-- : m6++;
        p4 = (2 * IP0) - IP1;
        p6 = IP0;

        pOutputArray[q] = IP0 + ((p5 * 31) >> 5);
        p5 = pOutputArray[q];

        IP1 = IP0;
    }
}

void CAntiPredictorHigh3700To3800::AntiPredict(int *pInputArray, int *pOutputArray, int NumberOfElements) 
{
    // the frame to start prediction on
    #define FIRST_ELEMENT    16

    int x = 100;
    int y = -25;

    // short frame handling
    if (NumberOfElements < 20) 
    {
        memcpy(pOutputArray, pInputArray, NumberOfElements * 4);
        return;
    }

    // make the first five samples identical in both arrays
    memcpy(pOutputArray, pInputArray, FIRST_ELEMENT * 4);
    
    // variable declares and initializations
    int bm[FIRST_ELEMENT]; memset(bm, 0, FIRST_ELEMENT * 4);
    int m2 = 64, m3 = 115, m4 = 64, m5 = 740, m6 = 0;
    int p4 = pInputArray[FIRST_ELEMENT - 1];
    int p3 = (pInputArray[FIRST_ELEMENT - 1] - pInputArray[FIRST_ELEMENT - 2]) << 1;
    int p2 = pInputArray[FIRST_ELEMENT - 1] + ((pInputArray[FIRST_ELEMENT - 3] - pInputArray[FIRST_ELEMENT - 2]) << 3);// - pInputArray[3] + pInputArray[2];
    int *op = &pOutputArray[FIRST_ELEMENT];
    int *ip = &pInputArray[FIRST_ELEMENT];
    int IPP2 = ip[-2];
    int IPP1 = ip[-1];
    int p7 = 2 * ip[-1] - ip[-2];
    int opp = op[-1];
    int Original;
    
    // undo the initial prediction stuff
    for (int q = 1; q < FIRST_ELEMENT; q++) {
        pOutputArray[q] += pOutputArray[q - 1];
    }

    // pump the primary loop
    for (;op < &pOutputArray[NumberOfElements]; op++, ip++) {

        Original = *ip - 1;
        *ip = Original - (((ip[-1] * bm[0]) + (ip[-2] * bm[1]) + (ip[-3] * bm[2]) + (ip[-4] * bm[3]) + (ip[-5] * bm[4]) + (ip[-6] * bm[5]) + (ip[-7] * bm[6]) + (ip[-8] * bm[7]) + (ip[-9] * bm[8]) + (ip[-10] * bm[9]) + (ip[-11] * bm[10]) + (ip[-12] * bm[11]) + (ip[-13] * bm[12]) + (ip[-14] * bm[13]) + (ip[-15] * bm[14]) + (ip[-16] * bm[15])) >> 8);

        if (Original > 0) 
        {
            bm[0] -= ip[-1] > 0 ? 1 : -1;
            bm[1] += ((unsigned int(ip[-2]) >> 30) & 2) - 1;
            bm[2] -= ip[-3] > 0 ? 1 : -1;
            bm[3] += ((unsigned int(ip[-4]) >> 30) & 2) - 1;
            bm[4] -= ip[-5] > 0 ? 1 : -1;
            bm[5] += ((unsigned int(ip[-6]) >> 30) & 2) - 1;
            bm[6] -= ip[-7] > 0 ? 1 : -1;
            bm[7] += ((unsigned int(ip[-8]) >> 30) & 2) - 1;
            bm[8] -= ip[-9] > 0 ? 1 : -1;
            bm[9] += ((unsigned int(ip[-10]) >> 30) & 2) - 1;
            bm[10] -= ip[-11] > 0 ? 1 : -1;
            bm[11] += ((unsigned int(ip[-12]) >> 30) & 2) - 1;
            bm[12] -= ip[-13] > 0 ? 1 : -1;
            bm[13] += ((unsigned int(ip[-14]) >> 30) & 2) - 1;
            bm[14] -= ip[-15] > 0 ? 1 : -1;
            bm[15] += ((unsigned int(ip[-16]) >> 30) & 2) - 1;
        }
        else if (Original < 0) 
        {
            bm[0] -= ip[-1] <= 0 ? 1 : -1;
            bm[1] -= ((unsigned int(ip[-2]) >> 30) & 2) - 1;
            bm[2] -= ip[-3] <= 0 ? 1 : -1;
            bm[3] -= ((unsigned int(ip[-4]) >> 30) & 2) - 1;
            bm[4] -= ip[-5] <= 0 ? 1 : -1;
            bm[5] -= ((unsigned int(ip[-6]) >> 30) & 2) - 1;
            bm[6] -= ip[-7] <= 0 ? 1 : -1;
            bm[7] -= ((unsigned int(ip[-8]) >> 30) & 2) - 1;
            bm[8] -= ip[-9] <= 0 ? 1 : -1;
            bm[9] -= ((unsigned int(ip[-10]) >> 30) & 2) - 1;
            bm[10] -= ip[-11] <= 0 ? 1 : -1;
            bm[11] -= ((unsigned int(ip[-12]) >> 30) & 2) - 1;
            bm[12] -= ip[-13] <= 0 ? 1 : -1;
            bm[13] -= ((unsigned int(ip[-14]) >> 30) & 2) - 1;
            bm[14] -= ip[-15] <= 0 ? 1 : -1;
            bm[15] -= ((unsigned int(ip[-16]) >> 30) & 2) - 1;
        }

        /////////////////////////////////////////////
        *op = *ip + (((p2 * m2) + (p3 * m3) + (p4 * m4)) >> 11);

        if (*ip > 0) 
        {
            m2 -= p2 > 0 ? -1 : 1;
            m3 -= p3 > 0 ? -4 : 4;
            m4 -= p4 > 0 ? -4 : 4;
        }
        else if (*ip < 0)
        {
            m2 -= p2 > 0 ? 1 : -1;
            m3 -= p3 > 0 ? 4 : -4;
            m4 -= p4 > 0 ? 4 : -4;
        }

        p4 = *op;
        p2 = p4 + ((IPP2 - IPP1) << 3);
        p3 = (p4 - IPP1) << 1;

        IPP2 = IPP1;
        IPP1 = p4;

        /////////////////////////////////////////////
        *op += (((p7 * m5) - (opp * m6)) >> 10);
        
        (IPP1 ^ p7) >= 0 ? m5+=2 : m5-=2;
        (IPP1 ^ opp) >= 0 ? m6-- : m6++;
  
        p7 = 2 * *op - opp;
        opp = *op;

        /////////////////////////////////////////////
        *op += ((op[-1] * 31) >> 5);
    }
}

void CAntiPredictorHigh3800ToCurrent::AntiPredict(int *pInputArray, int *pOutputArray, int NumberOfElements) 
{
    // the frame to start prediction on
    #define FIRST_ELEMENT    16

    // short frame handling
    if (NumberOfElements < 20) 
    {
        memcpy(pOutputArray, pInputArray, NumberOfElements * 4);
        return;
    }

    // make the first five samples identical in both arrays
    memcpy(pOutputArray, pInputArray, FIRST_ELEMENT * 4);
    
    // variable declares and initializations
    int bm[FIRST_ELEMENT]; memset(bm, 0, FIRST_ELEMENT * 4);
    int m2 = 64, m3 = 115, m4 = 64, m5 = 740, m6 = 0;
    int p4 = pInputArray[FIRST_ELEMENT - 1];
    int p3 = (pInputArray[FIRST_ELEMENT - 1] - pInputArray[FIRST_ELEMENT - 2]) << 1;
    int p2 = pInputArray[FIRST_ELEMENT - 1] + ((pInputArray[FIRST_ELEMENT - 3] - pInputArray[FIRST_ELEMENT - 2]) << 3);// - pInputArray[3] + pInputArray[2];
    int *op = &pOutputArray[FIRST_ELEMENT];
    int *ip = &pInputArray[FIRST_ELEMENT];
    int IPP2 = ip[-2];
    int IPP1 = ip[-1];
    int p7 = 2 * ip[-1] - ip[-2];
    int opp = op[-1];
    
    // undo the initial prediction stuff
    for (int q = 1; q < FIRST_ELEMENT; q++) 
    {
        pOutputArray[q] += pOutputArray[q - 1];
    }

    // pump the primary loop
    for (;op < &pOutputArray[NumberOfElements]; op++, ip++) 
    {

        unsigned int *pip = (unsigned int *) &ip[-FIRST_ELEMENT];
        int *pbm = &bm[0];
        int nDotProduct = 0;
        
        if (*ip > 0) 
        {
            EXPAND_16_TIMES(nDotProduct += *pip * *pbm; *pbm++ += ((*pip++ >> 30) & 2) - 1;)
        }
        else if (*ip < 0) 
        {
            EXPAND_16_TIMES(nDotProduct += *pip * *pbm; *pbm++ -= ((*pip++ >> 30) & 2) - 1;)
        }
        else
        {
            EXPAND_16_TIMES(nDotProduct += *pip++ * *pbm++;)
        }

        *ip -= (nDotProduct >> 9);

        /////////////////////////////////////////////
        *op = *ip + (((p2 * m2) + (p3 * m3) + (p4 * m4)) >> 11);

        if (*ip > 0) 
        {
            m2 -= ((p2 >> 30) & 2) - 1;
            m3 -= ((p3 >> 28) & 8) - 4;
            m4 -= ((p4 >> 28) & 8) - 4;

        }
        else if (*ip < 0) 
        {
            m2 += ((p2 >> 30) & 2) - 1;
            m3 += ((p3 >> 28) & 8) - 4;
            m4 += ((p4 >> 28) & 8) - 4;
        }

        
        p2 = *op + ((IPP2 - p4) << 3);
        p3 = (*op - p4) << 1;
        IPP2 = p4;
        p4 = *op;
        
        /////////////////////////////////////////////
        *op += (((p7 * m5) - (opp * m6)) >> 10);

        if (p4 > 0) 
        {
            m5 -= ((p7 >> 29) & 4) - 2;
            m6 += ((opp >> 30) & 2) - 1;
        }
        else if (p4 < 0) 
        {
            m5 += ((p7 >> 29) & 4) - 2;
            m6 -= ((opp >> 30) & 2) - 1;
        }
  
        p7 = 2 * *op - opp;
        opp = *op;

        /////////////////////////////////////////////
        *op += ((op[-1] * 31) >> 5);
    }

    #undef FIRST_ELEMENT
}

#endif // #ifdef ENABLE_COMPRESSION_MODE_HIGH

#endif // #ifdef BACKWARDS_COMPATIBILITY

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -