public static double MIN_SAMPLE_MATCH_PERCENTAGE = 0.05f; // 5% public static ArrayList GetSeqFileList(Stream fs, bool UseSeqMinimumSize, int MinimumSeqSize) { ArrayList ret = new ArrayList(); ProbableItemStruct seqEntry = new ProbableItemStruct(); long offset = 0; long seqEof = 0; uint seqLength; // build file list while ((offset = ParseFile.GetNextOffset(fs, offset, PsxSequence.ASCII_SIGNATURE_SEQ)) > -1) { seqEof = ParseFile.GetNextOffset(fs, offset, PsxSequence.END_SEQUENCE); if (seqEof > 0) { seqLength = (uint)(seqEof - offset + PsxSequence.END_SEQUENCE.Length); if ((!UseSeqMinimumSize) || ((UseSeqMinimumSize) && (seqLength >= MinimumSeqSize))) { seqEntry.offset = offset; seqEntry.length = (uint)(seqEof - offset + PsxSequence.END_SEQUENCE.Length); ret.Add(seqEntry); } } offset += 1; } return(ret); }
public static ArrayList GetSepFileList(Stream fs) { ArrayList ret = new ArrayList(); ProbableItemStruct sepEntry = new ProbableItemStruct(); long offset = 0; long sepStartingOffset = 0; int sepSeqCount; long seqEof = 0; // build file list while ((offset = ParseFile.GetNextOffset(fs, offset, PsxSequence.ASCII_SIGNATURE_SEP)) > -1) { sepStartingOffset = offset; sepSeqCount = 1; byte[] nextSepCheckBytes; seqEof = offset; while ((seqEof = ParseFile.GetNextOffset(fs, seqEof, PsxSequence.END_SEQUENCE)) > -1) { nextSepCheckBytes = ParseFile.ParseSimpleOffset(fs, (long)(seqEof + PsxSequence.END_SEQUENCE.Length), 2); Array.Reverse(nextSepCheckBytes); if (nextSepCheckBytes.Length > 0) { if (BitConverter.ToUInt16(nextSepCheckBytes, 0) == (UInt16)sepSeqCount) { sepSeqCount++; } else { sepEntry.offset = sepStartingOffset; sepEntry.length = (uint)(seqEof - sepStartingOffset + PsxSequence.END_SEQUENCE.Length); ret.Add(sepEntry); break; } } else { sepEntry.offset = sepStartingOffset; sepEntry.length = (uint)(seqEof - sepStartingOffset + PsxSequence.END_SEQUENCE.Length); ret.Add(sepEntry); break; } seqEof += 1; } offset += 1; } return(ret); }
public static ProbableItemStruct GetPotentialAdpcmItem( Stream searchStream, long offsetToCheck, ProbableItemStruct previousItem, ProbableItemStruct[][] existingItemLocations, int maximumSampleSize) { ProbableItemStruct probableAdpcmItem = new ProbableItemStruct(); byte[] adpcmRow = new byte[0x10]; // bool errorExists = false; probableAdpcmItem.Init(); adpcmRow = ParseFile.ParseSimpleOffset(searchStream, offsetToCheck, adpcmRow.Length); // check for potential sony adpcm signature if (IsPotentialAdpcm(searchStream, offsetToCheck + 0x10, MIN_ADPCM_ROW_SIZE, false)) { /* * // check if we have passed a different file type and reset previousVbOffset if we did * foreach (ProbableItemStruct[] items in existingItemLocations) * { * if (SteppedOverAnotherFile(previousItem.offset, offsetToCheck, items)) * { * errorExists = true; * break; * } * } * * // check if we have exceeded the max sample size and set error flag * // so the chunk size check doesn't apply * if (!errorExists && * (previousItem.offset != -1) && * ((offsetToCheck - previousItem.offset) > maximumSampleSize)) * { * errorExists = true; * } * * // try to preserve proper VB chunk size * if (errorExists || * (previousItem.offset == -1) || * ((offsetToCheck - previousItem.offset) % 0x10 == 0)) * { * probableAdpcmItem.offset = offsetToCheck; * } */ probableAdpcmItem.offset = offsetToCheck; } return(probableAdpcmItem); }