CDI Image File Format

I'm new to DC homebrew and I've been using cdrecord and documentation from Marcus Comstedt's site to write homebrew software to CD-Rs and run them on my Dreamcast. I recently picked up a GDEMU and I would like to write my homebrew to a CDI image file so I can run it on my GDEMU and in an emulator.

I haven't been able to find any documentation on the CDI file format and I've noticed that tools such as GD-ROM Explorer know how to parse these files but they lack source. Does anyone have any info or do I just need to hexdump some CDI files and figure it out on my own?

To be clear I'm look for info on the file format (or source code to something that understands CDI), not for pre-made tools that can read/write CDIs.

Thanks in advance
CDI is closed format.
In attach all source what i have
More source you can find in source code lxdrean
Thanks so much! and indeed the lxdream repo appears to have some useful code as well. I'm in a much better place than I was moments ago when I was comparing hexdumps of cdi files.
Thanks again.
You can mount cdi in daemon tools too.

Libmirage supports reading cdi too. Find it on GitHub.

If you want to create selfboot images, my Selfboot pack generates nrg files that can be mounted in daemon tools and imaged into cdi via discjuggler.

Gditools can also extracts some cdi files but it's experimental, only 11702 lba is supported so far. The experimental script can be found on the hldc-dev forum.

Presently, the format is understood enough to extract them, but creating valid ones is more tedious.

An open source tool to build them would be a great plus for the community indeed.
https://bitbucket.org/bogglez/lxdream/src
A shame its stopped development for so long. was a nice thing.

Original thread: https://assemblergames.com/threads/cdi-image-file-format.62808/