Skip to main content

Topic: Monkey's Audio 4.13 and filesize (Read 1604 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • lvqcl
  • [*][*][*][*][*]
  • Developer
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...)

  • Brazil2
  • [*][*][*]
Monkey's Audio 4.13 and filesize
Reply #1
I compiled in_APE.dll myself

It would be nice to share a patched build

  • lvqcl
  • [*][*][*][*][*]
  • Developer
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...