The latest Monkey's Audio encoder supports WAV files greater than 2 GB. So, the limit of input file size was raised from 2GB to 4GB.
This means that MAC can create APE files greater than 2GB, and it seems that even the latest 4.13 SDK doesn't like such files.
foobar2000 can decode the resulting big APE files without problems, but it cannot seek to the end of them:
Decoding failure at 5:35:32.119 (Unsupported format or corrupted file (1002)):
"D:\test\Image.ape"
And Winamp (+in_APE.dll) also can decode but cannot seek to the end (it simply crashes).
I compiled in_APE.dll myself, then tried to debug it.
The following patch fixes this problem and allows Winamp to seek to the end of such big files.
diff --git a/MAC_SDK_413/Source/MACLib/APEDecompress.cpp b/MAC_SDK_413/Source/MACLib/APEDecompress.cpp
index 3d09b84..84262ac 100644
--- a/MAC_SDK_413/Source/MACLib/APEDecompress.cpp
+++ b/MAC_SDK_413/Source/MACLib/APEDecompress.cpp
@@ -426,7 +426,7 @@ Seek to the proper frame (if necessary) and do any alignment of the bit array
*****************************************************************************************/
int CAPEDecompress::SeekToFrame(int nFrameIndex)
{
- int nSeekRemainder = (GetInfo(APE_INFO_SEEK_BYTE, nFrameIndex) - GetInfo(APE_INFO_SEEK_BYTE, 0)) % 4;
+ int nSeekRemainder = ((unsigned)GetInfo(APE_INFO_SEEK_BYTE, nFrameIndex) - (unsigned)GetInfo(APE_INFO_SEEK_BYTE, 0)) % 4;
return m_spUnBitArray->FillAndResetBitArray(GetInfo(APE_INFO_SEEK_BYTE, nFrameIndex) - nSeekRemainder, nSeekRemainder * 8);
}
diff --git a/MAC_SDK_413/Source/Shared/WinFileIO.cpp b/MAC_SDK_413/Source/Shared/WinFileIO.cpp
index 58408bd..6b76cf8 100644
--- a/MAC_SDK_413/Source/Shared/WinFileIO.cpp
+++ b/MAC_SDK_413/Source/Shared/WinFileIO.cpp
@@ -99,7 +99,11 @@ int CWinFileIO::Write(const void * pBuffer, unsigned int nBytesToWrite, unsigned
int CWinFileIO::Seek(int nDistance, unsigned int nMoveMode)
{
- SetFilePointer(m_hFile, nDistance, NULL, nMoveMode);
+ LONG high = 0;
+ if(nMoveMode == FILE_BEGIN)
+ SetFilePointer(m_hFile, nDistance, &high, nMoveMode); /* treat nDistance as unsigned */
+ else
+ SetFilePointer(m_hFile, nDistance, NULL, nMoveMode);
return 0;
}
(the plugin still reports negative file sizes and compression level, but it's not a big problem for me...)