Lossless Audio Compression => Lossless / Other Codecs => Topic started by: lvqcl on 2015-02-07 23:20:17

Title: Monkey's Audio 4.13 and filesize
Post by: lvqcl on 2015-02-07 23:20:17
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:
Code: [Select]
Decoding failure at 5:35:32.119 (Unsupported format or corrupted file (1002)):
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.
Code: [Select]
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...)
Title: Monkey's Audio 4.13 and filesize
Post by: Brazil2 on 2015-02-08 09:48:23
I compiled in_APE.dll myself

It would be nice to share a patched build
Title: Monkey's Audio 4.13 and filesize
Post by: lvqcl on 2015-02-08 10:09:35
I'm not sure that I'm allowed to do this: http://www.monkeysaudio.com/license.html (http://www.monkeysaudio.com/license.html)
3. The redistribution of Monkey's Audio is only allowed in cases where the original installer and components therein have not been modified.

Besides, the size of the original in_APE.dll is 440kB, and my version is 2MB long. I don't know why.

P.S. I wonder what other lossless codecs do for very long files (1GB, 3GB, 5GB input; 1GB, 3GB, 5GB output; 1G, 3G, 5G samples). Maybe I'll test it someday...
Title: Re: Monkey's Audio 4.13 and filesize
Post by: Peter on 2019-03-01 16:20:42
Monkey's Audio version 4.50 addresses this.

The format still doesn't support files larger than 4GB, as the seektable entries are 32bit.