public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID (" KPV") if (fileReader.Read_32bitsBE(offset) != 0x58564147) { return(0); } uint channel_count = fileReader.Read_32bitsBE(offset + 0x28); uint sample_rate = fileReader.Read_32bitsBE(offset + 0x3C); if (!VGM_Utils.CheckChannels(channel_count)) { return(0); } if (!VGM_Utils.CheckSampleRate(sample_rate)) { return(0); } uint fileLength = fileReader.Read_32bitsBE(offset + 0x04) + fileReader.Read_32bitsBE(offset + 0x40); return(fileLength); }
public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index) { UInt64 offset = file.FileStartOffset; if (System.IO.Path.GetExtension(file.Filename).ToUpper() != ".PSP") { return(null); } if ((fileReader.Read_32bitsBE(offset) != 0x01000010) && (fileReader.Read_32bitsBE(offset) != 0x434C5500)) { return(null); } FST tmpFST = new FST(); uint fileCount = (uint)fileReader.Read_32bits(offset + 0x0C); uint bufferSize = (uint)fileReader.Read_32bits(offset + 0x08); byte[] buffer = fileReader.Read(offset + 0x20, bufferSize); for (uint i = 0; i < fileCount; i++) { uint fileOffset = MemoryReader.ReadLong(ref buffer, (i * 0x10) + 0x08); uint fileSize = MemoryReader.ReadLong(ref buffer, (i * 0x10) + 0x04); tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, string.Empty, file.FileOwner, file.FilePath, offset + fileOffset, fileSize, tmpFST.EmptyDateTime, false)); } return(tmpFST); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("RIFF") if (fileReader.Read_32bitsBE(offset) != 0x52494646) { return(0); } if (!((fileReader.Read_32bits(offset + 0x20) % 0x40) == 0)) { return(0); } // Check for Mark ID ("WAVE" + "fmt ") if ((fileReader.Read_32bitsBE(offset + 0x08) == 0x57415645) && (fileReader.Read_32bitsBE(offset + 0x0C) == 0x666D7420)) { if ((fileReader.Read_16bits(offset + 0x14) == 0xFFFE) || (fileReader.Read_16bits(offset + 0x14) == 0xFFFC)) { if (VGM_Utils.CheckSampleRate(fileReader.Read_16bits(offset + 0x18))) { length = fileReader.Read_32bits(offset + 0x04) + 0x8; return(length); } } } return(0); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("SShd") if (fileReader.Read_32bitsBE(offset) != 0x53536864) { return(0); } // Check for Mark ID ("SSbd") if (fileReader.Read_32bitsBE(offset + 0x20) != 0x53536264) { return(0); } uint channel_count = fileReader.Read_32bits(offset + 0x10); uint sample_rate = fileReader.Read_32bits(offset + 0x0c); if (!VGM_Utils.CheckChannels(channel_count)) { return(0); } if (!VGM_Utils.CheckSampleRate(sample_rate)) { return(0); } uint fileLength = fileReader.Read_32bits(offset + 0x024); return(fileLength + 0x28); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { UInt64 nextOffset = 0; UInt64 endOffset = offset + length; // Check for Mark ID ("CAF ") if (fileReader.Read_32bitsBE(offset) != 0x43414620) { return(0); } uint blockCount = fileReader.Read_32bitsBE(offset + 0x24) - 1; for (int i = 0; i < blockCount; i++) { nextOffset = fileReader.Read_32bitsBE(offset + 0x4); if (fileReader.Read_32bitsBE(offset) != 0x43414620) { return(0); } if (fileReader.Read_32bitsBE(offset + 0x08) != i) { return(0); } offset += nextOffset; } return(length); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("RIFF") if (fileReader.Read_32bitsBE(offset) != 0x52494646) { return(0); } // Check for Mark ID ("WAVEfmt ") if ((fileReader.Read_32bitsBE(offset + 8) != 0x57415645) && (fileReader.Read_32bitsBE(offset + 10) != 0x666D7420)) { return(0); } // Check for RIFF Wave ID (0x5050) if (fileReader.Read_16bitsBE(offset + 0x14) != 0x5050) { return(0); } uint file_length = fileReader.Read_32bits(offset + 0x4) + 8; return(file_length); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { if (fileReader.Read_32bitsBE(offset + 0) != 0x5253544D) /* "RSTM" */ { return(0); } if ((fileReader.Read_32bitsBE(offset + 0x04) != 0xFEFF0100) && (fileReader.Read_32bitsBE(offset + 0x04) != 0xFEFF0001)) { return(0); } /* get head offset, check */ UInt64 head_offset = fileReader.Read_16bitsBE(offset + 0x0C); if (head_offset == 0x10) { m_Description = "Nintendo RSTM Header v1"; } else { m_Description = "Nintendo RSTM Header v2"; } UInt64 rl_head_offset = head_offset + offset; if (fileReader.Read_32bitsBE(head_offset + offset) != 0x48454144) /* "HEAD" */ { return(0); } /* check type details */ byte codec_number = fileReader.Read_8Bits((head_offset == 0x10) ? rl_head_offset + 0x8 : rl_head_offset + 0x20); bool loop_flag = (fileReader.Read_8Bits((head_offset == 0x10) ? rl_head_offset + 0x19 : rl_head_offset + 0x21) != 0); uint channel_count = fileReader.Read_8Bits((head_offset == 0x10) ? rl_head_offset + 0xa : rl_head_offset + 0x22); uint sample_rate = fileReader.Read_16bitsBE((head_offset == 0x10) ? rl_head_offset + 0xc : rl_head_offset + 0x24); if (!VGM_Utils.CheckChannels(channel_count)) { return(0); } if (!VGM_Utils.CheckSampleRate(sample_rate)) { return(0); } if (codec_number > 2) { return(0); } return(fileReader.Read_32bitsBE(offset + 0x08)); }
public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index) { FST tmpFST = new FST(); UInt64 offset = file.FileStartOffset; uint offsetBuffer = 0; bool bigEndian = true; // check for BIGF marker if (fileReader.Read_32bitsBE(offset) != 0x42494746) { return(null); } if (fileReader.Read_32bitsBE(offset + 4) == file.FileSize) { bigEndian = false; } uint fileCount, filenameSize, fileOffset, fileSize; if (bigEndian) { fileCount = (uint)fileReader.Read_32bits(offset + 0x08); filenameSize = fileReader.Read_32bits(offset + 0x0C) - 0x10; } else { fileCount = (uint)fileReader.Read_32bitsBE(offset + 0x08); filenameSize = fileReader.Read_32bitsBE(offset + 0x0C) - 0x10; } byte[] buffer = fileReader.Read(offset + 0x10, filenameSize); for (uint i = 0; i < fileCount; i++) { if (bigEndian) { fileOffset = MemoryReader.ReadLong(ref buffer, offsetBuffer); fileSize = MemoryReader.ReadLong(ref buffer, offsetBuffer + 4); } else { fileOffset = MemoryReader.ReadLongBE(ref buffer, offsetBuffer); fileSize = MemoryReader.ReadLongBE(ref buffer, offsetBuffer + 4); } string filename = string.Empty; filename = MemoryReader.GetString(ref buffer, offsetBuffer + 8); offsetBuffer += (uint)(8 + 1 + filename.Length); tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, filename, file.FileOwner, file.FilePath, offset + fileOffset, fileSize, tmpFST.EmptyDateTime, false)); } return(tmpFST); }
public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index) { if (System.IO.Path.GetExtension(file.Filename).ToUpper() != ".AWB") { return(null); } byte[] filenameBuffer = null; FST tmpFST = new FST(); UInt64 offset = file.FileStartOffset; UInt64 readOffset = offset; // check for AFS2 marker if (!((fileReader.Read_32bitsBE(readOffset) == 0x41465332) && (fileReader.Read_32bitsBE(readOffset + 0x04) == 0x01040200))) { return(null); } uint fileCount = (uint)fileReader.Read_32bits(readOffset + 0x08); readOffset += 0x10; readOffset += fileCount * 2; uint fileOffset = (uint)fileReader.Read_32bits(readOffset); readOffset += 4; byte[] buffer = fileReader.Read(readOffset, (fileCount * 4)); for (uint i = 0; i < fileCount; i++) { uint nextOffset = MemoryReader.ReadLong(ref buffer, (i * 8)); uint fileSize; uint padding = (fileOffset / 0x10) * 0x10; padding -= fileOffset; padding += 0x10; fileOffset += padding; fileSize = nextOffset; fileSize -= fileOffset; string filename = string.Empty; tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, filename, file.FileOwner, file.FilePath, offset + fileOffset, fileSize, tmpFST.EmptyDateTime, false)); fileOffset = nextOffset; } return(tmpFST); }
public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index) { FST tmpFST = new FST(); UInt64 offset = file.FileStartOffset; // check for AFS marker if (!((fileReader.Read_32bitsBE(offset) == 0x48473200) && (fileReader.Read_32bitsBE(offset + 4) == 0x03000000) && (fileReader.Read_32bitsBE(offset + 8) == 0x02000000))) { return(null); } //string archiveName = fileReader.Read_String(offset + 0x08, 0x50); uint sizeOfEntireFile = fileReader.Read_32bits(offset + 0x0c); if ((sizeOfEntireFile == 0) || (sizeOfEntireFile > file.FileSize)) { return(null); } uint fileCount = (uint)fileReader.Read_32bits(offset + 0x20); uint offsetOfFilename = (uint)fileReader.Read_32bits(offset + 0x2C); uint offsetOfFileInfo = (uint)fileReader.Read_32bits(offset + 0x24); byte[] buffer = fileReader.Read(offset + offsetOfFileInfo, (fileCount * 0x0c)); byte[] bufferOffsetName = fileReader.Read(offset + offsetOfFilename, (fileCount * 0x04)); uint OffsetSubstract = MemoryReader.ReadLong(ref bufferOffsetName, 0); if (OffsetSubstract > sizeOfEntireFile) { return(null); } byte[] bufferFileName = fileReader.Read(offset + offsetOfFilename + (fileCount * 0x04), sizeOfEntireFile - OffsetSubstract); for (uint i = 0; i < fileCount; i++) { uint fileOffset = MemoryReader.ReadLong(ref buffer, (i * 0x0c) + 0x08); uint fileSize = MemoryReader.ReadLong(ref buffer, (i * 0x0c) + 0x04); string filename = string.Empty; uint OffsetofFilename = MemoryReader.ReadLong(ref bufferOffsetName, (i * 0x04)); filename = MemoryReader.GetString(ref bufferFileName, OffsetofFilename - OffsetSubstract, 0x255); tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, filename, file.FileOwner, file.FilePath, offset + fileOffset, fileSize, tmpFST.EmptyDateTime, false)); } return(tmpFST); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("RIFX") if (fileReader.Read_32bitsBE(offset) != 0x52494658) { return(0); } // Check for Mark ID ("WAVE" + "fmt ") if ((fileReader.Read_32bitsBE(offset + 0x08) == 0x57415645) && (fileReader.Read_32bitsBE(offset + 0x0C) == 0x666D7420)) { for (UInt64 i = 0; i < 0x100; i += 4) { if ((fileReader.Read_32bitsBE(offset + i) == 0x766F7262) || (fileReader.Read_32bitsBE(offset + i) == 0x63756520) || (fileReader.Read_32bitsBE(offset + i) == 0x4A554E4B)) { if (VGM_Utils.CheckSampleRate(fileReader.Read_32bitsBE(offset + 0x18))) { length = fileReader.Read_32bitsBE(offset + 0x04) + 0x8; return(length); } } } } return(0); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("AUS ") if (fileReader.Read_32bitsBE(offset) != 0x41555320) { return(0); } uint channel_count = fileReader.Read_32bits(offset + 0x0C); uint sample_rate = fileReader.Read_32bits(offset + 0x10); if (!VGM_Utils.CheckChannels(channel_count)) { return(0); } if (!VGM_Utils.CheckSampleRate(sample_rate)) { return(0); } uint fileLength = (fileReader.Read_32bits(offset + 0x08) * 28 / 16) * channel_count; return(fileLength + 0x28); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID (" KPV") if (fileReader.Read_32bitsBE(offset) != 0x204B5056) { return(0); } uint channel_count = fileReader.Read_32bits(offset + 0x14); uint sample_rate = fileReader.Read_32bits(offset + 0x10); if (!VGM_Utils.CheckChannels(channel_count)) { return(0); } if (!VGM_Utils.CheckSampleRate(sample_rate)) { return(0); } uint fileLength = fileReader.Read_32bits(offset + 0x04); uint interleave = fileReader.Read_32bits(offset + 0x0C) / channel_count; int blockCount = (int)(fileLength / interleave); if ((fileLength % interleave) != 0) { blockCount++; } fileLength = (uint)(blockCount * interleave * channel_count); return(fileLength + fileReader.Read_32bits(offset + 0x08)); }
public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index) { if (System.IO.Path.GetExtension(file.Filename).ToUpper() != ".XAD") { return(null); } byte[] filenameBuffer = null; FST tmpFST = new FST(); UInt64 offset = file.FileStartOffset; // check for AFS marker if ((fileReader.Read_32bitsBE(offset + 0x10) != 0x58444100) && (fileReader.Read_32bitsBE(offset + 0x14) != 0x82000000)) { return(null); } //string archiveName = fileReader.Read_String(offset + 0x08, 0x50); uint fileCount = fileReader.Read_32bits(offset + 0x04); byte[] buffer = fileReader.Read(offset + 0x08, (fileCount * 8)); UInt64 filenameOffset = fileReader.Read_32bits(offset + 0x08 + (fileCount * 8)); if (filenameOffset != 0) { uint filenameSize = fileReader.Read_32bits(offset + 0x08 + (fileCount * 8) + 4); filenameBuffer = fileReader.Read(offset + filenameOffset, filenameSize); } for (uint i = 0; i < fileCount; i++) { uint fileOffset = MemoryReader.ReadLong(ref buffer, (i * 8)); uint fileSize = MemoryReader.ReadLong(ref buffer, (i * 8) + 0x04); string filename = string.Empty; if (filenameOffset != 0) { filename = MemoryReader.GetString(ref filenameBuffer, (i * 0x30), 0x20); } tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, filename, file.FileOwner, file.FilePath, offset + fileOffset, fileSize, tmpFST.EmptyDateTime, false)); } return(tmpFST); }
public void Init(StreamReader.IReader fileReader, UInt64 offset, ref VGM_Stream vgmStream, bool InitReader, UInt64 fileLength) { UInt64 start_offset; UInt64 i; int thpVersion = fileReader.Read_8Bits(offset + 0x06); /* fill in the vital statistics */ start_offset = fileReader.Read_32bitsBE(offset + 0x28); // Get info from the first block UInt64 componentTypeOffset = offset + fileReader.Read_32bitsBE(offset + 0x20); uint numComponents = fileReader.Read_32bitsBE(componentTypeOffset); UInt64 componentDataOffset = componentTypeOffset + 0x14; componentTypeOffset += 4; for (i = 0; i < numComponents; i++) { if (fileReader.Read_8Bits(componentTypeOffset + i) == 1) // audio block { uint channel_count = fileReader.Read_32bitsBE(componentDataOffset); /* build the VGMSTREAM */ VGM_Utils.allocate_vgmStream(ref vgmStream, (int)channel_count, false); vgmStream.vgmChannelCount = (int)channel_count; vgmStream.vgmSampleRate = (int)fileReader.Read_32bitsBE(componentDataOffset + 4); vgmStream.vgmTotalSamples = (int)fileReader.Read_32bitsBE(componentDataOffset + 8); break; } else { if (thpVersion == 0x10) { componentDataOffset += 0x0c; } else { componentDataOffset += 0x08; } } } vgmStream.vgmTHPNextFrameSize = fileReader.Read_32bitsBE(offset + 0x18); vgmStream.vgmDecoder = new DSP_Decoder(); vgmStream.vgmLayout = new Blocked(); vgmStream.vgmLayoutType = VGM_Layout_Type.THP_Blocked; if (InitReader) { for (i = 0; i < 2; i++) { vgmStream.vgmChannel[i].fReader = (StreamReader.IReader)Activator.CreateInstance(fileReader.GetType());; vgmStream.vgmChannel[i].fReader.Open(fileReader.GetFilename()); vgmStream.vgmChannel[i].fReader.SetSessionID(fileReader.GetSessionID()); } BlockedFnts.THP_Block_Update(offset + start_offset, ref vgmStream); } }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("VAGx") where x can be "p","i","s" if ((fileReader.Read_32bitsBE(offset) & 0xFFFFFF00) != 0x56414700) { return(0); } uint vagLength = fileReader.Read_32bitsBE(offset + 0x0C) + 0x30; if (fileReader.Read_32bitsBE(offset + 0x24) == 0x56414778) { uint k = 0; do { k += 0x10; vagLength += 0x10; }while (fileReader.Read_16bitsBE(offset + fileReader.Read_32bitsBE(offset + 0x0C) + k) != 0x0007); } if ((length != (UInt64)(0xFFFFFFFFF)) && (vagLength != length)) { return(0); } // Check for Sample Rate if (!VGM_Utils.CheckSampleRate(fileReader.Read_32bitsBE(offset + 0x10))) { return(0); } if (!VGM_Utils.IsPS2ADPCM(fileReader, offset + 0x30, offset + vagLength)) { return(0); } // Filename is stored at offset +0x20 m_Filename = fileReader.Read_String(offset + 0x20, 0x10); return(vagLength + 0x30); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("STER") if (fileReader.Read_32bitsBE(offset) != 0x53544552) { return(0); } // 0x04 = Length of each channels in byte // 0x08 = Length of each channels in byte (in Little Endian Format) if (fileReader.Read_32bits(offset + 0x04) != fileReader.Read_32bitsBE(offset + 0x0C)) { return(0); } // Check for Sample Rate uint sampleRate = fileReader.Read_32bitsBE(offset + 0x10); if ((sampleRate < 11025) || (sampleRate > 48000)) { return(0); } // others data must be equal to 0 if ((fileReader.Read_32bits(offset + 0x14) != 0) || (fileReader.Read_32bits(offset + 0x18) != 0) || (fileReader.Read_32bits(offset + 0x1C) != 0)) { return(0); } // Try to find file Length UInt64 startOffset = 0x30; UInt64 fileLength = fileReader.Read_32bits(offset + 0x04) * 2; //if (!VGM_Utils.IsPS2ADPCM(fileReader, startOffset + offset, startOffset + offset + fileLength)) // return 0; // Filename is stored at offset +0x20 m_Filename = fileReader.Read_String(offset + 0x20, 0x10); return(fileLength + startOffset); }
public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index) { FST tmpFST = new FST(); UInt64 offset = file.FileStartOffset; // check for ARC marker if ((fileReader.Read_32bitsBE(offset) != 0x41524300)) { return(null); } //string archiveName = fileReader.Read_String(offset + 0x08, 0x50); uint fileCount = (uint)fileReader.Read_32bits(offset + 0x0C); uint offset_adding = (uint)fileReader.Read_32bits(offset + 0x18); uint offset_name = (uint)fileReader.Read_32bits(offset + 0x10); if ((offset_adding == 0) || (offset_adding > file.FileSize)) { return(null); } if ((offset_name == 0) || (offset_name > offset_adding)) { return(null); } byte[] buffer_name = fileReader.Read(offset + offset_name, offset_adding - offset_name); // long filenameOffset = fileReader.Read_32bits(offset + 0x08 + (fileCount * 8)); // if (filenameOffset != 0) //{ // uint filenameSize = fileReader.Read_32bits(offset + 0x08 + (fileCount * 8) + 4); // filenameBuffer = fileReader.Read(offset + filenameOffset, filenameSize); //} for (uint i = 0; i < fileCount; i++) { UInt64 fileOffset = MemoryReader.ReadLong(ref buffer_name, (i * 0x18)); uint fileSize = MemoryReader.ReadLong(ref buffer_name, (i * 0x18) + 0x04); string filename = string.Empty; if (fileOffset != 0) { fileOffset += offset_adding; uint filenameOffset = MemoryReader.ReadLong(ref buffer_name, (i * 0x18) + 0x10); filename = MemoryReader.GetString(ref buffer_name, (fileCount * 0x18) + filenameOffset, 0xff); tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, filename, file.FileOwner, file.FilePath, offset + fileOffset, fileSize, tmpFST.EmptyDateTime, false)); } } return(tmpFST); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("THP") if (fileReader.Read_32bitsBE(offset) != 0x54485000) { return(0); } // check if thp is correct ... //if (fileReader.Read_32bitsBE(offset + 0x1C) + 0x60 != length) // return 0; // check if thp has audio if (fileReader.Read_32bitsBE(offset + 0x0C) == 0) { return(0); } return(length); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("PSMF") if (fileReader.Read_32bitsBE(offset) != 0x50534D46) { return(0); } if ((fileReader.Read_32bitsBE(offset + 0x04) == 0x30303135) || (fileReader.Read_32bitsBE(offset + 0x04) == 0x30303132) || (fileReader.Read_32bitsBE(offset + 0x04) == 0x30303134)) { length = fileReader.Read_32bitsBE(offset + 0x0C) + 0x800; return(length); } else { return(0); } }
public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index) { FST tmpFST = new FST(); if (!((System.IO.Path.GetExtension(file.Filename).ToUpper() == ".PSARC") || (System.IO.Path.GetExtension(file.Filename).ToUpper() == ".PAC"))) { return(null); } UInt64 offset = file.FileStartOffset; while (offset <= file.FileSize) { // check for FPAC marker if (fileReader.Read_32bitsBE(offset) == 0x46504143) { uint sizeofInfo = fileReader.Read_32bits(offset + 0x04); byte[] buffer = fileReader.Read(offset, sizeofInfo); uint sizeofFile = MemoryReader.ReadLong(ref buffer, 0x08); uint fileCount = MemoryReader.ReadLong(ref buffer, 0x0c); uint offsetofIndex = MemoryReader.ReadLong(ref buffer, 0x10); uint offsetofInfo = MemoryReader.ReadLong(ref buffer, 0x14); if (fileCount != 0) { uint sizeofOneInfo = 0; sizeofOneInfo = (sizeofInfo - 0x20) / fileCount; for (uint i = 0; i < fileCount; i++) { uint fileSize = MemoryReader.ReadLong(ref buffer, (i * sizeofOneInfo) + offsetofInfo + 0x20 + 8); uint fileOffset = MemoryReader.ReadLong(ref buffer, (i * sizeofOneInfo) + offsetofInfo + 0x20 + 4) + sizeofInfo; string filename = string.Empty; filename = MemoryReader.GetString(ref buffer, (i * sizeofOneInfo) + 0x20, offsetofInfo); tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, filename, file.FileOwner, file.FilePath, offset + fileOffset, fileSize, tmpFST.EmptyDateTime, false)); } } offset += sizeofFile; } else { offset += 4; } } return(tmpFST); }
public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index) { if (System.IO.Path.GetExtension(file.Filename).ToUpper() != ".PAC") { return(null); } FST tmpFST = new FST(); UInt64 offset = file.FileStartOffset; // check for AFS marker if (!((fileReader.Read_32bitsBE(offset) == 0x44474b50) && (fileReader.Read_32bitsBE(offset + 4) == 0x00000100))) { return(null); } uint fileCount = (uint)fileReader.Read_32bits(offset + 0x0C); uint offsetStart = (uint)fileReader.Read_32bits(offset + 0x10); uint fileOffset = offsetStart; for (uint i = 0; i < fileCount; i++) { byte[] buffer = fileReader.Read(offset + fileOffset, 0x90); if (MemoryReader.ReadLongBE(ref buffer, 0) == 0x53415439) { fileOffset += 0x90; uint fileSize = MemoryReader.ReadLong(ref buffer, 0x08); string filename = string.Empty; filename = MemoryReader.GetString(ref buffer, 0x10); tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, filename, file.FileOwner, file.FilePath, offset + fileOffset, fileSize, tmpFST.EmptyDateTime, false)); } fileOffset += (uint)MemoryReader.ReadLong(ref buffer, 0x08); } return(tmpFST); }
public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index) { FST tmpFST = new FST(); UInt64 offset = file.FileStartOffset; // check for XAST marker if (!((fileReader.Read_32bitsBE(offset) == 0x58415354) && (fileReader.Read_32bitsBE(offset) != 0x00000101))) { return(null); } uint fileCount = (uint)fileReader.Read_32bits(offset + 0x0C); uint bufferSize = (uint)fileReader.Read_32bits(offset + 0x14); byte[] buffer = fileReader.Read(offset, bufferSize); uint buffer_offset = 0x30; for (uint i = 0; i < fileCount; i++) { if (MemoryReader.ReadLong(ref buffer, (i * 48) + buffer_offset) != 0xffffffff) { UInt64 fileOffset = MemoryReader.ReadLong(ref buffer, (i * 48) + buffer_offset + 0x20); uint fileSize = MemoryReader.ReadLong(ref buffer, (i * 48) + buffer_offset + 0x10); UInt64 filenameOffset = MemoryReader.ReadLong(ref buffer, (i * 48) + buffer_offset + 0x04); string filename = string.Empty; filename = MemoryReader.GetString(ref buffer, filenameOffset, 255); tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, filename, file.FileOwner, file.FilePath, offset + fileOffset, fileSize, tmpFST.EmptyDateTime, false)); } } return(tmpFST); }
public void Init(StreamReader.IReader fileReader, UInt64 offset, ref VGM_Stream vgmStream, bool InitReader, UInt64 fileLength) { bool loop_flag = false; //(fileReader.Read_32bits(offset + 0x7FC) != 0); int channel_count = (int)fileReader.Read_32bitsBE(offset + 0x28); int sample_rate = (int)fileReader.Read_32bitsBE(offset + 0x3C); /* build the VGMSTREAM */ VGM_Utils.allocate_vgmStream(ref vgmStream, channel_count, loop_flag); vgmStream.vgmLoopFlag = loop_flag; vgmStream.vgmChannelCount = channel_count; vgmStream.vgmSampleRate = sample_rate; vgmStream.vgmTotalSamples = (int)((fileReader.Read_32bitsBE(offset + 0x40) * 28 / 16) / 2); vgmStream.vgmLayout = new Interleave(); vgmStream.vgmInterleaveBlockSize = 0x10; vgmStream.vgmDecoder = new PSX_Decoder(); if (loop_flag) { vgmStream.vgmLoopStartSample = (int)fileReader.Read_32bits(offset + 0x7FC) * 28 / 16; vgmStream.vgmLoopEndSample = vgmStream.vgmTotalSamples; } UInt64 start_offset = offset + fileReader.Read_32bitsBE(offset + 0x04); if (InitReader) { for (int i = 0; i < channel_count; i++) { vgmStream.vgmChannel[i].fReader = (StreamReader.IReader)Activator.CreateInstance(fileReader.GetType());; vgmStream.vgmChannel[i].fReader.Open(fileReader.GetFilename()); vgmStream.vgmChannel[i].fReader.SetSessionID(fileReader.GetSessionID()); vgmStream.vgmChannel[i].startOffset = vgmStream.vgmChannel[i].currentOffset = (start_offset + (UInt64)(vgmStream.vgmInterleaveBlockSize * i)); } } }
public void Init(StreamReader.IReader fileReader, UInt64 offset, ref VGM_Stream vgmStream, bool InitReader, UInt64 fileLength) { int vgmNumSamples = 0; int loop_start = -1; UInt64 NextBlock; UInt64 currBlock = offset; int i; // Calculate sample length ... uint blockCount = fileReader.Read_32bitsBE(offset + 0x24); for (i = 0; i < blockCount; i++) { NextBlock = fileReader.Read_32bitsBE(currBlock + 0x04); vgmNumSamples += (int)(fileReader.Read_32bitsBE(currBlock + 0x14) / 8 * 14); if (fileReader.Read_32bitsBE(currBlock + 0x20) == fileReader.Read_32bitsBE(currBlock + 0x08)) { loop_start = (int)(vgmNumSamples - fileReader.Read_32bitsBE(currBlock + 0x14) / 8 * 14); } currBlock += NextBlock; } bool loop_flag = (loop_start != -1); /* build the VGMSTREAM */ VGM_Utils.allocate_vgmStream(ref vgmStream, 2, loop_flag); vgmStream.vgmLoopFlag = loop_flag; vgmStream.vgmChannelCount = 2; vgmStream.vgmSampleRate = 32000; vgmStream.vgmTotalSamples = vgmNumSamples; if (loop_flag) { vgmStream.vgmLoopStartSample = loop_start; vgmStream.vgmLoopEndSample = vgmNumSamples; } vgmStream.vgmDecoder = new DSP_Decoder(); vgmStream.vgmLayout = new Blocked(); vgmStream.vgmLayoutType = VGM_Layout_Type.CAF_Blocked; if (InitReader) { for (i = 0; i < 2; i++) { vgmStream.vgmChannel[i].fReader = (StreamReader.IReader)Activator.CreateInstance(fileReader.GetType());; vgmStream.vgmChannel[i].fReader.Open(fileReader.GetFilename()); vgmStream.vgmChannel[i].fReader.SetSessionID(fileReader.GetSessionID()); } BlockedFnts.CAF_Block_Update(offset + 0, ref vgmStream); } }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("Svag") if (fileReader.Read_32bitsBE(offset) != 0x53766167) { return(0); } // Check for Sample Rate if (!VGM_Utils.CheckSampleRate(fileReader.Read_32bits(offset + 0x08))) { return(0); } // Check Channels count if (!VGM_Utils.CheckChannels(fileReader.Read_32bits(offset + 0x0C))) { return(0); } // Values from 0 -> 0x1C are duplicated at offset 0x400 for (UInt64 i = 0; i < 0x1C / 4; i++) { if (fileReader.Read_32bits(offset + i) != fileReader.Read_32bits(offset + 0x400 + i)) { return(0); } } // Try to find file Length UInt64 startOffset = 0x800; UInt64 fileLength = fileReader.Read_32bits(offset + 0x04); //if (!VGM_Utils.IsPS2ADPCM(fileReader, startOffset + offset, startOffset + offset + fileLength)) // return 0; if (fileReader.Read_32bits(offset + 0x30) == 0x45434B2E) { m_Description = "Konami SVAG (KCE-Tokyo)"; } else { m_Description = "Konami SVAG (KONAMITYO)"; } return(fileLength + startOffset); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID ("NPSF") if (fileReader.Read_32bitsBE(offset) != 0x4E505346) { return(0); } uint channel_count = fileReader.Read_32bits(offset + 0x0C); uint sample_rate = fileReader.Read_32bits(offset + 0x18); if (!VGM_Utils.CheckChannels(channel_count)) { return(0); } if (!VGM_Utils.CheckSampleRate(sample_rate)) { return(0); } if (fileReader.Read_32bits(offset + 0x10) != 0x800) { return(0); } uint fileLength = fileReader.Read_32bits(offset + 0x08); m_Filename = fileReader.Read_String(offset + 0x34, 0x20); if (channel_count == 1) { return(fileLength + 0x800); } else { uint blockCount = fileLength / 0x800; if ((fileLength % 0x800) != 0) { blockCount++; } fileLength = (blockCount * channel_count * 0x800) + 0x800; } return(fileLength); }
public UInt64 IsFormat(StreamReader.IReader fileReader, UInt64 offset, UInt64 length) { // Check for Mark ID if (fileReader.Read_32bitsBE(offset) != 0x01006408) { return(0); } // Check for Start Offset Value (can't be equal to 0) if (fileReader.Read_32bits(offset + 8) == 0) { return(0); } // Check for Channels Count & Sample Rate uint sampleRate = fileReader.Read_32bits(offset + 0x18); uint channelCount = fileReader.Read_32bits(offset + 0x1C); uint interleave = fileReader.Read_32bits(offset + 0x24); if (((channelCount <= 0) || (channelCount > 2)) || ((sampleRate < 11025) || (sampleRate > 48000))) { return(0); } // Check for Interleave value if ((interleave < 0) || (interleave > 0x10000)) { return(0); } // Try to find file Length UInt64 startOffset = fileReader.Read_32bits(offset + 0x08); UInt64 fileLength = fileReader.Read_32bits(offset + 0x0C); //if (!VGM_Utils.IsPS2ADPCM(fileReader, startOffset + offset, startOffset + offset + fileLength)) // return 0; return(fileLength + startOffset); }
public void Init(StreamReader.IReader fileReader, UInt64 offset, ref VGM_Stream vgmStream, bool InitReader, UInt64 fileLength) { int i; bool loop_flag = (fileReader.Read_32bits(offset + 0x08) != 0xFFFFFFFF); int channel_count = 2; /* build the VGMSTREAM */ VGM_Utils.allocate_vgmStream(ref vgmStream, channel_count, loop_flag); /* fill in the vital statistics */ UInt64 start_offset = offset + 0x30; vgmStream.vgmChannelCount = channel_count; vgmStream.vgmSampleRate = (int)fileReader.Read_32bitsBE(offset + 0x10); vgmStream.vgmDecoder = new PSX_Decoder(); vgmStream.vgmLayout = new Interleave(); vgmStream.vgmLoopFlag = loop_flag; vgmStream.vgmTotalSamples = (int)(fileReader.Read_32bits(offset + 0x04) * 28 / 16); if (loop_flag) { vgmStream.vgmLoopStartSample = (int)(fileReader.Read_32bits(offset + 0x08) * 28 / 16 / vgmStream.vgmChannelCount); vgmStream.vgmLoopEndSample = (int)(fileReader.Read_32bits(offset + 0x04) * 28 / 16); } vgmStream.vgmInterleaveBlockSize = 0x10; if (InitReader) { for (i = 0; i < channel_count; i++) { vgmStream.vgmChannel[i].fReader = (StreamReader.IReader)Activator.CreateInstance(fileReader.GetType());; vgmStream.vgmChannel[i].fReader.Open(fileReader.GetFilename()); vgmStream.vgmChannel[i].startOffset = vgmStream.vgmChannel[i].currentOffset = start_offset + (UInt64)(vgmStream.vgmInterleaveBlockSize * i); } } }
public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index) { FST tmpFST = new FST(); UInt64 offset = file.FileStartOffset; // check for file extension ".POD" if (System.IO.Path.GetExtension(file.Filename).ToUpper() != ".POD") { return(null); } // check for POD2 marker if (fileReader.Read_32bitsBE(offset) != 0x504F4432) { return(null); } string archiveName = fileReader.Read_String(offset + 0x08, 0x50); uint fileCount = fileReader.Read_32bits(offset + 0x58); uint filenameOffset = 0x60 + (fileCount * 20); uint filenameSize = fileReader.Read_32bits(offset + 0x68) - filenameOffset; byte[] buffer = fileReader.Read(offset + 0x60, (fileCount * 20)); byte[] filenameBuffer = fileReader.Read(offset + filenameOffset, filenameSize); for (uint i = 0; i < fileCount; i++) { uint nameOffset = MemoryReader.ReadLong(ref buffer, (i * 20)); uint fileSize = MemoryReader.ReadLong(ref buffer, (i * 20) + 0x04); uint fileOffset = MemoryReader.ReadLong(ref buffer, (i * 20) + 0x08); string filename = MemoryReader.GetString(ref filenameBuffer, nameOffset); tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, filename, file.Filename, file.FilePath, offset + fileOffset, fileSize, tmpFST.EmptyDateTime, false)); } return(tmpFST); }