示例#1
0
 int[] ProcessVerbatimSubframe( FlacBitReader bitReader, int bitsPerSample, int blockSize )
 {
     int[] data = new int[blockSize];
     for( int i = 0; i < data.Length; i++ ) {
         data[i] = bitReader.ReadSignedBits( bitsPerSample );
     }
     return data;
 }
示例#2
0
 int[] ProcessFixedSubframe( FlacBitReader bitReader, int bitsPerSample, int predictorOrder, int blockSize )
 {
     int[] warmUpSamples = new int[predictorOrder];
     for( int i = 0; i < predictorOrder; i++ ) {
         warmUpSamples[i] = bitReader.ReadSignedBits( bitsPerSample );
     }
     int[] residual = ReadResidual( bitReader, predictorOrder, blockSize );
     int[] data = new int[blockSize];
     Buffer.BlockCopy( warmUpSamples, 0, data, 0, predictorOrder * sizeof( int ) );
     FixedSignalRestore( residual, blockSize - predictorOrder, predictorOrder, data );
     return data;
 }
示例#3
0
        int[] ProcessLpcSubframe( FlacBitReader bitReader, int bitsPerSample, int lpcOrder, int blockSize )
        {
            int[] warmUpSamples = new int[lpcOrder];
            for( int i = 0; i < warmUpSamples.Length; i++ ) {
                warmUpSamples[i] = bitReader.ReadSignedBits( bitsPerSample );
            }

            int lpcPrecision = bitReader.ReadBits( 4 ) + 1;
            if( lpcPrecision == 16 ) {// 1111 + 1
                throw new InvalidDataException( "Invalid lpc precision." );
            }

            int lpcShift = bitReader.ReadSignedBits( 5 );
            int[] coefficients = new int[lpcOrder];
            for( int i = 0; i < coefficients.Length; i++ ) {
                coefficients[i] = bitReader.ReadSignedBits( lpcPrecision );
            }

            int[] residual = ReadResidual( bitReader, lpcOrder, blockSize );
            int[] data = new int[lpcOrder + blockSize];
            Buffer.BlockCopy( warmUpSamples, 0, data, 0, lpcOrder * sizeof( int ) );

            if( bitsPerSample + lpcPrecision + ilog2( lpcOrder ) <= 32 ) {
                LpcRestoreSignal( residual, blockSize - lpcOrder, coefficients, lpcOrder, lpcShift, data );
            } else {
                LpcRestoreSignal64( residual, blockSize - lpcOrder, coefficients, lpcOrder, lpcShift, data );
            }
            return data;
        }
示例#4
0
 int[] ProcessConstantSubframe( FlacBitReader bitReader, int bitsPerSample, int blockSize )
 {
     int constantValue = bitReader.ReadSignedBits( bitsPerSample );
     int[] data = new int[blockSize];
     for( int i = 0; i < data.Length; i++ ) {
         data[i] = constantValue;
     }
     return data;
 }