FSO.Files.XA.XAFile.DecompressMono C# (CSharp) Method

DecompressMono() private method

Decompresses a mono sample.
private DecompressMono ( byte InputBuffer ) : void
InputBuffer byte The data containing the mono sample.
return void
        private void DecompressMono(byte[] InputBuffer)
        {
            byte bInput = InputBuffer[0];
            uint i;
            int c1 = (int)EATable[HINIBBLE(bInput)];	// predictor coeffs
            int c2 = (int)EATable[HINIBBLE(bInput) + 4];
            int left, c1left, c2left;
            byte d, dleft;

            d = (byte)(LONIBBLE(bInput) + 8);  // shift value
            c1left = (int)EATable[HINIBBLE(bInput)];   // predictor coeffs for left channel
            c2left = (int)EATable[HINIBBLE(bInput) + 4];
            dleft = (byte)(LONIBBLE(bInput) + 8);   // shift value for left channel

            for (i = 1; i < 0xF; i++)
            {
                left = HINIBBLE(InputBuffer[i]);  // HIGHER nibble for left channel
                left = (left << 0x1c) >> dleft;
                left = (left + m_CurSampleLeft * c1left + m_PrevSampleLeft * c2left + 0x80) >> 8;
                left = Clip16BitSample(left);
                m_PrevSampleLeft = m_CurSampleLeft;
                m_CurSampleLeft = left;

                // Now we've got lCurSampleLeft which is one mono sample and all is set
                // for the next input nibble...
                //Output((SHORT)lCurSampleLeft); // send the sample to output
                m_Writer.Write((short)m_CurSampleLeft);

                left = LONIBBLE(InputBuffer[i]);  // LOWER nibble for left channel
                left = (left << 0x1c) >> dleft;
                left = (left + m_CurSampleLeft * c1left + m_PrevSampleLeft * c2left + 0x80) >> 8;
                left = Clip16BitSample(left);
                m_PrevSampleLeft = m_CurSampleLeft;
                m_CurSampleLeft = left;

                // Now we've got lCurSampleLeft which is one mono sample and all is set
                // for the next input byte...
                //Output((SHORT)lCurSampleLeft); // send the sample to output
                m_Writer.Write((short)m_CurSampleLeft);
            }
        }