Apply latest language features.

This commit is contained in:
2024-04-30 04:45:40 +01:00
parent 51ac29c6de
commit df86b44902
4 changed files with 133 additions and 232 deletions

View File

@@ -13,7 +13,7 @@ namespace Aaru.VideoNow
/// endian, so the first appearence is at 9th byte. /// endian, so the first appearence is at 9th byte.
/// </summary> /// </summary>
public static readonly byte[] FrameMarker = public static readonly byte[] FrameMarker =
{ [
0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 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, 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, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3,
@@ -37,10 +37,10 @@ namespace Aaru.VideoNow
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0xFF 0xFF, 0xFF, 0x00, 0xFF
}; ];
public static readonly byte[] SwappedFrameMarker = public static readonly byte[] SwappedFrameMarker =
{ [
0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 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, 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, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7,
@@ -64,11 +64,11 @@ namespace Aaru.VideoNow
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x00 0xFF, 0xFF, 0xFF, 0x00
}; ];
public static void Decode(string filename, Stream fs, bool swapped, long framePosition) public static void Decode(string filename, Stream fs, bool swapped, long framePosition)
{ {
char progress = ' '; var progress = ' ';
var aviWriter = new AviWriter(filename + ".avi") var aviWriter = new AviWriter(filename + ".avi")
{ {
@@ -80,7 +80,7 @@ namespace Aaru.VideoNow
IAviAudioStream audioStream = aviWriter.AddAudioStream(2, 17640, 8); IAviAudioStream audioStream = aviWriter.AddAudioStream(2, 17640, 8);
fs.Position = framePosition; fs.Position = framePosition;
byte[] frameBuffer = new byte[19600]; var frameBuffer = new byte[19600];
fs.Read(frameBuffer, 0, frameBuffer.Length); fs.Read(frameBuffer, 0, frameBuffer.Length);
int audioStart = swapped ? 9 : 8; int audioStart = swapped ? 9 : 8;
@@ -91,27 +91,16 @@ namespace Aaru.VideoNow
var outFs = new MemoryStream(); var outFs = new MemoryStream();
for(int i = 9; i <= frameBuffer.Length; i += 10) for(var i = 9; i <= frameBuffer.Length; i += 10)
{ {
switch((i / 10) % 4) progress = (i / 10 % 4) switch
{ {
case 0: 0 => '-',
progress = '-'; 1 => '\\',
2 => '|',
break; 3 => '/',
case 1: _ => progress
progress = '\\'; };
break;
case 2:
progress = '|';
break;
case 3:
progress = '/';
break;
}
Console.Write($"\r{Localization.ExtractingAudio}", progress); Console.Write($"\r{Localization.ExtractingAudio}", progress);
outFs.WriteByte(frameBuffer[i]); outFs.WriteByte(frameBuffer[i]);
@@ -121,31 +110,20 @@ namespace Aaru.VideoNow
videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length);
audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length);
int totalFrames = 1; var totalFrames = 1;
framePosition += 19600; framePosition += 19600;
byte[] buffer = new byte[frameMarkerToUse.Length]; var buffer = new byte[frameMarkerToUse.Length];
while(framePosition + 19600 < fs.Length) while(framePosition + 19600 < fs.Length)
{ {
switch(totalFrames % 4) progress = (totalFrames % 4) switch
{ {
case 0: 0 => '-',
progress = '-'; 1 => '\\',
2 => '|',
break; 3 => '/',
case 1: _ => progress
progress = '\\'; };
break;
case 2:
progress = '|';
break;
case 3:
progress = '/';
break;
}
Console.Write($"\r{Localization.LookingForMoreFrames}", progress); Console.Write($"\r{Localization.LookingForMoreFrames}", progress);
@@ -179,27 +157,16 @@ namespace Aaru.VideoNow
outFs = new MemoryStream(); outFs = new MemoryStream();
for(int i = 9; i <= frameBuffer.Length; i += 10) for(var i = 9; i <= frameBuffer.Length; i += 10)
{ {
switch((i / 10) % 4) progress = (i / 10 % 4) switch
{ {
case 0: 0 => '-',
progress = '-'; 1 => '\\',
2 => '|',
break; 3 => '/',
case 1: _ => progress
progress = '\\'; };
break;
case 2:
progress = '|';
break;
case 3:
progress = '/';
break;
}
Console.Write($"\r{Localization.ExtractingAudio}", progress); Console.Write($"\r{Localization.ExtractingAudio}", progress);
outFs.WriteByte(frameBuffer[i]); outFs.WriteByte(frameBuffer[i]);
@@ -246,27 +213,16 @@ namespace Aaru.VideoNow
outFs = new MemoryStream(); outFs = new MemoryStream();
for(int i = 9; i <= frameBuffer.Length; i += 10) for(var i = 9; i <= frameBuffer.Length; i += 10)
{ {
switch((i / 10) % 4) progress = (i / 10 % 4) switch
{ {
case 0: 0 => '-',
progress = '-'; 1 => '\\',
2 => '|',
break; 3 => '/',
case 1: _ => progress
progress = '\\'; };
break;
case 2:
progress = '|';
break;
case 3:
progress = '/';
break;
}
Console.Write($"\r{Localization.ExtractingAudio}", progress); Console.Write($"\r{Localization.ExtractingAudio}", progress);
outFs.WriteByte(frameBuffer[i]); outFs.WriteByte(frameBuffer[i]);
@@ -291,41 +247,30 @@ namespace Aaru.VideoNow
public static byte[] DecodeFrame(byte[] frameBuffer) public static byte[] DecodeFrame(byte[] frameBuffer)
{ {
char progress = ' '; var progress = ' ';
var videoFs = new MemoryStream(); var videoFs = new MemoryStream();
Array.Reverse(frameBuffer); Array.Reverse(frameBuffer);
byte r, g, b; byte r, g, b;
int index = 1; var index = 1;
int indexBlock2; int indexBlock2;
for(int i = 0; i < 19200; i += 240) for(var i = 0; i < 19200; i += 240)
{ {
for(int k = 0; k < 120; k += 10) for(var k = 0; k < 120; k += 10)
{ {
for(int j = 1; j < 9; j += 3) for(var j = 1; j < 9; j += 3)
{ {
indexBlock2 = index + 120; indexBlock2 = index + 120;
switch((index / 10) % 4) progress = (index / 10 % 4) switch
{ {
case 0: 0 => '-',
progress = '-'; 1 => '\\',
2 => '|',
break; 3 => '/',
case 1: _ => progress
progress = '\\'; };
break;
case 2:
progress = '|';
break;
case 3:
progress = '/';
break;
}
Console.Write($"\r{Localization.ExtractingVideo}", progress); Console.Write($"\r{Localization.ExtractingVideo}", progress);
r = (byte)((frameBuffer[index] & 0xF0) + ((frameBuffer[index] & 0xF0) >> 4)); r = (byte)((frameBuffer[index] & 0xF0) + ((frameBuffer[index] & 0xF0) >> 4));
@@ -377,10 +322,10 @@ namespace Aaru.VideoNow
frameBuffer = new byte[videoFs.Length]; frameBuffer = new byte[videoFs.Length];
byte[] frameBuffer2 = videoFs.ToArray(); byte[] frameBuffer2 = videoFs.ToArray();
for(int row = 0; row < 80; row++) for(var row = 0; row < 80; row++)
{ {
for(int p = 0; p < 432; p++) for(var p = 0; p < 432; p++)
frameBuffer[(row * 432) + p] = frameBuffer2[(row * 432) + (431 - p)]; frameBuffer[row * 432 + p] = frameBuffer2[row * 432 + (431 - p)];
} }
return frameBuffer; return frameBuffer;

View File

@@ -42,31 +42,31 @@ namespace Aaru.VideoNow
internal static class MainClass internal static class MainClass
{ {
const int MAX_SIZE = 635040000; const int MAX_SIZE = 635040000;
static string assemblyCopyright; static string _assemblyCopyright;
static string assemblyTitle; static string _assemblyTitle;
static AssemblyInformationalVersionAttribute assemblyVersion; static AssemblyInformationalVersionAttribute _assemblyVersion;
static readonly byte[] FrameStart = static readonly byte[] FrameStart =
{ [
0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81
}; ];
static readonly byte[] SwappedFrameStart = static readonly byte[] SwappedFrameStart =
{ [
0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3
}; ];
public static void Main(string[] args) public static void Main(string[] args)
{ {
object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
assemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title; _assemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title;
attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
assemblyVersion = _assemblyVersion =
Attribute.GetCustomAttribute(typeof(MainClass).Assembly, typeof(AssemblyInformationalVersionAttribute)) Attribute.GetCustomAttribute(typeof(MainClass).Assembly, typeof(AssemblyInformationalVersionAttribute))
as AssemblyInformationalVersionAttribute; as AssemblyInformationalVersionAttribute;
assemblyCopyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; _assemblyCopyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
PrintCopyright(); PrintCopyright();
@@ -108,13 +108,13 @@ namespace Aaru.VideoNow
Console.WriteLine(Localization.SearchingFirstFrame); Console.WriteLine(Localization.SearchingFirstFrame);
long framePosition = 0; long framePosition = 0;
byte[] buffer = new byte[Color.FrameMarker.Length]; var buffer = new byte[Color.FrameMarker.Length];
byte[] swappedBuffer = new byte[Color.FrameMarker.Length]; var swappedBuffer = new byte[Color.FrameMarker.Length];
bool swapped = false; var swapped = false;
bool xp = false; var xp = false;
byte[] startBuffer = new byte[FrameStart.Length]; var startBuffer = new byte[FrameStart.Length];
byte[] xpBuffer = new byte[Xp.FrameMarker.Length]; var xpBuffer = new byte[Xp.FrameMarker.Length];
byte[] xpSwappedBuffer = new byte[Xp.FrameMarker.Length]; var xpSwappedBuffer = new byte[Xp.FrameMarker.Length];
while(framePosition < 19760) while(framePosition < 19760)
{ {
@@ -132,7 +132,7 @@ namespace Aaru.VideoNow
fs.Position = framePosition; fs.Position = framePosition;
fs.Read(buffer, 0, buffer.Length); fs.Read(buffer, 0, buffer.Length);
for(int ab = 8; ab < buffer.Length; ab += 10) for(var ab = 8; ab < buffer.Length; ab += 10)
buffer[ab] = 0; buffer[ab] = 0;
if(buffer.SequenceEqual(Color.FrameMarker)) if(buffer.SequenceEqual(Color.FrameMarker))
@@ -141,7 +141,7 @@ namespace Aaru.VideoNow
fs.Position = framePosition; fs.Position = framePosition;
fs.Read(swappedBuffer, 0, swappedBuffer.Length); fs.Read(swappedBuffer, 0, swappedBuffer.Length);
for(int ab = 9; ab < swappedBuffer.Length; ab += 10) for(var ab = 9; ab < swappedBuffer.Length; ab += 10)
swappedBuffer[ab] = 0; swappedBuffer[ab] = 0;
if(swappedBuffer.SequenceEqual(Color.SwappedFrameMarker)) if(swappedBuffer.SequenceEqual(Color.SwappedFrameMarker))
@@ -154,7 +154,7 @@ namespace Aaru.VideoNow
fs.Position = framePosition; fs.Position = framePosition;
fs.Read(xpBuffer, 0, xpBuffer.Length); fs.Read(xpBuffer, 0, xpBuffer.Length);
for(int i = 0; i < xpBuffer.Length; i++) for(var i = 0; i < xpBuffer.Length; i++)
xpBuffer[i] &= Xp.FrameMask[i]; xpBuffer[i] &= Xp.FrameMask[i];
if(xpBuffer.SequenceEqual(Xp.FrameMarker)) if(xpBuffer.SequenceEqual(Xp.FrameMarker))
@@ -167,7 +167,7 @@ namespace Aaru.VideoNow
fs.Position = framePosition; fs.Position = framePosition;
fs.Read(xpSwappedBuffer, 0, xpSwappedBuffer.Length); fs.Read(xpSwappedBuffer, 0, xpSwappedBuffer.Length);
for(int i = 0; i < xpSwappedBuffer.Length; i++) for(var i = 0; i < xpSwappedBuffer.Length; i++)
xpSwappedBuffer[i] &= Xp.SwappedFrameMask[i]; xpSwappedBuffer[i] &= Xp.SwappedFrameMask[i];
if(xpSwappedBuffer.SequenceEqual(Xp.SwappedFrameMarker)) if(xpSwappedBuffer.SequenceEqual(Xp.SwappedFrameMarker))
@@ -206,8 +206,8 @@ namespace Aaru.VideoNow
static void PrintCopyright() static void PrintCopyright()
{ {
Console.WriteLine("{0} {1}", assemblyTitle, assemblyVersion?.InformationalVersion); Console.WriteLine("{0} {1}", _assemblyTitle, _assemblyVersion?.InformationalVersion);
Console.WriteLine("{0}", assemblyCopyright); Console.WriteLine("{0}", _assemblyCopyright);
Console.WriteLine(); Console.WriteLine();
} }
} }

View File

@@ -4,9 +4,9 @@ namespace Aaru.VideoNow
{ {
public static byte[] SwapBuffer(byte[] buffer) public static byte[] SwapBuffer(byte[] buffer)
{ {
byte[] tmp = new byte[buffer.Length]; var tmp = new byte[buffer.Length];
for(int i = 0; i < buffer.Length; i += 2) for(var i = 0; i < buffer.Length; i += 2)
{ {
tmp[i] = buffer[i + 1]; tmp[i] = buffer[i + 1];
tmp[i + 1] = buffer[i]; tmp[i + 1] = buffer[i];

View File

@@ -9,7 +9,7 @@ namespace Aaru.VideoNow
public static class Xp public static class Xp
{ {
public static readonly byte[] FrameMask = public static readonly byte[] FrameMask =
{ [
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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, 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, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -42,10 +42,10 @@ namespace Aaru.VideoNow
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, 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, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x00 0xFF, 0x00
}; ];
public static readonly byte[] SwappedFrameMask = public static readonly byte[] SwappedFrameMask =
{ [
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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, 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, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -78,10 +78,10 @@ namespace Aaru.VideoNow
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 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, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0xFF 0x00, 0xFF
}; ];
public static readonly byte[] FrameMarker = public static readonly byte[] FrameMarker =
{ [
0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 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, 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, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7, 0xC7, 0x81, 0x81, 0xE3, 0xC7, 0x00, 0x81, 0xE3, 0xE3, 0xC7,
@@ -114,10 +114,10 @@ namespace Aaru.VideoNow
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, 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, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x00 0xFF, 0x00
}; ];
public static readonly byte[] SwappedFrameMarker = public static readonly byte[] SwappedFrameMarker =
{ [
0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 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, 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, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0xC7, 0xE3, 0x81, 0x00, 0xC7, 0xE3, 0x81, 0xC7, 0xE3,
@@ -150,11 +150,11 @@ namespace Aaru.VideoNow
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 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, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x00, 0xFF 0x00, 0xFF
}; ];
public static void Decode(string filename, Stream fs, bool swapped, long framePosition) public static void Decode(string filename, Stream fs, bool swapped, long framePosition)
{ {
char progress = ' '; var progress = ' ';
var aviWriter = new AviWriter(filename + ".avi") var aviWriter = new AviWriter(filename + ".avi")
{ {
@@ -166,7 +166,7 @@ namespace Aaru.VideoNow
IAviAudioStream audioStream = aviWriter.AddAudioStream(2, 17784, 8); IAviAudioStream audioStream = aviWriter.AddAudioStream(2, 17784, 8);
fs.Position = framePosition; fs.Position = framePosition;
byte[] frameBuffer = new byte[19760]; var frameBuffer = new byte[19760];
fs.Read(frameBuffer, 0, frameBuffer.Length); fs.Read(frameBuffer, 0, frameBuffer.Length);
int audioStart = swapped ? 9 : 8; int audioStart = swapped ? 9 : 8;
@@ -178,27 +178,16 @@ namespace Aaru.VideoNow
var outFs = new MemoryStream(); var outFs = new MemoryStream();
for(int i = 9; i <= frameBuffer.Length; i += 10) for(var i = 9; i <= frameBuffer.Length; i += 10)
{ {
switch((i / 10) % 4) progress = (i / 10 % 4) switch
{ {
case 0: 0 => '-',
progress = '-'; 1 => '\\',
2 => '|',
break; 3 => '/',
case 1: _ => progress
progress = '\\'; };
break;
case 2:
progress = '|';
break;
case 3:
progress = '/';
break;
}
Console.Write($"\r{Localization.ExtractingAudio}", progress); Console.Write($"\r{Localization.ExtractingAudio}", progress);
outFs.WriteByte(frameBuffer[i]); outFs.WriteByte(frameBuffer[i]);
@@ -208,35 +197,24 @@ namespace Aaru.VideoNow
videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length); videoStream.WriteFrame(true, videoFrame, 0, videoFrame.Length);
audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length); audioStream.WriteBlock(outFs.ToArray(), 0, (int)outFs.Length);
int totalFrames = 1; var totalFrames = 1;
framePosition += 19760; framePosition += 19760;
byte[] buffer = new byte[frameMarkerToUse.Length]; var buffer = new byte[frameMarkerToUse.Length];
while(framePosition + 19760 < fs.Length) while(framePosition + 19760 < fs.Length)
{ {
switch(totalFrames % 4) progress = (totalFrames % 4) switch
{ {
case 0: 0 => '-',
progress = '-'; 1 => '\\',
2 => '|',
break; 3 => '/',
case 1: _ => progress
progress = '\\'; };
break;
case 2:
progress = '|';
break;
case 3:
progress = '/';
break;
}
Console.Write($"\r{Localization.LookingForMoreFrames}", progress); Console.Write($"\r{Localization.LookingForMoreFrames}", progress);
for(int i = 0; i < buffer.Length; i++) for(var i = 0; i < buffer.Length; i++)
buffer[i] &= frameMaskToUse[i]; buffer[i] &= frameMaskToUse[i];
if(!buffer.SequenceEqual(frameMarkerToUse)) if(!buffer.SequenceEqual(frameMarkerToUse))
@@ -250,7 +228,7 @@ namespace Aaru.VideoNow
fs.Position = framePosition; fs.Position = framePosition;
fs.Read(buffer, 0, buffer.Length); fs.Read(buffer, 0, buffer.Length);
for(int i = 0; i < buffer.Length; i++) for(var i = 0; i < buffer.Length; i++)
buffer[i] &= frameMaskToUse[i]; buffer[i] &= frameMaskToUse[i];
if(buffer.SequenceEqual(frameMarkerToUse)) if(buffer.SequenceEqual(frameMarkerToUse))
@@ -266,27 +244,16 @@ namespace Aaru.VideoNow
outFs = new MemoryStream(); outFs = new MemoryStream();
for(int i = 9; i <= frameBuffer.Length; i += 10) for(var i = 9; i <= frameBuffer.Length; i += 10)
{ {
switch((i / 10) % 4) progress = (i / 10 % 4) switch
{ {
case 0: 0 => '-',
progress = '-'; 1 => '\\',
2 => '|',
break; 3 => '/',
case 1: _ => progress
progress = '\\'; };
break;
case 2:
progress = '|';
break;
case 3:
progress = '/';
break;
}
Console.Write($"\r{Localization.ExtractingAudio}", progress); Console.Write($"\r{Localization.ExtractingAudio}", progress);
outFs.WriteByte(frameBuffer[i]); outFs.WriteByte(frameBuffer[i]);
@@ -333,27 +300,16 @@ namespace Aaru.VideoNow
outFs = new MemoryStream(); outFs = new MemoryStream();
for(int i = 9; i <= frameBuffer.Length; i += 10) for(var i = 9; i <= frameBuffer.Length; i += 10)
{ {
switch((i / 10) % 4) progress = (i / 10 % 4) switch
{ {
case 0: 0 => '-',
progress = '-'; 1 => '\\',
2 => '|',
break; 3 => '/',
case 1: _ => progress
progress = '\\'; };
break;
case 2:
progress = '|';
break;
case 3:
progress = '/';
break;
}
Console.Write($"\r{Localization.ExtractingAudio}", progress); Console.Write($"\r{Localization.ExtractingAudio}", progress);
outFs.WriteByte(frameBuffer[i]); outFs.WriteByte(frameBuffer[i]);