public override void load(Stream stream) { aBinaryReader reader = new aBinaryReader(stream, Endianness.Big); mFormat = (gxTextureFormat)reader.Read8(); // 0000 mTransparency = reader.Read8(); // 0001 mWidth = reader.Read16(); // 0002 mHeight = reader.Read16(); // 0004 mWrapS = (gxWrapMode)reader.Read8(); // 0006 mWrapT = (gxWrapMode)reader.Read8(); // 0007 reader.Step(1); // 0008 (0001) mTlutFormat = (gxTlutFormat)reader.Read8(); // 0009 int tlutentrycount = reader.Read16(); // 000A long tlutoffset = reader.Read32(); // 000C mMipMap = (reader.Read8() != 0); // 0010 mEdgeLOD = (reader.Read8() != 0); // 0011 mBiasClamp = (reader.Read8() != 0); // 0012 mMaxAniso = (gxAnisotropy)reader.Read8(); // 0013 mMinFilter = (gxTextureFilter)reader.Read8(); // 0014 mMagFilter = (gxTextureFilter)reader.Read8(); // 0015 mMinLod = reader.ReadS8(); // 0016 mMaxLod = reader.ReadS8(); // 0017 mImageCount = reader.Read8(); // 0018 (0001) mLodBias = reader.ReadS16(); // 001A long texoffset = reader.Read32(); // 001C loadImageData(reader, texoffset); if (tlutentrycount > 0) { loadPaletteData(reader, tlutentrycount, tlutoffset); } }
protected override void CalculateHistoryAdpcm2(int sample, out int last, out int penult) { last = 0; penult = 0; var frame = (sample / 16); if (frame == 0) { return; } switch (mFormat) { case WaveFormat.Pcm8: { var adpcm2 = new byte[5]; var pcm16 = new short[16]; int _last = 0, _penult = 0; mReader.Goto(0); for (var i = 0; i < frame; ++i) { for (var j = 0; j < 16; ++j) { pcm16[j] = 0; if ((i * 16 + j) < mSampleCount) { Waveform.Pcm8toPcm16(mReader.ReadS8(), out pcm16[j]); } } Waveform.Pcm16toAdpcm2(pcm16, adpcm2, ref _last, ref _penult); Waveform.Adpcm2toPcm16(adpcm2, pcm16, ref last, ref penult); } break; } case WaveFormat.Pcm16: { var adpcm2 = new byte[5]; var pcm16 = new short[16]; int _last = 0, _penult = 0; mReader.Goto(0); for (var i = 0; i < frame; ++i) { for (var j = 0; j < 16; ++j) { pcm16[j] = 0; if ((i * 16 + j) < mSampleCount) { pcm16[j] = mReader.ReadS16(); } } Waveform.Pcm16toAdpcm2(pcm16, adpcm2, ref _last, ref _penult); Waveform.Adpcm2toPcm16(adpcm2, pcm16, ref last, ref penult); } break; } case WaveFormat.Adpcm2: { var pcm16 = new short[16]; mReader.Goto(0); for (var i = 0; i < frame; ++i) { Waveform.Adpcm2toPcm16(mReader.Read8s(5), pcm16, ref last, ref penult); } break; } case WaveFormat.Adpcm4: { var adpcm2 = new byte[5]; var pcm16 = new short[16]; int last1 = 0, penult1 = 0; int last2 = 0, penult2 = 0; mReader.Goto(0); for (var i = 0; i < frame; ++i) { Waveform.Adpcm4toPcm16(mReader.Read8s(9), pcm16, ref last1, ref penult1); Waveform.Pcm16toAdpcm2(pcm16, adpcm2, ref last2, ref penult2); Waveform.Adpcm2toPcm16(adpcm2, pcm16, ref last, ref penult); } break; } } }