diff --git a/Aaru.VideoNow/Aaru.VideoNow.csproj b/Aaru.VideoNow/Aaru.VideoNow.csproj index b2954f2..df14d60 100644 --- a/Aaru.VideoNow/Aaru.VideoNow.csproj +++ b/Aaru.VideoNow/Aaru.VideoNow.csproj @@ -10,7 +10,7 @@ - + diff --git a/Aaru.VideoNow/Color.cs b/Aaru.VideoNow/Color.cs index 836be91..db34ef5 100644 --- a/Aaru.VideoNow/Color.cs +++ b/Aaru.VideoNow/Color.cs @@ -4,92 +4,212 @@ using System.Linq; using SharpAvi; using SharpAvi.Output; -namespace Aaru.VideoNow +namespace Aaru.VideoNow; + +public static class Color { - public static class Color + /// + /// 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. + /// + public static readonly byte[] FrameMarker = + [ + 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, + 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, + 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, + 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, + 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, + 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81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C, 0x08, 0x2D, 0x0A, 0x2E, 0x0C, 0x2F, 0x0E, 0x00, 0xFF, 0x30, 0x11, 0x31, 0x13, 0x32, 0x15, + 0x33, 0x17, 0x00, 0xFF, 0x34, 0x19, 0x35, 0x1B, 0x36, 0x1D, 0x37, 0x1F, 0x00, 0xFF, 0x38, 0x00, 0x39, 0x02, + 0x3A, 0x04, 0x3B, 0x06, 0x00, 0xFF, 0x3C, 0x08, 0x3D, 0x0A, 0x3E, 0x0C, 0x3F, 0x0E, 0x00, 0xFF, 0x40, 0x11, + 0x41, 0x13, 0x42, 0x15, 0x43, 0x17, 0x00, 0xFF, 0x44, 0x19, 0x45, 0x1B, 0x46, 0x1D, 0x47, 0x1F, 0x00, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x00, 0xFF + ]; + + public static readonly byte[] SwappedFrameMarker = + [ + 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, + 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, + 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, + 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81,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, 0x00, 0x08, 0x04, + 0x0A, 0x05, 0x0C, 0x06, 0x0E, 0x07, 0xFF, 0x00, 0x11, 0x08, 0x13, 0x09, 0x15, 0x0A, 0x17, 0x0B, 0xFF, 0x00, + 0x19, 0x0C, 0x1B, 0x0D, 0x1D, 0x0E, 0x1F, 0x0F, 0xFF, 0x00, 0x00, 0x28, 0x02, 0x29, 0x04, 0x2A, 0x06, 0x2B, + 0xFF, 0x00, 0x08, 0x2C, 0x0A, 0x2D, 0x0C, 0x2E, 0x0E, 0x2F, 0xFF, 0x00, 0x11, 0x30, 0x13, 0x31, 0x15, 0x32, + 0x17, 0x33, 0xFF, 0x00, 0x19, 0x34, 0x1B, 0x35, 0x1D, 0x36, 0x1F, 0x37, 0xFF, 0x00, 0x00, 0x38, 0x02, 0x39, + 0x04, 0x3A, 0x06, 0x3B, 0xFF, 0x00, 0x08, 0x3C, 0x0A, 0x3D, 0x0C, 0x3E, 0x0E, 0x3F, 0xFF, 0x00, 0x11, 0x40, + 0x13, 0x41, 0x15, 0x42, 0x17, 0x43, 0xFF, 0x00, 0x19, 0x44, 0x1B, 0x45, 0x1D, 0x46, 0x1F, 0x47, 0xFF, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x00 + ]; + + public static void Decode(string filename, Stream fs, bool swapped, long framePosition) { - /// - /// 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. - /// - public static readonly byte[] FrameMarker = - [ - 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7,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 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, - 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, - 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, - 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0x00, 0x00, 0x01, 0x02, 0x02, 0x04, 0x03, 0x06, 0x00, 0xFF, 0x04, 0x08, - 0x05, 0x0A, 0x06, 0x0C, 0x07, 0x0E, 0x00, 0xFF, 0x08, 0x11, 0x09, 0x13, 0x0A, 0x15, 0x0B, 0x17, 0x00, 0xFF, - 0x0C, 0x19, 0x0D, 0x1B, 0x0E, 0x1D, 0x0F, 0x1F, 0x00, 0xFF, 0x28, 0x00, 0x29, 0x02, 0x2A, 0x04, 0x2B, 0x06, - 0x00, 0xFF, 0x2C, 0x08, 0x2D, 0x0A, 0x2E, 0x0C, 0x2F, 0x0E, 0x00, 0xFF, 0x30, 0x11, 0x31, 0x13, 0x32, 0x15, - 0x33, 0x17, 0x00, 0xFF, 0x34, 0x19, 0x35, 0x1B, 0x36, 0x1D, 0x37, 0x1F, 0x00, 0xFF, 0x38, 0x00, 0x39, 0x02, - 0x3A, 0x04, 0x3B, 0x06, 0x00, 0xFF, 0x3C, 0x08, 0x3D, 0x0A, 0x3E, 0x0C, 0x3F, 0x0E, 0x00, 0xFF, 0x40, 0x11, - 0x41, 0x13, 0x42, 0x15, 0x43, 0x17, 0x00, 0xFF, 0x44, 0x19, 0x45, 0x1B, 0x46, 0x1D, 0x47, 0x1F, 0x00, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x00, 0xFF - ]; + var progress = ' '; - public static readonly byte[] SwappedFrameMarker = - [ - 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, - 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, - 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, - 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, - 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, - 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, - 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, - 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, - 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, - 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, - 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, - 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, - 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, - 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x00, 0x00, 0x02, 0x01, 0x04, 0x02, 0x06, 0x03, 0xFF, 0x00, 0x08, 0x04, - 0x0A, 0x05, 0x0C, 0x06, 0x0E, 0x07, 0xFF, 0x00, 0x11, 0x08, 0x13, 0x09, 0x15, 0x0A, 0x17, 0x0B, 0xFF, 0x00, - 0x19, 0x0C, 0x1B, 0x0D, 0x1D, 0x0E, 0x1F, 0x0F, 0xFF, 0x00, 0x00, 0x28, 0x02, 0x29, 0x04, 0x2A, 0x06, 0x2B, - 0xFF, 0x00, 0x08, 0x2C, 0x0A, 0x2D, 0x0C, 0x2E, 0x0E, 0x2F, 0xFF, 0x00, 0x11, 0x30, 0x13, 0x31, 0x15, 0x32, - 0x17, 0x33, 0xFF, 0x00, 0x19, 0x34, 0x1B, 0x35, 0x1D, 0x36, 0x1F, 0x37, 0xFF, 0x00, 0x00, 0x38, 0x02, 0x39, - 0x04, 0x3A, 0x06, 0x3B, 0xFF, 0x00, 0x08, 0x3C, 0x0A, 0x3D, 0x0C, 0x3E, 0x0E, 0x3F, 0xFF, 0x00, 0x11, 0x40, - 0x13, 0x41, 0x15, 0x42, 0x17, 0x43, 0xFF, 0x00, 0x19, 0x44, 0x1B, 0x45, 0x1D, 0x46, 0x1F, 0x47, 0xFF, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x00 - ]; - - public static void Decode(string filename, Stream fs, bool swapped, long framePosition) + var aviWriter = new AviWriter(filename + ".avi") { - var progress = ' '; + EmitIndex1 = true, FramesPerSecond = 18 + }; - var aviWriter = new AviWriter(filename + ".avi") + IAviVideoStream videoStream = aviWriter.AddVideoStream(144, 80, BitsPerPixel.Bpp24); + videoStream.Codec = CodecIds.Uncompressed; + IAviAudioStream audioStream = aviWriter.AddAudioStream(2, 17640, 8); + + fs.Position = framePosition; + var frameBuffer = new byte[19600]; + fs.Read(frameBuffer, 0, frameBuffer.Length); + + int audioStart = swapped ? 9 : 8; + byte[] frameMarkerToUse = swapped ? SwappedFrameMarker : FrameMarker; + + if(!swapped) frameBuffer = Swapping.SwapBuffer(frameBuffer); + + var outFs = new MemoryStream(); + + for(var i = 9; i <= frameBuffer.Length; i += 10) + { + progress = (i / 10 % 4) switch + { + 0 => '-', + 1 => '\\', + 2 => '|', + 3 => '/', + _ => progress + }; + + Console.Write($"\r{Localization.ExtractingAudio}", progress); + outFs.WriteByte(frameBuffer[i]); + } + + byte[] videoFrame = DecodeFrame(frameBuffer); + videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); + audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); + + var totalFrames = 1; + framePosition += 19600; + var buffer = new byte[frameMarkerToUse.Length]; + + while(framePosition + 19600 < fs.Length) + { + progress = (totalFrames % 4) switch + { + 0 => '-', + 1 => '\\', + 2 => '|', + 3 => '/', + _ => progress + }; + + Console.Write($"\r{Localization.LookingForMoreFrames}", progress); + + for(int ab = audioStart; ab < buffer.Length; ab += 10) buffer[ab] = 0; + + if(!buffer.SequenceEqual(frameMarkerToUse)) { - EmitIndex1 = true, FramesPerSecond = 18 - }; + Console.Write("\r \r"); + Console.WriteLine(Localization.FrameAndNextAreNotAligned, totalFrames); + long expectedFramePosition = framePosition; - IAviVideoStream videoStream = aviWriter.AddVideoStream(144, 80, BitsPerPixel.Bpp24); - videoStream.Codec = CodecIds.Uncompressed; - IAviAudioStream audioStream = aviWriter.AddAudioStream(2, 17640, 8); + while(framePosition < fs.Length) + { + fs.Position = framePosition; + fs.Read(buffer, 0, buffer.Length); + for(int ab = audioStart; ab < buffer.Length; ab += 10) buffer[ab] = 0; + + if(buffer.SequenceEqual(frameMarkerToUse)) + { + Console.Write("\r \r"); + + fs.Position = framePosition; + frameBuffer = new byte[19600]; + fs.Read(frameBuffer, 0, frameBuffer.Length); + + if(!swapped) frameBuffer = Swapping.SwapBuffer(frameBuffer); + + outFs = new MemoryStream(); + + for(var i = 9; i <= frameBuffer.Length; i += 10) + { + progress = (i / 10 % 4) switch + { + 0 => '-', + 1 => '\\', + 2 => '|', + 3 => '/', + _ => progress + }; + + Console.Write($"\r{Localization.ExtractingAudio}", progress); + outFs.WriteByte(frameBuffer[i]); + } + + videoFrame = DecodeFrame(frameBuffer); + videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); + audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); + + totalFrames++; + Console.Write("\r \r"); + + Console.WriteLine(Localization.FrameFoundAtPosition, + framePosition, + totalFrames, + framePosition - expectedFramePosition); + + Console.WriteLine(framePosition % 2352 == 0 + ? Localization.FrameIsAtSectorBoundary + : Localization.FrameIsNotAtSectorBoundary, + totalFrames); + + framePosition += 19600; + + break; + } + + framePosition++; + } + + continue; + } + + if(framePosition % 2352 == 0) + { + Console.Write("\r \r"); + Console.WriteLine(Localization.FrameIsAtSectorBoundary, totalFrames); + } + + Console.Write("\r \r"); fs.Position = framePosition; - var frameBuffer = new byte[19600]; + frameBuffer = new byte[19600]; fs.Read(frameBuffer, 0, frameBuffer.Length); - int audioStart = swapped ? 9 : 8; - byte[] frameMarkerToUse = swapped ? SwappedFrameMarker : FrameMarker; + if(!swapped) frameBuffer = Swapping.SwapBuffer(frameBuffer); - if(!swapped) - frameBuffer = Swapping.SwapBuffer(frameBuffer); - - var outFs = new MemoryStream(); + outFs = new MemoryStream(); for(var i = 9; i <= frameBuffer.Length; i += 10) { @@ -106,116 +226,42 @@ namespace Aaru.VideoNow outFs.WriteByte(frameBuffer[i]); } - byte[] videoFrame = DecodeFrame(frameBuffer); + videoFrame = DecodeFrame(frameBuffer); videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); - var totalFrames = 1; + totalFrames++; + fs.Position = framePosition; + fs.Read(buffer, 0, buffer.Length); framePosition += 19600; - var buffer = new byte[frameMarkerToUse.Length]; + } - while(framePosition + 19600 < fs.Length) + Console.Write("\r \r"); + Console.WriteLine(Localization.FramesFound, totalFrames); + + outFs.Close(); + aviWriter.Close(); + } + + public static byte[] DecodeFrame(byte[] frameBuffer) + { + var progress = ' '; + var videoFs = new MemoryStream(); + Array.Reverse(frameBuffer); + byte r, g, b; + + var index = 1; + int indexBlock2; + + for(var i = 0; i < 19200; i += 240) + { + for(var k = 0; k < 120; k += 10) { - progress = (totalFrames % 4) switch - { - 0 => '-', - 1 => '\\', - 2 => '|', - 3 => '/', - _ => progress - }; - - Console.Write($"\r{Localization.LookingForMoreFrames}", progress); - - for(int ab = audioStart; ab < buffer.Length; ab += 10) - buffer[ab] = 0; - - if(!buffer.SequenceEqual(frameMarkerToUse)) + for(var j = 1; j < 9; j += 3) { - Console.Write("\r \r"); - Console.WriteLine(Localization.FrameAndNextAreNotAligned, totalFrames); - long expectedFramePosition = framePosition; + indexBlock2 = index + 120; - while(framePosition < fs.Length) - { - fs.Position = framePosition; - fs.Read(buffer, 0, buffer.Length); - - for(int ab = audioStart; ab < buffer.Length; ab += 10) - buffer[ab] = 0; - - if(buffer.SequenceEqual(frameMarkerToUse)) - { - Console.Write("\r \r"); - - fs.Position = framePosition; - frameBuffer = new byte[19600]; - fs.Read(frameBuffer, 0, frameBuffer.Length); - - if(!swapped) - frameBuffer = Swapping.SwapBuffer(frameBuffer); - - outFs = new MemoryStream(); - - for(var i = 9; i <= frameBuffer.Length; i += 10) - { - progress = (i / 10 % 4) switch - { - 0 => '-', - 1 => '\\', - 2 => '|', - 3 => '/', - _ => progress - }; - - Console.Write($"\r{Localization.ExtractingAudio}", progress); - outFs.WriteByte(frameBuffer[i]); - } - - videoFrame = DecodeFrame(frameBuffer); - videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); - audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); - - totalFrames++; - Console.Write("\r \r"); - - Console.WriteLine(Localization.FrameFoundAtPosition, framePosition, totalFrames, - framePosition - expectedFramePosition); - - Console. - WriteLine(framePosition % 2352 == 0 ? Localization.FrameIsAtSectorBoundary : Localization.FrameIsNotAtSectorBoundary, - totalFrames); - - framePosition += 19600; - - break; - } - - framePosition++; - } - - continue; - } - - if(framePosition % 2352 == 0) - { - Console.Write("\r \r"); - Console.WriteLine(Localization.FrameIsAtSectorBoundary, totalFrames); - } - - Console.Write("\r \r"); - fs.Position = framePosition; - frameBuffer = new byte[19600]; - fs.Read(frameBuffer, 0, frameBuffer.Length); - - if(!swapped) - frameBuffer = Swapping.SwapBuffer(frameBuffer); - - outFs = new MemoryStream(); - - for(var i = 9; i <= frameBuffer.Length; i += 10) - { - progress = (i / 10 % 4) switch + progress = (index / 10 % 4) switch { 0 => '-', 1 => '\\', @@ -224,111 +270,57 @@ namespace Aaru.VideoNow _ => progress }; - Console.Write($"\r{Localization.ExtractingAudio}", progress); - outFs.WriteByte(frameBuffer[i]); + Console.Write($"\r{Localization.ExtractingVideo}", progress); + r = (byte)((frameBuffer[index] & 0xF0) + ((frameBuffer[index] & 0xF0) >> 4)); + b = (byte)((frameBuffer[indexBlock2] & 0xF0) + ((frameBuffer[indexBlock2] & 0xF0) >> 4)); + g = (byte)((frameBuffer[indexBlock2] & 0x0F) + ((frameBuffer[indexBlock2] & 0x0F) << 4)); + videoFs.WriteByte(r); + videoFs.WriteByte(g); + videoFs.WriteByte(b); + + r = (byte)((frameBuffer[indexBlock2 + 1] & 0xF0) + ((frameBuffer[indexBlock2 + 1] & 0xF0) >> 4)); + + b = (byte)((frameBuffer[index] & 0x0F) + ((frameBuffer[index] & 0x0F) << 4)); + g = (byte)((frameBuffer[index + 1] & 0xF0) + ((frameBuffer[index + 1] & 0xF0) >> 4)); + videoFs.WriteByte(r); + videoFs.WriteByte(g); + videoFs.WriteByte(b); + + r = (byte)((frameBuffer[index + 1] & 0x0F) + ((frameBuffer[index + 1] & 0x0F) << 4)); + + b = (byte)((frameBuffer[indexBlock2 + 1] & 0x0F) + ((frameBuffer[indexBlock2 + 1] & 0x0F) << 4)); + + g = (byte)((frameBuffer[indexBlock2 + 2] & 0xF0) + ((frameBuffer[indexBlock2 + 2] & 0xF0) >> 4)); + + videoFs.WriteByte(r); + videoFs.WriteByte(g); + videoFs.WriteByte(b); + + r = (byte)((frameBuffer[index + 120 + 2] & 0x0F) + ((frameBuffer[index + 120 + 2] & 0x0F) << 4)); + + b = (byte)((frameBuffer[index + 2] & 0xF0) + ((frameBuffer[index + 2] & 0xF0) >> 4)); + g = (byte)((frameBuffer[index + 2] & 0x0F) + ((frameBuffer[index + 2] & 0x0F) << 4)); + videoFs.WriteByte(r); + videoFs.WriteByte(g); + videoFs.WriteByte(b); + + index += 3; } - videoFrame = DecodeFrame(frameBuffer); - videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); - audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); - - totalFrames++; - fs.Position = framePosition; - fs.Read(buffer, 0, buffer.Length); - framePosition += 19600; + index += 1; } - Console.Write("\r \r"); - Console.WriteLine(Localization.FramesFound, totalFrames); - - outFs.Close(); - aviWriter.Close(); + index += 120; } - public static byte[] DecodeFrame(byte[] frameBuffer) + frameBuffer = new byte[videoFs.Length]; + byte[] frameBuffer2 = videoFs.ToArray(); + + for(var row = 0; row < 80; row++) { - var progress = ' '; - var videoFs = new MemoryStream(); - Array.Reverse(frameBuffer); - byte r, g, b; - - var index = 1; - int indexBlock2; - - for(var i = 0; i < 19200; i += 240) - { - for(var k = 0; k < 120; k += 10) - { - for(var j = 1; j < 9; j += 3) - { - indexBlock2 = index + 120; - - progress = (index / 10 % 4) switch - { - 0 => '-', - 1 => '\\', - 2 => '|', - 3 => '/', - _ => progress - }; - - Console.Write($"\r{Localization.ExtractingVideo}", progress); - r = (byte)((frameBuffer[index] & 0xF0) + ((frameBuffer[index] & 0xF0) >> 4)); - b = (byte)((frameBuffer[indexBlock2] & 0xF0) + ((frameBuffer[indexBlock2] & 0xF0) >> 4)); - g = (byte)((frameBuffer[indexBlock2] & 0x0F) + ((frameBuffer[indexBlock2] & 0x0F) << 4)); - videoFs.WriteByte(r); - videoFs.WriteByte(g); - videoFs.WriteByte(b); - - r = (byte)((frameBuffer[indexBlock2 + 1] & 0xF0) + - ((frameBuffer[indexBlock2 + 1] & 0xF0) >> 4)); - - b = (byte)((frameBuffer[index] & 0x0F) + ((frameBuffer[index] & 0x0F) << 4)); - g = (byte)((frameBuffer[index + 1] & 0xF0) + ((frameBuffer[index + 1] & 0xF0) >> 4)); - videoFs.WriteByte(r); - videoFs.WriteByte(g); - videoFs.WriteByte(b); - - r = (byte)((frameBuffer[index + 1] & 0x0F) + ((frameBuffer[index + 1] & 0x0F) << 4)); - - b = (byte)((frameBuffer[indexBlock2 + 1] & 0x0F) + - ((frameBuffer[indexBlock2 + 1] & 0x0F) << 4)); - - g = (byte)((frameBuffer[indexBlock2 + 2] & 0xF0) + - ((frameBuffer[indexBlock2 + 2] & 0xF0) >> 4)); - - videoFs.WriteByte(r); - videoFs.WriteByte(g); - videoFs.WriteByte(b); - - r = (byte)((frameBuffer[index + 120 + 2] & 0x0F) + - ((frameBuffer[index + 120 + 2] & 0x0F) << 4)); - - b = (byte)((frameBuffer[index + 2] & 0xF0) + ((frameBuffer[index + 2] & 0xF0) >> 4)); - g = (byte)((frameBuffer[index + 2] & 0x0F) + ((frameBuffer[index + 2] & 0x0F) << 4)); - videoFs.WriteByte(r); - videoFs.WriteByte(g); - videoFs.WriteByte(b); - - index += 3; - } - - index += 1; - } - - index += 120; - } - - frameBuffer = new byte[videoFs.Length]; - byte[] frameBuffer2 = videoFs.ToArray(); - - for(var row = 0; row < 80; row++) - { - for(var p = 0; p < 432; p++) - frameBuffer[row * 432 + p] = frameBuffer2[row * 432 + (431 - p)]; - } - - return frameBuffer; + for(var p = 0; p < 432; p++) frameBuffer[row * 432 + p] = frameBuffer2[row * 432 + (431 - p)]; } + + return frameBuffer; } } \ No newline at end of file diff --git a/Aaru.VideoNow/Program.cs b/Aaru.VideoNow/Program.cs index 179dd86..088c03e 100644 --- a/Aaru.VideoNow/Program.cs +++ b/Aaru.VideoNow/Program.cs @@ -37,178 +37,166 @@ using System.Reflection; // ReSharper disable LocalizableElement -namespace Aaru.VideoNow +namespace Aaru.VideoNow; + +static class MainClass { - internal static class MainClass + const int MAX_SIZE = 635040000; + static string _assemblyCopyright; + 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]; + + public static void Main(string[] args) { - const int MAX_SIZE = 635040000; - static string _assemblyCopyright; - static string _assemblyTitle; - static AssemblyInformationalVersionAttribute _assemblyVersion; + object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); + _assemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title; + attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); - static readonly byte[] FrameStart = - [ - 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81 - ]; + _assemblyVersion = + Attribute.GetCustomAttribute(typeof(MainClass).Assembly, typeof(AssemblyInformationalVersionAttribute)) as + AssemblyInformationalVersionAttribute; - static readonly byte[] SwappedFrameStart = - [ - 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3 - ]; + _assemblyCopyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; - public static void Main(string[] args) + PrintCopyright(); + + if(args.Length != 1) { - object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); - _assemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title; - attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + Console.WriteLine(Localization.Usage); - _assemblyVersion = - Attribute.GetCustomAttribute(typeof(MainClass).Assembly, typeof(AssemblyInformationalVersionAttribute)) - as AssemblyInformationalVersionAttribute; + return; + } - _assemblyCopyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + if(!File.Exists(args[0])) + { + Console.WriteLine(Localization.FileDoesNotExist); - PrintCopyright(); + return; + } - if(args.Length != 1) + FileStream fs; + + try + { + fs = File.Open(args[0], FileMode.Open, FileAccess.Read, FileShare.Read); + } + catch + { + Console.WriteLine(Localization.FileCannotBeOpened); + + return; + } + + if(fs.Length > MAX_SIZE) + { + Console.WriteLine(Localization.FileIsTooBig); + + return; + } + + Console.WriteLine(Localization.FileName, args[0]); + Console.WriteLine(Localization.SearchingFirstFrame); + + long framePosition = 0; + var buffer = new byte[Color.FrameMarker.Length]; + var swappedBuffer = new byte[Color.FrameMarker.Length]; + var swapped = false; + var xp = false; + var startBuffer = new byte[FrameStart.Length]; + var xpBuffer = new byte[Xp.FrameMarker.Length]; + var xpSwappedBuffer = new byte[Xp.FrameMarker.Length]; + + while(framePosition < 19760) + { + fs.Position = framePosition; + fs.Read(startBuffer, 0, startBuffer.Length); + + if(!startBuffer.SequenceEqual(FrameStart) && !startBuffer.SequenceEqual(SwappedFrameStart)) { - Console.WriteLine(Localization.Usage); - - return; - } - - if(!File.Exists(args[0])) - { - Console.WriteLine(Localization.FileDoesNotExist); - - return; - } - - FileStream fs; - - try - { - fs = File.Open(args[0], FileMode.Open, FileAccess.Read, FileShare.Read); - } - catch - { - Console.WriteLine(Localization.FileCannotBeOpened); - - return; - } - - if(fs.Length > MAX_SIZE) - { - Console.WriteLine(Localization.FileIsTooBig); - - return; - } - - Console.WriteLine(Localization.FileName, args[0]); - Console.WriteLine(Localization.SearchingFirstFrame); - - long framePosition = 0; - var buffer = new byte[Color.FrameMarker.Length]; - var swappedBuffer = new byte[Color.FrameMarker.Length]; - var swapped = false; - var xp = false; - var startBuffer = new byte[FrameStart.Length]; - var xpBuffer = new byte[Xp.FrameMarker.Length]; - var xpSwappedBuffer = new byte[Xp.FrameMarker.Length]; - - while(framePosition < 19760) - { - 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); - - for(var ab = 8; ab < buffer.Length; ab += 10) - buffer[ab] = 0; - - if(buffer.SequenceEqual(Color.FrameMarker)) - break; - - fs.Position = framePosition; - fs.Read(swappedBuffer, 0, swappedBuffer.Length); - - for(var ab = 9; ab < swappedBuffer.Length; ab += 10) - swappedBuffer[ab] = 0; - - if(swappedBuffer.SequenceEqual(Color.SwappedFrameMarker)) - { - swapped = true; - - break; - } - - fs.Position = framePosition; - fs.Read(xpBuffer, 0, xpBuffer.Length); - - for(var i = 0; i < xpBuffer.Length; i++) - xpBuffer[i] &= Xp.FrameMask[i]; - - if(xpBuffer.SequenceEqual(Xp.FrameMarker)) - { - xp = true; - - break; - } - - fs.Position = framePosition; - fs.Read(xpSwappedBuffer, 0, xpSwappedBuffer.Length); - - for(var i = 0; i < xpSwappedBuffer.Length; i++) - xpSwappedBuffer[i] &= Xp.SwappedFrameMask[i]; - - if(xpSwappedBuffer.SequenceEqual(Xp.SwappedFrameMarker)) - { - swapped = true; - xp = true; - - break; - } - framePosition++; + + continue; } - if(!buffer.SequenceEqual(Color.FrameMarker) && - !swappedBuffer.SequenceEqual(Color.SwappedFrameMarker) && - !xpBuffer.SequenceEqual(Xp.FrameMarker) && - !xpSwappedBuffer.SequenceEqual(Xp.SwappedFrameMarker)) + fs.Position = framePosition; + fs.Read(buffer, 0, buffer.Length); + + for(var ab = 8; ab < buffer.Length; ab += 10) buffer[ab] = 0; + + if(buffer.SequenceEqual(Color.FrameMarker)) break; + + fs.Position = framePosition; + fs.Read(swappedBuffer, 0, swappedBuffer.Length); + + for(var ab = 9; ab < swappedBuffer.Length; ab += 10) swappedBuffer[ab] = 0; + + if(swappedBuffer.SequenceEqual(Color.SwappedFrameMarker)) { - Console.WriteLine(Localization.NoFrameFound); + swapped = true; - return; + break; } - Console.WriteLine(Localization.FirstFrameFoundAt, framePosition); + fs.Position = framePosition; + fs.Read(xpBuffer, 0, xpBuffer.Length); - Console.WriteLine(framePosition % 2352 == 0 ? Localization.FirstFrameIsAtSectorBoundary - : Localization.FirstFrameIsNotAtSectorBoundary); + for(var i = 0; i < xpBuffer.Length; i++) xpBuffer[i] &= Xp.FrameMask[i]; - if(xp) - Xp.Decode(args[0], fs, swapped, framePosition); - else - Color.Decode(args[0], fs, swapped, framePosition); + if(xpBuffer.SequenceEqual(Xp.FrameMarker)) + { + xp = true; - fs.Close(); + break; + } + + fs.Position = framePosition; + fs.Read(xpSwappedBuffer, 0, xpSwappedBuffer.Length); + + for(var i = 0; i < xpSwappedBuffer.Length; i++) xpSwappedBuffer[i] &= Xp.SwappedFrameMask[i]; + + if(xpSwappedBuffer.SequenceEqual(Xp.SwappedFrameMarker)) + { + swapped = true; + xp = true; + + break; + } + + framePosition++; } - static void PrintCopyright() + if(!buffer.SequenceEqual(Color.FrameMarker) && + !swappedBuffer.SequenceEqual(Color.SwappedFrameMarker) && + !xpBuffer.SequenceEqual(Xp.FrameMarker) && + !xpSwappedBuffer.SequenceEqual(Xp.SwappedFrameMarker)) { - Console.WriteLine("{0} {1}", _assemblyTitle, _assemblyVersion?.InformationalVersion); - Console.WriteLine("{0}", _assemblyCopyright); - Console.WriteLine(); + Console.WriteLine(Localization.NoFrameFound); + + return; } + + Console.WriteLine(Localization.FirstFrameFoundAt, framePosition); + + Console.WriteLine(framePosition % 2352 == 0 + ? Localization.FirstFrameIsAtSectorBoundary + : Localization.FirstFrameIsNotAtSectorBoundary); + + if(xp) + Xp.Decode(args[0], fs, swapped, framePosition); + else + Color.Decode(args[0], fs, swapped, framePosition); + + fs.Close(); + } + + static void PrintCopyright() + { + Console.WriteLine("{0} {1}", _assemblyTitle, _assemblyVersion?.InformationalVersion); + Console.WriteLine("{0}", _assemblyCopyright); + Console.WriteLine(); } } \ No newline at end of file diff --git a/Aaru.VideoNow/Properties/Localization.es.resx b/Aaru.VideoNow/Properties/Localization.es.resx index c1abca0..23e6ce5 100644 --- a/Aaru.VideoNow/Properties/Localization.es.resx +++ b/Aaru.VideoNow/Properties/Localization.es.resx @@ -1,155 +1,160 @@ - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> - - - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + Uso: Aaru.VideoNow dump.raw - + El archivo especificado no existe. - + No se pudo abrir el archivo especificado. - + El archivo es demasiado grande, no se puede continuar. - + Archivo: {0} - + Buscando el primer fotograma.... - + ¡No se pudo encontrar ningún fotograma! - + Se encontró el primer fotograma en {0} - + El primer fotograma está al comienzo de un sector - + El primer fotograma no está al comienzo de un sector - + Extrayendo sonido {0} - + Buscando más fotogramas {0} - + El fotograma {0} y el siguiente no están alineados... - + Fotograma {1} encontrado en {0}, separado por {2} bytes - + El fotograma {0} está al comienzo de un sector - + El fotograma {0} no está al comienzo de un sector - + Encontrados {0} fotogramas - + Extrayendo video {0} \ No newline at end of file diff --git a/Aaru.VideoNow/Properties/Localization.fr.resx b/Aaru.VideoNow/Properties/Localization.fr.resx index 8968922..c10f488 100644 --- a/Aaru.VideoNow/Properties/Localization.fr.resx +++ b/Aaru.VideoNow/Properties/Localization.fr.resx @@ -1,155 +1,160 @@ - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> - - - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + Usage: Aaru.VideoNow dump.raw - + Le fichier spécifié n'existe pas. - + Impossible d'ouvrir le fichier spécifié. - + Le fichier est trop grand, ne peut pas continuer. - + Fichier: {0} - + Cherchant le premier cadre.... - + Aucun cadre trouvé! - + Premier cadre trouvé à {0} - + Premier cadre est à la limite du secteur - + Premier cadre n'est pas à la limite du secteur - + Extraire l'audio {0} - + Vous cherchez plus de cadres {0} - + Cadre {0} et le suivant ne sont pas alignés... - + Cadre {1} trouvé à {0}, {2} bytes apart - + Cadre {0} est à la limite du secteur - + Cadre {0} n'est pas à la limite du secteur - + {0} cadres trouvés - + Extraire la vidéo {0} \ No newline at end of file diff --git a/Aaru.VideoNow/Properties/Localization.it.resx b/Aaru.VideoNow/Properties/Localization.it.resx index 3104aa8..22535e9 100644 --- a/Aaru.VideoNow/Properties/Localization.it.resx +++ b/Aaru.VideoNow/Properties/Localization.it.resx @@ -1,155 +1,160 @@ - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> - - - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + Utilizzo: Aaru.VideoNow dump.raw - + Il file specificato non esiste. - + Impossible aprire il file specificato. - + File troppo grande, impossibile continuare. - + File: {0} - + Ricerca primo fotogramma.... - + Nessun fotogramma trovato! - + Primo fotogramma trovato a {0} - + Primo fotogramma al confine del settore - + Primo fotogramma non al confine del settore - + Estrazione audio {0} - + Buscando más fotogramas {0} - + Fotogramma {0} e il successivo non allineati... - + Fotogramma {1} trovato a {0}, dopo {2} bytes - + Fotogramma {0} al confine del settore - + Fotogramma {0} non al confine del settore - + Trovati {0} fotogrammi - + Estrazione video {0} \ No newline at end of file diff --git a/Aaru.VideoNow/Properties/Localization.nl.resx b/Aaru.VideoNow/Properties/Localization.nl.resx index b63f59f..11f98b2 100644 --- a/Aaru.VideoNow/Properties/Localization.nl.resx +++ b/Aaru.VideoNow/Properties/Localization.nl.resx @@ -1,155 +1,160 @@ - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> - - - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + Usage: Aaru.VideoNow dump.raw - + Opgegeven bestand kan niet worden gevonden. - + Kon opgegeven bestand niet openen. - + Bestand is te groot, afgebroken. - + Bestand: {0} - + Eerste frame aan het zoeken.... - + Geen frame gevonden! - + Eerste frame gevonden op {0} - + Eerste frame is op een sector-grens - + Eerste frame is niet op een sector-grens - + Uitlezen van audio-data {0} - + Zoekend naar (nog meer) frames {0} - + Frame {0} en het volgende frame zijn niet aan elkaar gebonden... - + Frame {1} gevonden op {0}, {2} bytes van elkaar verwijderd - + Frame {0} is op een sector-grens - + Frame {0} is niet op een sector-grens - + {0} Frames gevonden - + Uitlezen van video-data {0} \ No newline at end of file diff --git a/Aaru.VideoNow/Properties/Localization.pt-BR.resx b/Aaru.VideoNow/Properties/Localization.pt-BR.resx index 7ef5737..7780601 100644 --- a/Aaru.VideoNow/Properties/Localization.pt-BR.resx +++ b/Aaru.VideoNow/Properties/Localization.pt-BR.resx @@ -1,155 +1,160 @@ - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> - - - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + Utilização: Aaru.VideoNow dump.raw - + O ficheiro especificado não existe. - + Não conseguiu abrir o ficheiro especificado. - + Ficheiro é demasiado grande, não continuando. - + Ficheiro: {0} - + Procurando primeiro frame.... - + Não conseguiu encontrar nenhum frame! - + Primeiro frame encontrado em {0} - + Primeiro frame está numa fronteira de setor - + Primeiro frame não está numa fronteira de setor - + Extraindo aúdio {0} - + Procurando mais frames {0} - + Frame {0} e o seguinte não estão alinhados... - + Frame {1} encontrado em {0}, distância de {2} bytes - + Frame {1} encontrado em {0}, distância de {2} bytes - + Frame {0} não está numa fronteira de setor - + Encontrados {0} fotogramas - + Extraindo vídeo {0} \ No newline at end of file diff --git a/Aaru.VideoNow/Properties/Localization.pt-PT.resx b/Aaru.VideoNow/Properties/Localization.pt-PT.resx index 7ef5737..7780601 100644 --- a/Aaru.VideoNow/Properties/Localization.pt-PT.resx +++ b/Aaru.VideoNow/Properties/Localization.pt-PT.resx @@ -1,155 +1,160 @@ - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> - - - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + Utilização: Aaru.VideoNow dump.raw - + O ficheiro especificado não existe. - + Não conseguiu abrir o ficheiro especificado. - + Ficheiro é demasiado grande, não continuando. - + Ficheiro: {0} - + Procurando primeiro frame.... - + Não conseguiu encontrar nenhum frame! - + Primeiro frame encontrado em {0} - + Primeiro frame está numa fronteira de setor - + Primeiro frame não está numa fronteira de setor - + Extraindo aúdio {0} - + Procurando mais frames {0} - + Frame {0} e o seguinte não estão alinhados... - + Frame {1} encontrado em {0}, distância de {2} bytes - + Frame {1} encontrado em {0}, distância de {2} bytes - + Frame {0} não está numa fronteira de setor - + Encontrados {0} fotogramas - + Extraindo vídeo {0} \ No newline at end of file diff --git a/Aaru.VideoNow/Properties/Localization.resx b/Aaru.VideoNow/Properties/Localization.resx index 76ea699..3a82aa1 100644 --- a/Aaru.VideoNow/Properties/Localization.resx +++ b/Aaru.VideoNow/Properties/Localization.resx @@ -59,73 +59,78 @@ --> - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + Usage: Aaru.VideoNow dump.raw - + Specified file does not exist. - + Could not open specified file. - + File is too big, not continuing. - + File: {0} - + Searching for first frame.... - + Could not find any frame! - + First frame found at {0} - + First frame is at a sector boundary - + First frame is not at a sector boundary - + Extracting audio {0} - + Looking for more frames {0} - + Frame {0} and the next one are not aligned... - + Frame {1} found at {0}, {2} bytes apart - + Frame {0} is at a sector boundary - + Frame {0} is not at a sector boundary - + Found {0} frames - + Extracting video {0} \ No newline at end of file diff --git a/Aaru.VideoNow/Properties/Localization.ro.resx b/Aaru.VideoNow/Properties/Localization.ro.resx index 71610d2..9143e53 100644 --- a/Aaru.VideoNow/Properties/Localization.ro.resx +++ b/Aaru.VideoNow/Properties/Localization.ro.resx @@ -1,155 +1,160 @@ - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> - - - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + Folosire: Aaru.VideoNow dump.raw - + Fișierul specificat nu există. - + Fișierul specificat nu poate fi deschis. - + Fișierul este prea mare, imposibil de continuat. - + Fișier: {0} - + Caut primul cadru.... - + Nu am putut găsi nici un cadru! - + Primul cardu a fost găsit la {0} - + Primul cadru este la limita sectorului - + Primul cadru nu este la limita sectorului - + Extrag audio {0} - + Caut mai multe cardre {0} - + Cadrul {0} și următorul nu sunt aliniate... - + Cadrul {1} găsit la {0}, {2} bytes distanta - + Cadrul {0} este la limita sectorului - + Cadrul nu este la limita secorului - + {0} cadre găsite - + Extrag video {0} \ No newline at end of file diff --git a/Aaru.VideoNow/Properties/Localization.ru.resx b/Aaru.VideoNow/Properties/Localization.ru.resx index 524e96a..07496b3 100644 --- a/Aaru.VideoNow/Properties/Localization.ru.resx +++ b/Aaru.VideoNow/Properties/Localization.ru.resx @@ -1,155 +1,160 @@ - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> - - - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + Использование: Aaru.VideoNow dump.raw - + Указанный файл не существует. - + Невозможно открыть указанный файл. - + Файл слишком большой, операция прекращена. - + Файл: {0} - + Поиск первого фрейма.... - + Невозможно найти ни один фрейм! - + Первый фрейм найден по смещению {0} - + Первый фрейм на границе сектора - + Первый фрейм не на границе сектора - + Извлечение аудио {0} - + Продолжение поиска фреймов {0} - + Фрейм {0} и следующий за ним не выровнены... - + Фрейм {1} найден по смещению {0}, на расстоянии {2} байт - + Фрейм {0} на границе сектора - + Фрейм {0} не на границе сектора - + Найдено {0} фреймов - + Извлечение видео {0} \ No newline at end of file diff --git a/Aaru.VideoNow/Properties/Localization.sv.resx b/Aaru.VideoNow/Properties/Localization.sv.resx index 8ca6e70..dd981bc 100644 --- a/Aaru.VideoNow/Properties/Localization.sv.resx +++ b/Aaru.VideoNow/Properties/Localization.sv.resx @@ -1,155 +1,160 @@ - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> - - - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + Användning: Aaru.VideoNow dump.raw - + Angivna filen finns inte. - + Kunde inte öppna den angivna filen. - + Filen är för stor, avbryter. - + Fil: {0} - + Söker efter första bilden.... - + Kunde inte hitta några bilder! - + Första bilden hittad på {0} - + Första bilden funnen vid en sektorgräns - + Första bilden finns ej vid en sektorgräns - + Extraherar audio {0} - + Letar efter fler bilder {0} - + Bild {0} och efterföljade bild är inte inriktad... - + Bild {1} funnen på {0}, {2} bytes från varandra - + Bild {0} funnen vid en sektorgräns - + Bild {0} finns ej vid en sektorgräns - + {0} bilder funna - + Extraherar video {0} \ No newline at end of file diff --git a/Aaru.VideoNow/Swapping.cs b/Aaru.VideoNow/Swapping.cs index 7e4338a..e28981b 100644 --- a/Aaru.VideoNow/Swapping.cs +++ b/Aaru.VideoNow/Swapping.cs @@ -1,18 +1,17 @@ -namespace Aaru.VideoNow +namespace Aaru.VideoNow; + +public static class Swapping { - public static class Swapping + public static byte[] SwapBuffer(byte[] buffer) { - public static byte[] SwapBuffer(byte[] buffer) + var tmp = new byte[buffer.Length]; + + for(var i = 0; i < buffer.Length; i += 2) { - var tmp = new byte[buffer.Length]; - - for(var i = 0; i < buffer.Length; i += 2) - { - tmp[i] = buffer[i + 1]; - tmp[i + 1] = buffer[i]; - } - - return tmp; + tmp[i] = buffer[i + 1]; + tmp[i + 1] = buffer[i]; } + + return tmp; } } \ No newline at end of file diff --git a/Aaru.VideoNow/Xp.cs b/Aaru.VideoNow/Xp.cs index 8c67607..7f4e0e5 100644 --- a/Aaru.VideoNow/Xp.cs +++ b/Aaru.VideoNow/Xp.cs @@ -4,179 +4,299 @@ using System.Linq; using SharpAvi; using SharpAvi.Output; -namespace Aaru.VideoNow +namespace Aaru.VideoNow; + +public static class Xp { - public static class Xp + public static readonly byte[] FrameMask = + [ + 0xFF, 0xFF, 0xFF, 0xFF, 0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 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,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, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0xFF + ]; + + public static readonly byte[] FrameMarker = + [ + 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, + 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, + 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, + 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, + 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, + 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, + 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00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7, + 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, + 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, + 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, + 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, + 0x81, 0xE3, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00 + ]; + + public static readonly byte[] SwappedFrameMarker = + [ + 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, + 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, + 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, + 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, + 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, + 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, + 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF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, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, + 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, + 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, + 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, + 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, + 0xE3, 0x81, 0x00, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0xFF + ]; + + public static void Decode(string filename, Stream fs, bool swapped, long framePosition) { - public static readonly byte[] FrameMask = - [ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,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x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x00 - ]; + var progress = ' '; - public static readonly byte[] SwappedFrameMask = - [ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x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x00, 0x00, 0x00, 0x00, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0xFF - ]; - - public static readonly byte[] FrameMarker = - [ - 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, - 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, - 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, - 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, - 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, - 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, - 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF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x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x00 - ]; - - public static readonly byte[] SwappedFrameMarker = - [ - 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, - 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, - 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, - 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, - 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, - 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, - 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x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00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0xFF - ]; - - public static void Decode(string filename, Stream fs, bool swapped, long framePosition) + var aviWriter = new AviWriter(filename + ".avi") { - var progress = ' '; + EmitIndex1 = true, FramesPerSecond = 18 + }; - var aviWriter = new AviWriter(filename + ".avi") + IAviVideoStream videoStream = aviWriter.AddVideoStream(144, 80, BitsPerPixel.Bpp24); + videoStream.Codec = CodecIds.Uncompressed; + IAviAudioStream audioStream = aviWriter.AddAudioStream(2, 17784, 8); + + fs.Position = framePosition; + var frameBuffer = new byte[19760]; + fs.Read(frameBuffer, 0, frameBuffer.Length); + + int audioStart = swapped ? 9 : 8; + byte[] frameMarkerToUse = swapped ? SwappedFrameMarker : FrameMarker; + byte[] frameMaskToUse = swapped ? SwappedFrameMask : FrameMask; + + if(swapped) frameBuffer = Swapping.SwapBuffer(frameBuffer); + + var outFs = new MemoryStream(); + + for(var i = 9; i <= frameBuffer.Length; i += 10) + { + progress = (i / 10 % 4) switch + { + 0 => '-', + 1 => '\\', + 2 => '|', + 3 => '/', + _ => progress + }; + + Console.Write($"\r{Localization.ExtractingAudio}", progress); + outFs.WriteByte(frameBuffer[i]); + } + + byte[] videoFrame = Color.DecodeFrame(frameBuffer); + videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); + audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); + + var totalFrames = 1; + framePosition += 19760; + var buffer = new byte[frameMarkerToUse.Length]; + + while(framePosition + 19760 < fs.Length) + { + progress = (totalFrames % 4) switch + { + 0 => '-', + 1 => '\\', + 2 => '|', + 3 => '/', + _ => progress + }; + + Console.Write($"\r{Localization.LookingForMoreFrames}", progress); + + for(var i = 0; i < buffer.Length; i++) buffer[i] &= frameMaskToUse[i]; + + if(!buffer.SequenceEqual(frameMarkerToUse)) { - EmitIndex1 = true, FramesPerSecond = 18 - }; + Console.Write("\r \r"); + Console.WriteLine(Localization.FrameAndNextAreNotAligned, totalFrames); + long expectedFramePosition = framePosition; - IAviVideoStream videoStream = aviWriter.AddVideoStream(144, 80, BitsPerPixel.Bpp24); - videoStream.Codec = CodecIds.Uncompressed; - IAviAudioStream audioStream = aviWriter.AddAudioStream(2, 17784, 8); + while(framePosition < fs.Length) + { + fs.Position = framePosition; + fs.Read(buffer, 0, buffer.Length); + for(var i = 0; i < buffer.Length; i++) buffer[i] &= frameMaskToUse[i]; + + if(buffer.SequenceEqual(frameMarkerToUse)) + { + Console.Write("\r \r"); + + fs.Position = framePosition; + frameBuffer = new byte[19760]; + fs.Read(frameBuffer, 0, frameBuffer.Length); + + if(swapped) frameBuffer = Swapping.SwapBuffer(frameBuffer); + + outFs = new MemoryStream(); + + for(var i = 9; i <= frameBuffer.Length; i += 10) + { + progress = (i / 10 % 4) switch + { + 0 => '-', + 1 => '\\', + 2 => '|', + 3 => '/', + _ => progress + }; + + Console.Write($"\r{Localization.ExtractingAudio}", progress); + outFs.WriteByte(frameBuffer[i]); + } + + videoFrame = Color.DecodeFrame(frameBuffer); + videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); + audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); + + totalFrames++; + Console.Write("\r \r"); + + Console.WriteLine(Localization.FrameFoundAtPosition, + framePosition, + totalFrames, + framePosition - expectedFramePosition); + + Console.WriteLine(framePosition % 2352 == 0 + ? Localization.FrameIsAtSectorBoundary + : Localization.FrameIsNotAtSectorBoundary, + totalFrames); + + framePosition += 19760; + + break; + } + + framePosition++; + } + + continue; + } + + if(framePosition % 2352 == 0) + { + Console.Write("\r \r"); + Console.WriteLine(Localization.FrameIsAtSectorBoundary, totalFrames); + } + + Console.Write("\r \r"); fs.Position = framePosition; - var frameBuffer = new byte[19760]; + frameBuffer = new byte[19760]; fs.Read(frameBuffer, 0, frameBuffer.Length); - int audioStart = swapped ? 9 : 8; - byte[] frameMarkerToUse = swapped ? SwappedFrameMarker : FrameMarker; - byte[] frameMaskToUse = swapped ? SwappedFrameMask : FrameMask; + if(swapped) frameBuffer = Swapping.SwapBuffer(frameBuffer); - if(swapped) - frameBuffer = Swapping.SwapBuffer(frameBuffer); - - var outFs = new MemoryStream(); + outFs = new MemoryStream(); for(var i = 9; i <= frameBuffer.Length; i += 10) { @@ -193,143 +313,20 @@ namespace Aaru.VideoNow outFs.WriteByte(frameBuffer[i]); } - byte[] videoFrame = Color.DecodeFrame(frameBuffer); + videoFrame = Color.DecodeFrame(frameBuffer); videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); - var totalFrames = 1; + totalFrames++; + fs.Position = framePosition; + fs.Read(buffer, 0, buffer.Length); framePosition += 19760; - var buffer = new byte[frameMarkerToUse.Length]; - - while(framePosition + 19760 < fs.Length) - { - progress = (totalFrames % 4) switch - { - 0 => '-', - 1 => '\\', - 2 => '|', - 3 => '/', - _ => progress - }; - - Console.Write($"\r{Localization.LookingForMoreFrames}", progress); - - for(var i = 0; i < buffer.Length; i++) - buffer[i] &= frameMaskToUse[i]; - - if(!buffer.SequenceEqual(frameMarkerToUse)) - { - Console.Write("\r \r"); - Console.WriteLine(Localization.FrameAndNextAreNotAligned, totalFrames); - long expectedFramePosition = framePosition; - - while(framePosition < fs.Length) - { - fs.Position = framePosition; - fs.Read(buffer, 0, buffer.Length); - - for(var i = 0; i < buffer.Length; i++) - buffer[i] &= frameMaskToUse[i]; - - if(buffer.SequenceEqual(frameMarkerToUse)) - { - Console.Write("\r \r"); - - fs.Position = framePosition; - frameBuffer = new byte[19760]; - fs.Read(frameBuffer, 0, frameBuffer.Length); - - if(swapped) - frameBuffer = Swapping.SwapBuffer(frameBuffer); - - outFs = new MemoryStream(); - - for(var i = 9; i <= frameBuffer.Length; i += 10) - { - progress = (i / 10 % 4) switch - { - 0 => '-', - 1 => '\\', - 2 => '|', - 3 => '/', - _ => progress - }; - - Console.Write($"\r{Localization.ExtractingAudio}", progress); - outFs.WriteByte(frameBuffer[i]); - } - - videoFrame = Color.DecodeFrame(frameBuffer); - videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); - audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); - - totalFrames++; - Console.Write("\r \r"); - - Console.WriteLine(Localization.FrameFoundAtPosition, framePosition, totalFrames, - framePosition - expectedFramePosition); - - Console. - WriteLine(framePosition % 2352 == 0 ? Localization.FrameIsAtSectorBoundary : Localization.FrameIsNotAtSectorBoundary, - totalFrames); - - framePosition += 19760; - - break; - } - - framePosition++; - } - - continue; - } - - if(framePosition % 2352 == 0) - { - Console.Write("\r \r"); - Console.WriteLine(Localization.FrameIsAtSectorBoundary, totalFrames); - } - - Console.Write("\r \r"); - fs.Position = framePosition; - frameBuffer = new byte[19760]; - fs.Read(frameBuffer, 0, frameBuffer.Length); - - if(swapped) - frameBuffer = Swapping.SwapBuffer(frameBuffer); - - outFs = new MemoryStream(); - - for(var i = 9; i <= frameBuffer.Length; i += 10) - { - progress = (i / 10 % 4) switch - { - 0 => '-', - 1 => '\\', - 2 => '|', - 3 => '/', - _ => progress - }; - - Console.Write($"\r{Localization.ExtractingAudio}", progress); - outFs.WriteByte(frameBuffer[i]); - } - - videoFrame = Color.DecodeFrame(frameBuffer); - videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); - audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); - - totalFrames++; - fs.Position = framePosition; - fs.Read(buffer, 0, buffer.Length); - framePosition += 19760; - } - - Console.Write("\r \r"); - Console.WriteLine(Localization.FramesFound, totalFrames); - - outFs.Close(); - aviWriter.Close(); } + + Console.Write("\r \r"); + Console.WriteLine(Localization.FramesFound, totalFrames); + + outFs.Close(); + aviWriter.Close(); } } \ No newline at end of file