public unsafe FlacSubFrameLPC(FlacBitReader reader, FlacFrameHeader header, FlacSubFrameData data, int bps, int order) : base(header) { //warmup _warmup = new int[FlacConstant.MaxLpcOrder]; for (int i = 0; i < order; i++) { _warmup[i] = data.ResidualBuffer[i] = reader.ReadBitsSigned(bps); } //header int u32 = (int)reader.ReadBits(FlacConstant.SubframeLpcQlpCoeffPrecisionLen); if (u32 == (1 << FlacConstant.SubframeLpcQlpCoeffPrecisionLen) - 1) { Debug.WriteLine("Invalid FlacLPC qlp coeff precision."); return; //return false; } _qlpCoeffPrecision = u32 + 1; int level = reader.ReadBitsSigned(FlacConstant.SubframeLpcQlpShiftLen); if (level < 0) throw new Exception("negative shift"); _lpcShiftNeeded = level; _qlpCoeffs = new int[FlacConstant.MaxLpcOrder]; //qlp coeffs for (int i = 0; i < order; i++) { _qlpCoeffs[i] = reader.ReadBitsSigned(_qlpCoeffPrecision); } Residual = new FlacResidual(reader, header, data, order); for (int i = 0; i < order; i++) { data.DestBuffer[i] = data.ResidualBuffer[i]; } int i1 = order; int result = 0; while ((i1 >>= 1) != 0) { result++; } if (bps + _qlpCoeffPrecision + result <= 32) { if (bps <= 16 && _qlpCoeffPrecision <= 16) RestoreLPCSignal(data.ResidualBuffer + order, data.DestBuffer + order, header.BlockSize - order, order); //Restore(data.residualBuffer + order, data.destBuffer, Header.BlockSize - order, order, order); else RestoreLPCSignal(data.ResidualBuffer + order, data.DestBuffer + order, header.BlockSize - order, order); } else { RestoreLPCSignalWide(data.ResidualBuffer + order, data.DestBuffer + order, header.BlockSize - order, order);//RestoreWide(data.residualBuffer + order, data.destBuffer, Header.BlockSize - order, order, order); } }
public unsafe FlacSubFrameFixed(FlacBitReader reader, FlacFrameHeader header, FlacSubFrameData data, int bps, int order) : base(header) { for (int i = 0; i < order; i++) { data.ResidualBuffer[i] = data.DestBuffer[i] = reader.ReadBitsSigned(bps); } Residual = new FlacResidual(reader, header, data, order); //necessary for decoding RestoreSignal(data, header.BlockSize - order, order); }
public unsafe FlacSubFrameFixed(FlacBitReader reader, FlacFrameHeader header, FlacSubFrameData data, int bps, int order) : base(header) { for (int i = 0; i < order; i++) { data.ResidualBuffer[i] = data.DestBuffer[i] = reader.ReadBitsSigned(bps); } Residual = new FlacResidual(reader, header, data, order); //necessary for decoding RestoreSignal(data, header.BlockSize - order, order); }
public unsafe FlacSubFrameLPC(FlacBitReader reader, FlacFrameHeader header, FlacSubFrameData data, int bps, int order) : base(header) { //warmup _warmup = new int[FlacConstant.MaxLpcOrder]; for (int i = 0; i < order; i++) { _warmup[i] = data.ResidualBuffer[i] = reader.ReadBitsSigned(bps); } //header int u32 = (int)reader.ReadBits(FlacConstant.SubframeLpcQlpCoeffPrecisionLen); if (u32 == (1 << FlacConstant.SubframeLpcQlpCoeffPrecisionLen) - 1) { Debug.WriteLine("Invalid FlacLPC qlp coeff precision."); return; //return false; } _qlpCoeffPrecision = u32 + 1; int level = reader.ReadBitsSigned(FlacConstant.SubframeLpcQlpShiftLen); if (level < 0) { throw new Exception("negative shift"); } _lpcShiftNeeded = level; _qlpCoeffs = new int[FlacConstant.MaxLpcOrder]; //qlp coeffs for (int i = 0; i < order; i++) { _qlpCoeffs[i] = reader.ReadBitsSigned(_qlpCoeffPrecision); } Residual = new FlacResidual(reader, header, data, order); for (int i = 0; i < order; i++) { data.DestBuffer[i] = data.ResidualBuffer[i]; } int i1 = order; int result = 0; while ((i1 >>= 1) != 0) { result++; } if (bps + _qlpCoeffPrecision + result <= 32) { if (bps <= 16 && _qlpCoeffPrecision <= 16) { RestoreLPCSignal(data.ResidualBuffer + order, data.DestBuffer + order, header.BlockSize - order, order); //Restore(data.residualBuffer + order, data.destBuffer, Header.BlockSize - order, order, order); } else { RestoreLPCSignal(data.ResidualBuffer + order, data.DestBuffer + order, header.BlockSize - order, order); } } else { RestoreLPCSignalWide(data.ResidualBuffer + order, data.DestBuffer + order, header.BlockSize - order, order);//RestoreWide(data.residualBuffer + order, data.destBuffer, Header.BlockSize - order, order, order); } }