bugfix for ape

This commit is contained in:
chudov
2008-11-09 14:01:15 +00:00
parent da7fe1edfe
commit 2fbcf9575e
3 changed files with 78 additions and 4 deletions

View File

@@ -156,8 +156,8 @@ namespace APEDotNet {
array<Int32,2>^ _sampleBuffer = gcnew array<Int32,2> (nBlocksRetrieved, 2);
interior_ptr<Int32> pMyBuffer = &_sampleBuffer[0, 0];
unsigned short * pAPEBuffer = (unsigned short *) pBuffer;
unsigned short * pAPEBufferEnd = (unsigned short *) pBuffer + 2 * nBlocksRetrieved;
short * pAPEBuffer = (short *) pBuffer;
short * pAPEBufferEnd = (short *) pBuffer + 2 * nBlocksRetrieved;
while (pAPEBuffer < pAPEBufferEnd) {
*(pMyBuffer++) = *(pAPEBuffer++);
@@ -327,4 +327,39 @@ namespace APEDotNet {
_initialized = true;
}
};
#if 0
extern "C"
{
BOOL GetMMXAvailable();
int CalculateDotProduct8(const short* pA, const short* pB, int nOrder);
};
public ref class SSE2Functions
{
public:
SSE2Functions ()
{
_haveSSE2 = GetMMXAvailable();
}
int SumInts (short*a, short*b, int count)
{
if (_haveSSE2 && count == 8)
return CalculateDotProduct8(a, b, count);
int sum = 0;
for (int j = 0; j < count; j++)
sum += a[j] * b[j];
return sum;
}
int SumInts (int*a, short*b, int count)
{
int sum = 0;
for (int j = 0; j < count; j++)
sum += a[j] * b[j];
return sum;
}
private:
bool _haveSSE2;
};
#endif
}

View File

@@ -327,8 +327,10 @@ namespace CUEToolsLib {
copyCount = Math.Min(samplesNeeded, SamplesInBuffer);
APESamplesToFLACSamples(_sampleBuffer, _bufferOffset, buff, buffOffset,
copyCount, chanCount);
Array.Copy(_sampleBuffer, _bufferOffset * chanCount, buff, buffOffset * chanCount, copyCount * chanCount);
//APESamplesToFLACSamples(_sampleBuffer, _bufferOffset, buff, buffOffset,
// copyCount, chanCount);
samplesNeeded -= copyCount;
buffOffset += copyCount;

View File

@@ -232,6 +232,7 @@ namespace CUEToolsLib
public bool decodeHDCD;
public bool wait750FramesForHDCD;
public bool createM3U;
public bool createTOC;
public bool createCUEFileWhenEmbedded;
public bool truncate4608ExtraSamples;
public bool processPriorityIdle;
@@ -272,6 +273,7 @@ namespace CUEToolsLib
wait750FramesForHDCD = true;
decodeHDCD = false;
createM3U = false;
createTOC = false;
createCUEFileWhenEmbedded = false;
truncate4608ExtraSamples = true;
processPriorityIdle = true;
@@ -313,6 +315,7 @@ namespace CUEToolsLib
sw.Save("Wait750FramesForHDCD", wait750FramesForHDCD);
sw.Save("DecodeHDCD", decodeHDCD);
sw.Save("CreateM3U", createM3U);
sw.Save("CreateTOC", createTOC);
sw.Save("CreateCUEFileWhenEmbedded", createCUEFileWhenEmbedded);
sw.Save("Truncate4608ExtraSamples", truncate4608ExtraSamples);
sw.Save("ProcessPriorityIdle", processPriorityIdle);
@@ -354,6 +357,7 @@ namespace CUEToolsLib
wait750FramesForHDCD = sr.LoadBoolean("Wait750FramesForHDCD") ?? true;
decodeHDCD = sr.LoadBoolean("DecodeHDCD") ?? false;
createM3U = sr.LoadBoolean("CreateM3U") ?? false;
createTOC = sr.LoadBoolean("CreateTOC") ?? false;
createCUEFileWhenEmbedded = sr.LoadBoolean("CreateCUEFileWhenEmbedded") ?? false;
truncate4608ExtraSamples = sr.LoadBoolean("Truncate4608ExtraSamples") ?? true;
processPriorityIdle = sr.LoadBoolean("ProcessPriorityIdle") ?? true;
@@ -988,6 +992,25 @@ namespace CUEToolsLib
}
}
public void WriteTOC(string path)
{
StreamWriter sw = new StreamWriter(path, false, CUESheet.Encoding);
WriteTOC(sw);
sw.Close();
}
public void WriteTOC(TextWriter sw)
{
uint trackOffset = 150;
for (int iTrack = 0; iTrack < TrackCount; iTrack++)
{
trackOffset += _tracks[iTrack].IndexLengths[0];
WriteLine(sw, 0, "\t" + trackOffset);
for (int iIndex = 1; iIndex <= _tracks[iTrack].LastIndex; iIndex++)
trackOffset += _tracks[iTrack].IndexLengths[iIndex];
}
}
public void Write(string path, CUEStyle style) {
StringWriter sw = new StringWriter();
Write(sw, style);
@@ -1367,6 +1390,8 @@ namespace CUEToolsLib
sw.WriteLine("Assuming a data track was present, length {0}.", General.TimeToString(_dataTrackLength.Value));
else
{
if (_cddbDiscIdTag != null && _accurateRipId.Split('-')[2].ToUpper() != _cddbDiscIdTag.ToUpper())
sw.WriteLine("CDDBId mismatch: {0} vs {1}", _cddbDiscIdTag.ToUpper(), _accurateRipId.Split('-')[2].ToUpper());
if (_minDataTrackLength.HasValue)
sw.WriteLine("Data track was probably present, length {0}-{1}.", General.TimeToString(_minDataTrackLength.Value), General.TimeToString(_minDataTrackLength.Value + 74));
if (_accurateRipIdActual != _accurateRipId)
@@ -1608,6 +1633,12 @@ namespace CUEToolsLib
GenerateAccurateRipLog(sw);
sw.Close();
}
if (_config.createTOC)
{
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
WriteTOC(Path.ChangeExtension(_cuePath, ".toc"));
}
return;
}
}
@@ -1704,6 +1735,12 @@ namespace CUEToolsLib
GenerateAccurateRipLog(sw);
sw.Close();
}
if (_config.createTOC)
{
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
WriteTOC(Path.ChangeExtension(_cuePath, ".toc"));
}
}
}