melonDS-emu / melonDS

DS emulator, sorta
https://melonds.kuribo64.net
GNU General Public License v3.0
3.32k stars 545 forks source link

[Feature Request] CHD support #642

Open Sanaki opened 4 years ago

Sanaki commented 4 years ago

While MAME's CHD format is generally used in libretro cores for optical disc images, the format is also capable of handling HDD compression. It has a number of general advantages, the most relevant for DS (in my opinion) being that it's directly seekable while staying compressed. Loading larger games from within max compression 7z on 5200 RPM HDDs, USB externals, or SD cards can take an unpleasantly long time.

On a whim, I decided to test the largest DS game I'm personally in possession of (Ni No Kuni, 512MiB, english patched in this case). I also verified it reverses back to a perfect copy, so no data is being discarded in the conversion process.

Logical size: 536,870,912 bytes
CHD size:     388,270,315 bytes
Ratio:        72.3%

     Hunks  Percent  Name
----------  -------  ------------------------------------
     5,998     4.6%  Uncompressed
    12,338     9.4%  Copy from self
    43,163    32.9%  LZMA
     9,237     7.0%  Deflate
    53,403    40.7%  Huffman
     6,933     5.3%  FLAC

327.5MiB as max compression lzma2 7z. 370.3MiB as chd. Support for this format is available via the libchdr library.

While my personal priority is seeing this in the libretro version, I'm submitting the issue here because I believe it could be beneficial here as well. If you disagree, I'd be happy to move the issue to the libretro repo.

RSDuck commented 4 years ago

I wonder though how many people have their DS roms compressed in the chd format?

~Also afaik we can't link with libchdr because it's license is incompatible with ours.~ Forget about this, it's 3-clause, not 4-clause BSD.

crazynoob458 commented 4 years ago

But why ds games are small

Sanaki commented 4 years ago

I doubt any have them compressed that way already. I didn't even know it was possible until I tried it yesterday. This would be a feature moving forward for DS, not support added for a format already in use in this fashion.

As for them being small, some are, yes. I wouldn't worry about compressing something like "Yoshi's Touch & Go", at 16MiB. But when you get up to half a gig for a game, you start to feel load speed issues and size constraints much easier.

RSDuck commented 4 years ago

still zip and 7zip are more common and acessible formats, which is why I give them higher priority. We'll see about this one.

Sanaki commented 4 years ago

Yeah, of course. Those should definitely have priority. The goal is user utility. Zip and 7z have worse performance, but are significantly more accessible. It's not a cut and dry benefit like you get with CD formats.

lonkelle commented 2 years ago

My favorite feature about this request is that it's instantly seekable meaning no load times when starting games. Good to know the popular CHD format has an HDD mode. Hope this gets implemented for sure in the future.