mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
CUETools 2.1.1
* Local Database for verification results and metadata * FlaCuda replaced with FLACCL
This commit is contained in:
@@ -190,6 +190,69 @@ namespace CUETools.TestCodecs
|
||||
Assert.AreEqual<uint>(2012115554, ar2.CRC450(1, 55), "CRC450[1,55] was not set correctly.");
|
||||
Assert.AreEqual<uint>(1483829604, ar2.CRC450(1, -3), "CRC450[1,-3] was not set correctly.");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///OffsetSafeCRCRecord
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void OffsetSafeCRCRecordTest()
|
||||
{
|
||||
OffsetSafeCRCRecord[] records = new OffsetSafeCRCRecord[5000];
|
||||
for (int i = 0; i < records.Length; i++)
|
||||
{
|
||||
var arv = new AccurateRipVerify(toc, null);
|
||||
Random rnd = new Random(2314);
|
||||
Random rnd2 = new Random(2314);
|
||||
for (int k = 0; k < i; k++)
|
||||
{
|
||||
rnd.Next(-32768, 32767);
|
||||
rnd.Next(-32768, 32767);
|
||||
}
|
||||
int chunk;
|
||||
for (int k = 0; k < toc.AudioLength * 588; k += chunk)
|
||||
{
|
||||
chunk = Math.Min(512 + rnd2.Next(512), (int)toc.AudioLength * 588 - k);
|
||||
AudioBuffer buff = new AudioBuffer(AudioPCMConfig.RedBook, chunk);
|
||||
buff.Length = chunk;
|
||||
for (int s = 0; s < chunk; s++)
|
||||
{
|
||||
buff.Samples[s, 0] = rnd.Next(-32768, 32767);
|
||||
buff.Samples[s, 1] = rnd.Next(-32768, 32767);
|
||||
}
|
||||
arv.Write(buff);
|
||||
}
|
||||
records[i] = arv.OffsetSafeCRC;
|
||||
arv.Close();
|
||||
}
|
||||
|
||||
for (int i = 0; i < records.Length; i++)
|
||||
{
|
||||
int real_off = -i;
|
||||
int off;
|
||||
bool found = records[0].FindOffset(records[i], out off);
|
||||
if (real_off > 4096 || real_off < -4096)
|
||||
{
|
||||
Assert.IsFalse(found, string.Format("FindOffset found offset where it shouldn't have, real offset {0}", real_off));
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsTrue(found, string.Format("FindOffset failed to detect offset, real offset {0}", real_off));
|
||||
Assert.AreEqual(real_off, off, string.Format("FindOffset returned {0}, should be {1}", off, real_off));
|
||||
}
|
||||
real_off = i;
|
||||
found = records[i].FindOffset(records[0], out off);
|
||||
if (real_off > 4096 || real_off < -4096)
|
||||
{
|
||||
Assert.IsFalse(found, string.Format("FindOffset found offset where it shouldn't have, real offset {0}", real_off));
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsTrue(found, string.Format("FindOffset failed to detect offset, real offset {0}", real_off));
|
||||
Assert.AreEqual(real_off, off, string.Format("FindOffset returned {0}, should be {1}", off, real_off));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -30,6 +31,7 @@
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CSScriptLibrary.v1.1, Version=2.3.2.0, Culture=neutral">
|
||||
|
||||
@@ -99,7 +99,55 @@ namespace CUETools.TestCodecs
|
||||
CollectionAssert.AreEqual(File.ReadAllBytes("flake.flac"), File.ReadAllBytes("flakewriter1.flac"), "flakewriter1.flac doesn't match.");
|
||||
}
|
||||
|
||||
public static unsafe void
|
||||
compute_schur_reflection(/*const*/ double* autoc, uint max_order,
|
||||
double* dreff/*[][MAX_LPC_ORDER]*/, double* err)
|
||||
{
|
||||
float* gen0 = stackalloc float[lpc.MAX_LPC_ORDER];
|
||||
float* gen1 = stackalloc float[lpc.MAX_LPC_ORDER];
|
||||
|
||||
// Schur recursion
|
||||
for (uint i = 0; i < max_order; i++)
|
||||
gen0[i] = gen1[i] = (float)autoc[i + 1];
|
||||
float error = (float)autoc[0];
|
||||
|
||||
for (uint i = 0; i < max_order; i++)
|
||||
{
|
||||
float reff = -gen1[0] / error;
|
||||
error += gen1[0] * reff;
|
||||
|
||||
for (uint j = 0; j < max_order - i - 1; j++)
|
||||
{
|
||||
gen1[j] = gen1[j + 1] + reff * gen0[j];
|
||||
gen0[j] = gen1[j + 1] * reff + gen0[j];
|
||||
}
|
||||
|
||||
dreff[i] = reff;
|
||||
err[i] = error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[TestMethod()]
|
||||
public unsafe void LPCTest()
|
||||
{
|
||||
double* autoc = stackalloc double[9];
|
||||
double* reff = stackalloc double[8];
|
||||
double* err = stackalloc double[8];
|
||||
float* lpcs = stackalloc float[9 * lpc.MAX_LPC_ORDER];
|
||||
autoc[0] = 177286873088.0;
|
||||
autoc[1] = 177010016256.0;
|
||||
autoc[2] = 176182624256.0;
|
||||
autoc[3] = 174806581248.0;
|
||||
autoc[4] = 172888768512.0;
|
||||
autoc[5] = 170436820992.0;
|
||||
autoc[6] = 167460765696.0;
|
||||
autoc[7] = 163973169152.0;
|
||||
autoc[8] = 159987859456.0;
|
||||
|
||||
compute_schur_reflection(autoc, 8, reff, err);
|
||||
lpc.compute_lpc_coefs(8, reff, lpcs);
|
||||
Assert.IsTrue(lpcs[7 * lpc.MAX_LPC_ORDER] < 3000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user