Over the last few weeks I have been preparing for a source code release of the CD-i base case audio and video decoder functionality from CD-i Emulator (https://www.cdiemu.org) in the form of two of its generic controller classes (excluding the specific chip emulations) and supporting infrastructure.
CD-i Emulator is written in C++98 and currently uses Visual Studio 2010 as its compiler. This source code release will be done on GitHub under the LGPL version 2.1 license; based on number of source lines this release comprises about 15% of the current CD-i Emulator source code.
Controller classes
The CCdiAudio controller class is capable of decoding all CD-i ADPCM formats (levels A/B/C, both mono and stereo) into 16-bit PCM format, with optional upsampling to a 44.1 kHZ sample rate; it also supports 44.1 kHz stereo passthrough for Compact Disc Digital Audio (CDDA). The minimum decoding unit for ADPCM is the 128-byte Sound Group. The controller also supports mixing with external audio; in a typical CD-i player this would be decoded MPEG audio from the Digital Video Cartridge (DVC).
The CCdiVideo controller class is capable of decoding all CD-i image formats (CLUT, RL, DYUV and RGB555) into various RGB formats, with full processing of the two-plane Display Control Program (DCP) supporting all CD-i video effects such as overlay, transparency, mixing, regions and mosaics and the cursor plane. The minimal decoding unit is the display line. The controller also supports mixing with external video; in a typical CD-i player this would be decoded MPEG video from the DVC.
These two controller classes together contain a little over 6000 Lines of Code (6 kLoC) or about 25% of this source code release. A large majority of the rest is utility and interface classes; keep in mind that this code is all lifted from CD-i Emulator as is and therefore contains more functionality then strictly needed for the use-cases discussed below.
Use-cases
The primary use-case for this source code release is to serve as a reference and toolkit for decoding the CD-i audio and video formats as described in the Green Book, hopefully easing the work of current and future writers of CD-i emulators, tools, and applications.
The generic controller classes and the other classes can also be used in other projects, thereby saving development time, provided their licenses are compatible with the LGPL.
However, I want this source code release to be more directly useful so I am spicing up my existing cdiconv program for converting CD-i audio and video files into PCM and RGB formats and will include that in the release. The program already takes "raw" CD-i audio and video data but especially the latter does not capture the full richness of CD-i video decoding with its multiple planes of video data and the Display Control Program (DCP).
To remedy this I am adding a mode to the cdiconv program where it can simply decode the current image from a full CD-i video memory dump file; such dumps are easily generated from any CD-i emulator by just writing out both 512 KB banks of video memory in big-endian byte order. This can be used to validate decoder implementations; it is also easier to debug decoder issues outside the framework of a CD-i emulator.
Of course the cdiconv program can also be used for decoding assets from an existing CD-i title after these assets have been extracted from the disc image using other tools.
CD-i Emulator
To create video memory dumps with CD-i Emulator, select Emulate | Dump from the menu, press its keyboard shortcut Ctrl-F12 or use the new debugger command "ex dump". A video memory dump will be written to the dump directory, much like Emulate | Snapshot or F12 writes a snaphot image in PNG format to the snap directory.
The dump function can actually be used to dump any CD-i memory area by using the new -dumpfilter option or passing an additional parameter to the "ex dump" command; the default for the filter parameter is "planea;planeb" which selects the two video memory areas. In the future this will be extended to a generic state save facility.
Two files are actually written by CD-i Emulator:
- a .dmp file containing textual meta information about the dump
- a .dat file containing the binary data from the memory areas
No comments:
Post a Comment