Check for start of frame header marking before reading complete frame marker.

This commit is contained in:
2019-03-13 19:19:05 +00:00
parent aeae73d2f3
commit 6f48e62c70
2 changed files with 23 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ContentModelStore">
<e p="$APPLICATION_CONFIG_DIR$/consoles/db" t="IncludeRecursive" />
<e p="$APPLICATION_CONFIG_DIR$/extensions" t="IncludeRecursive" />
<e p="$USER_HOME$/.Rider2018.3/system/extResources" t="IncludeRecursive" />
<e p="$USER_HOME$/.Rider2018.3/system/resharper-host/local/Transient/ReSharperHost/v183/SolutionCaches/_DiscImageChef.VideoNow.-333220507.00" t="ExcludeRecursive" />

View File

@@ -48,6 +48,16 @@ namespace DiscImageChef.VideoNow
static string assemblyTitle;
static AssemblyInformationalVersionAttribute assemblyVersion;
static readonly byte[] FrameStart =
{
0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81
};
static readonly byte[] SwappedFrameStart =
{
0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3
};
/// <summary>
/// This is some kind of header. Every 10 bytes there's an audio byte. Here it is without reordering from little
/// endian, so the first appearence is at 9th byte.
@@ -161,9 +171,21 @@ namespace DiscImageChef.VideoNow
byte[] buffer = new byte[FrameMarker.Length];
byte[] swappedBuffer = new byte[FrameMarker.Length];
bool swapped = false;
byte[] startBuffer = new byte[FrameStart.Length];
while(framePosition < 19600)
{
fs.Position = framePosition;
fs.Read(startBuffer, 0, startBuffer.Length);
if(!startBuffer.SequenceEqual(FrameStart) &&
!startBuffer.SequenceEqual(SwappedFrameStart))
{
framePosition++;
continue;
}
fs.Position = framePosition;
fs.Read(buffer, 0, buffer.Length);