Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Monkey's Audio 4.13 and filesize (Read 49861 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Monkey's Audio 4.13 and filesize

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)):
"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.
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...)


Monkey's Audio 4.13 and filesize

Reply #2
I'm not sure that I'm allowed to do this: http://www.monkeysaudio.com/license.html
Quote
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...

Re: Monkey's Audio 4.13 and filesize

Reply #3
Monkey's Audio version 4.50 addresses this.

The format still doesn't support files larger than 4GB, as the seektable entries are 32bit.
Microsoft Windows: We can't script here, this is bat country.