Unpack ECM files on the fly

May 30, 2016 at 5:11 PM
Edited May 30, 2016 at 5:16 PM
I find it annoying that I have to run unecm to uncompress ecm files before I can use them.

To sort that out I have created a simple "unecm" overlay filesystem based on FUSE.
Basically, it will automatically translate all ECM files into their uncompressed counterpart as PCSX tries to read/access the individual blocks.


Based on FUSE so it only works on platforms that have FUSE.

The un-ecm support is in :
It is heavily based on Neill Corlett unecm.c .

The meat of the changes are for tracking metadata and to support reading/uncompressing data at random offsets on the fly.

It would be even neater if PCSX would have built-in support for reading ECM files.
If you are interested in that, see libunecm.c, and how it is used from the fuse module, for how to read/uncompress data from random offsets into the file.
May 31, 2016 at 4:25 PM
The support has been there for some time. Check cdriso.c


F.e. just launch pcsxr from command line giving .ecm as cdfile param.

./pcsxr -cdfile gamez.ecm
Jun 28, 2016 at 6:22 PM
Jun 28, 2016 at 6:25 PM
Nice. However, my mistake was that I am/was using PCSX, not PCSXR, and PCSX does not have ECM support :-( The number of PSX emulators and how they relate to eachother is confusing to me :-) A small drawback in cdriso.c is that it appears to build the index
on the fly by reading sequentially through the file until it gets to the desired offset. That may have a small performance impact for some games. (reading through hundreds of MB in order to build the index will take many seconds on say a RPI accessing data
on a slow network share). In my solution I create a precomputed index which I store in a separate file alongside the ecm. This means that opening the file and startup is instant. I also have second fuse module for transparently unpacking BGZIP files (indexed
gzip files). With these two fuse filesystems I can then first compress the disk images using ecm-compress (and creating an index using ecm-index) and then as a second step run bgzip -i to compress the files even further. With the two fuse modules it means
that I can access and play the games even when using emulators that do not support neither ecm of bgzip formats, wooohooo! Being able to both ecm compress and then bgzip the files means I save a lot storage space.