Added Lego Pirates of the Carribean FMV format

Also, added an error when trying to open a dll from external sources
(instead of an exception).
Auto creates Plugins directory, and copies the libraries.
This commit is contained in:
Gericom 2014-11-04 17:36:37 +01:00
parent fa363c66fb
commit 381ef84ce5
14 changed files with 1824 additions and 3 deletions

View File

@ -21,6 +21,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarioKart", "MarioKart\MarioKart.csproj", "{8117CF39-0FD6-453D-AA7F-4B4AD85EBB3A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LegoPirates", "LegoPirates\LegoPirates.csproj", "{E786AAC6-2D88-40E0-BFB6-45164A6183F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -101,6 +103,16 @@ Global
{8117CF39-0FD6-453D-AA7F-4B4AD85EBB3A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8117CF39-0FD6-453D-AA7F-4B4AD85EBB3A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8117CF39-0FD6-453D-AA7F-4B4AD85EBB3A}.Release|x86.ActiveCfg = Release|Any CPU
{E786AAC6-2D88-40E0-BFB6-45164A6183F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E786AAC6-2D88-40E0-BFB6-45164A6183F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E786AAC6-2D88-40E0-BFB6-45164A6183F9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{E786AAC6-2D88-40E0-BFB6-45164A6183F9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{E786AAC6-2D88-40E0-BFB6-45164A6183F9}.Debug|x86.ActiveCfg = Debug|Any CPU
{E786AAC6-2D88-40E0-BFB6-45164A6183F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E786AAC6-2D88-40E0-BFB6-45164A6183F9}.Release|Any CPU.Build.0 = Release|Any CPU
{E786AAC6-2D88-40E0-BFB6-45164A6183F9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E786AAC6-2D88-40E0-BFB6-45164A6183F9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E786AAC6-2D88-40E0-BFB6-45164A6183F9}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -96,6 +96,10 @@
<Content Include="Propeller_Box_Artwork_-_Super_Mario_3D_World.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>md "$(TargetDir)\Plugins"
copy "$(SolutionDir)\Libraries\*" "$(TargetDir)\Plugins"</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -25,7 +25,15 @@ namespace EveryFileExplorer.Plugins
{
continue;//This is not a .net assembly
}
Assembly ass = Assembly.LoadFile(s);
Assembly ass = null;
try
{
ass = Assembly.LoadFile(s);
}
catch(NotSupportedException e)
{
MessageBox.Show("Unblock " + AssemblyName.GetAssemblyName(s) + " from external sources!");
}
if (Plugin.IsPlugin(ass)) p.Add(new Plugin(ass));
}
Plugins = p.ToArray();

1256
LegoPirates/FMV.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E786AAC6-2D88-40E0-BFB6-45164A6183F9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LegoPirates</RootNamespace>
<AssemblyName>LegoPirates</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="NAudio">
<HintPath>..\Libraries\NAudio.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FMV.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UI\FMVViewer.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\FMVViewer.designer.cs">
<DependentUpon>FMVViewer.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LibEveryFileExplorer\LibEveryFileExplorer.csproj">
<Project>{39DBD12F-F7E3-4E9A-97A2-0722A4BA2A26}</Project>
<Name>LibEveryFileExplorer</Name>
</ProjectReference>
<ProjectReference Include="..\NDS\NDS.csproj">
<Project>{8BCF0C6C-FD8F-4446-BEA1-B8C1BE5C3389}</Project>
<Name>NDS</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="UI\FMVViewer.resx">
<DependentUpon>FMVViewer.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)\EveryFileExplorer\bin\Debug\Plugins\$(TargetFileName)"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Lego Pirates of the Carribean Plugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Every File Explorer")]
[assembly: AssemblyCopyright("Copyright © Florian Nouwt 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("58dd297a-249a-47c8-8e66-266a1615799f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

145
LegoPirates/UI/FMVViewer.cs Normal file
View File

@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace LegoPirates.UI
{
public partial class FMVViewer : Form
{
NAudio.Wave.BufferedWaveProvider AudioBuffer;
NAudio.Wave.WaveOut Player;
FMV Video;
public FMVViewer(FMV Video)
{
this.Video = Video;
InitializeComponent();
}
private void FMV_Load(object sender, EventArgs e)
{
/*double ticks = 10000000.0 / (Video.Header.FrameRate / 256.0);
float exp = (float)(ticks - Math.Floor(ticks));
if (exp != 0)
{
int i = 0;
float result;
do
{
i++;
result = exp * i;
}
while((float)(result - Math.Floor(result)) != 0);
}*/
//TODO: Calculate timing based on fps
if ((Video.Header.Flags & 4) == 4)
{
AudioBuffer = new NAudio.Wave.BufferedWaveProvider(new NAudio.Wave.WaveFormat((int)Video.Header.AudioRate, 16, 1));
AudioBuffer.DiscardOnBufferOverflow = true;
AudioBuffer.BufferLength = 8192 * 16;
Player = new NAudio.Wave.WaveOut();
Player.DesiredLatency = 150;
Player.Init(AudioBuffer);
Player.Play();
}
new System.Threading.Thread(new System.Threading.ThreadStart(delegate
{
int state = 0;
while (!stop)
{
if (Frames.Count != 0)
{
pictureBox1.Image = Frames.Dequeue();
switch (state)
{
case 0: System.Threading.Thread.Sleep(TimeSpan.FromTicks(666666)); break;
case 1: System.Threading.Thread.Sleep(TimeSpan.FromTicks(666667)); break;
case 2: System.Threading.Thread.Sleep(TimeSpan.FromTicks(666667)); break;
}
state = (state + 1) % 3;
}
}
System.Threading.Thread.CurrentThread.Abort();
})).Start();
backgroundWorker1.RunWorkerAsync();
}
int aa = 0;
int bb = 0;
bool first = true;
Queue<Bitmap> Frames = new Queue<Bitmap>();
private void FMV_FormClosing(object sender, FormClosingEventArgs e)
{
if (!stop)
{
stop = true;
if ((Video.Header.Flags & 4) == 4)
{
Player.Stop();
Player.Dispose();
Player = null;
AudioBuffer = null;
}
}
Video.Close();
}
bool stop = false;
bool stopped = false;
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
while (!stop)
{
if (Frames.Count < 8 || AudioBuffer.BufferedBytes < 8192 * 4)
{
retry:
byte[] audio;
Bitmap b = Video.GetNextFrame(out audio);
if (audio != null)
{
byte[] Return;
if (first) Return = new byte[(int)(audio.Length - 4) * 4];
else Return = new byte[audio.Length * 4];
unsafe
{
byte* buf = (byte*)Marshal.UnsafeAddrOfPinnedArrayElement(audio, 0);
byte* outbuffer = (byte*)Marshal.UnsafeAddrOfPinnedArrayElement(Return, 0);
int length = audio.Length;
if (first)
{
aa = ((short*)buf)[0];
bb = ((short*)buf)[1] & 0x7F;
((short*)outbuffer)[0] = (short)aa;
first = false;
buf += 4;
length -= 4;
outbuffer += 2;
}
NDS.SND.ADPCM.ConvertImaAdpcm(buf, length, outbuffer, ref aa, ref bb);
}
AudioBuffer.AddSamples(Return, 0, Return.Length);
goto retry;
}
if (b == null)
{
stop = true;
if ((Video.Header.Flags & 4) == 4)
{
Player.Stop();
Player.Dispose();
Player = null;
AudioBuffer = null;
}
}
else Frames.Enqueue(b);
}
}
}
}
}

70
LegoPirates/UI/FMVViewer.designer.cs generated Normal file
View File

@ -0,0 +1,70 @@
namespace LegoPirates.UI
{
partial class FMVViewer
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(422, 326);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// backgroundWorker1
//
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
//
// FMV
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(422, 326);
this.Controls.Add(this.pictureBox1);
this.Name = "FMV";
this.Text = "FMV";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FMV_FormClosing);
this.Load += new System.EventHandler(this.FMV_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.ComponentModel.BackgroundWorker backgroundWorker1;
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
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.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>268, 17</value>
</metadata>
</root>

View File

@ -30,6 +30,7 @@ namespace LibEveryFileExplorer.Files
protected const String Category_Shaders = "Shaders";
protected const String Category_Strings = "Strings";
protected const String Category_Textures = "Textures";
protected const String Category_Videos = "Videos";
public abstract String GetCategory();
public abstract String GetFileDescription();

BIN
Libraries/NAudio.dll Normal file

Binary file not shown.

View File

@ -1 +0,0 @@
Put these 2 dll files in the plugins directory of efe!

View File

@ -21,7 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -70,6 +70,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resource.resx</DependentUpon>
</Compile>
<Compile Include="SND\ADPCM.cs" />
<Compile Include="UI\MDL0MaterialEditor.cs">
<SubType>UserControl</SubType>
</Compile>

82
NDS/SND/ADPCM.cs Normal file
View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NDS.SND
{
//Tempoarly from mkdscm
//I need to rewrite this all
public class ADPCM
{
private static int[] indexTable =
{ -1, -1, -1, -1, 2, 4, 6, 8,
-1, -1, -1, -1, 2, 4, 6, 8 };
private static int[] stepsizeTable =
{ 7, 8, 9, 10, 11, 12, 13, 14,
16, 17, 19, 21, 23, 25, 28,
31, 34, 37, 41, 45, 50, 55,
60, 66, 73, 80, 88, 97, 107,
118, 130, 143, 157, 173, 190, 209,
230, 253, 279, 307, 337, 371, 408,
449, 494, 544, 598, 658, 724, 796,
876, 963, 1060, 1166, 1282, 1411, 1552,
1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026,
4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
9493, 10442, 11487, 12635, 13899, 15289, 16818,
18500, 20350, 22385, 24623, 27086, 29794, 32767 };
public unsafe static void ConvertImaAdpcm(byte* buf, int length, byte* outbuffer)
{
int a = ((short*)buf)[0];
int b = ((short*)buf)[1] & 0x7F;
((short*)outbuffer)[0] = (short)a;
ConvertImaAdpcm(buf + 4, length - 4, outbuffer + 2, ref a, ref b);
}
public unsafe static void ConvertImaAdpcm(byte* buf, int length, byte* outbuffer, ref int decompSample, ref int stepIndex)
{
uint destOff = 0;
uint curOffset = 0;
byte compByte;
while (curOffset < length)
{
compByte = buf[curOffset++];
process_nibble(compByte, ref stepIndex, ref decompSample);
((short*)outbuffer)[destOff++] = (short)decompSample;
process_nibble((byte)((compByte & 0xF0) >> 4), ref stepIndex, ref decompSample);
((short*)outbuffer)[destOff++] = (short)decompSample;
}
}
private static int IMAMax(int samp) { return (samp > 0x7FFF) ? ((short)0x7FFF) : samp; }
private static int IMAMin(int samp) { return (samp < -0x7FFF) ? ((short)-0x7FFF) : samp; }
private static int IMAIndexMinMax(int index, int min, int max) { return (index > max) ? max : ((index < min) ? min : index); }
private static void process_nibble(byte data4bit, ref int Index, ref int Pcm16bit)
{
int Diff = stepsizeTable[Index] / 8;
if ((data4bit & 1) != 0) Diff = Diff + stepsizeTable[Index] / 4;
if ((data4bit & 2) != 0) Diff = Diff + stepsizeTable[Index] / 2;
if ((data4bit & 4) != 0) Diff = Diff + stepsizeTable[Index] / 1;
if ((data4bit & 8) == 0) Pcm16bit = IMAMax(Pcm16bit + Diff);
if ((data4bit & 8) == 8) Pcm16bit = IMAMin(Pcm16bit - Diff);
Index = IMAIndexMinMax(Index + indexTable[data4bit & 7], 0, 88);
}
private static void clamp_step_index(ref int stepIndex)
{
if (stepIndex < 0) stepIndex = 0;
if (stepIndex > 88) stepIndex = 88;
}
private static void clamp_sample(ref int decompSample)
{
if (decompSample < -32768) decompSample = -32768;
if (decompSample > 32767) decompSample = 32767;
}
}
}