mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
CUETools.Codecs.ALAC: fix a bug that was causing corruption of the last 4 bytes in some files.
This commit is contained in:
8
CUETools.ALACEnc/App.config
Normal file
8
CUETools.ALACEnc/App.config
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<probing privatePath="plugins"/>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -36,7 +36,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -88,6 +88,9 @@
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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.
|
||||
|
||||
@@ -492,14 +492,16 @@ namespace CUETools.Codecs.ALAC
|
||||
res[0] = smp[0];
|
||||
for (int i = 1; i < n; i++)
|
||||
res[i] = smp[i] - smp[i - 1];
|
||||
}
|
||||
res[n] = 1; // Stop byte to help alac_entropy_coder;
|
||||
}
|
||||
|
||||
unsafe static void alac_encode_residual_0(int* res, int* smp, int n)
|
||||
unsafe static void alac_encode_residual_0(int* res, int* smp, int n)
|
||||
{
|
||||
AudioSamples.MemCpy(res, smp, n);
|
||||
}
|
||||
res[n] = 1; // Stop byte to help alac_entropy_coder;
|
||||
}
|
||||
|
||||
unsafe static void alac_encode_residual(int* res, int* smp, int n, int order, int* coefs, int shift, int bps)
|
||||
unsafe static void alac_encode_residual(int* res, int* smp, int n, int order, int* coefs, int shift, int bps)
|
||||
{
|
||||
int csum = 0;
|
||||
|
||||
@@ -838,35 +840,32 @@ namespace CUETools.Codecs.ALAC
|
||||
}
|
||||
}
|
||||
|
||||
unsafe void encode_residual(ALACFrame frame, int ch, int pass, int best_windows)
|
||||
{
|
||||
int* smp = frame.subframes[ch].samples;
|
||||
int i, n = frame.blocksize;
|
||||
unsafe void encode_residual(ALACFrame frame, int ch, int pass, int best_windows)
|
||||
{
|
||||
int* smp = frame.subframes[ch].samples;
|
||||
int i, n = frame.blocksize;
|
||||
int bps = Settings.PCM.BitsPerSample + Settings.PCM.ChannelCount - 1;
|
||||
|
||||
// FIXED
|
||||
//if (0 == (2 & frame.subframes[ch].done_fixed) && (pass != 1 || n < eparams.max_prediction_order))
|
||||
//{
|
||||
// frame.subframes[ch].done_fixed |= 2;
|
||||
// frame.current.order = 31;
|
||||
// frame.current.window = -1;
|
||||
// alac_encode_residual_31(frame.current.residual, frame.subframes[ch].samples, frame.blocksize);
|
||||
// frame.current.size = (uint)(alac_entropy_coder(frame.current.residual, frame.blocksize, bps, out frame.current.ricemodifier) + 16);
|
||||
// frame.ChooseBestSubframe(ch);
|
||||
//}
|
||||
//if (0 == (1 & frame.subframes[ch].done_fixed) && (pass != 1 || n < eparams.max_prediction_order))
|
||||
//{
|
||||
// frame.subframes[ch].done_fixed |= 1;
|
||||
// frame.current.order = 0;
|
||||
// frame.current.window = -1;
|
||||
// alac_encode_residual_0(frame.current.residual, frame.subframes[ch].samples, frame.blocksize);
|
||||
// frame.current.size = (uint)(alac_entropy_coder(frame.current.residual, frame.blocksize, bps, out frame.current.ricemodifier) + 16);
|
||||
// frame.ChooseBestSubframe(ch);
|
||||
//}
|
||||
|
||||
// LPC
|
||||
if (n < eparams.max_prediction_order)
|
||||
return;
|
||||
// FIXED
|
||||
//if (0 == (2 & frame.subframes[ch].done_fixed) && (pass != 1 || n < eparams.max_prediction_order))
|
||||
//{
|
||||
// frame.subframes[ch].done_fixed |= 2;
|
||||
// frame.current.order = 31;
|
||||
// frame.current.window = -1;
|
||||
// alac_encode_residual_31(frame.current.residual, frame.subframes[ch].samples, frame.blocksize);
|
||||
// frame.current.size = (uint)(alac_entropy_coder(frame.current.residual, frame.blocksize, bps, out frame.current.ricemodifier) + 16);
|
||||
// frame.ChooseBestSubframe(ch);
|
||||
//}
|
||||
//if (0 == (1 & frame.subframes[ch].done_fixed) && (pass != 1 || n < eparams.max_prediction_order))
|
||||
if (0 == (1 & frame.subframes[ch].done_fixed) && n < eparams.max_prediction_order)
|
||||
{
|
||||
frame.subframes[ch].done_fixed |= 1;
|
||||
frame.current.order = 0;
|
||||
frame.current.window = -1;
|
||||
alac_encode_residual_0(frame.current.residual, frame.subframes[ch].samples, frame.blocksize);
|
||||
frame.current.size = (uint)(alac_entropy_coder(frame.current.residual, frame.blocksize, bps, out frame.current.ricemodifier) + 16);
|
||||
frame.ChooseBestSubframe(ch);
|
||||
}
|
||||
|
||||
float* lpcs = stackalloc float[lpc.MAX_LPC_ORDER * lpc.MAX_LPC_ORDER];
|
||||
int min_order = eparams.min_prediction_order;
|
||||
|
||||
Reference in New Issue
Block a user