One game, two rare-letter formats

As I’m still in a search for formats to implement in na_game_tool for 0.4.0 release, one game brought two formats at one—and both start with a letter I had only one or two formats before.

I’m talking about ID4 or Independence Day. Its Sega Saturn port uses EGG format which has not been REd before. But first I was able to locate PC version of the game with its animations in YQS format, so I started with it.

It turned out to be a very curious format, with YUV frame coded per plane using quadtree and two separate streams for pixel values and for control bits, eight streams in total (there’s IMA ADPCM audio as well and fixed-size vector codebook for luma). Essentially plane is split into 8×8 (luma) or 4×4 (chroma) blocks which may be skipped entirely (if the control bit is not set), filled with single value obtained from the stream (again, if the next control bit is not set) or split into four sub-blocks with the similar approach. 2×2 chroma blocks may be skipped, filled or coded raw; 2×2 luma blocks additionally may use input pixel value as a codebook index and use that 2×2 vector (flipped or not, depending on control bits).

After that I actually looked at EGG. It had similar structure but with some changes: frames are always 20kB and do not contain audio, values are big-endian and bitstream format for 2×2 luma blocks differs. I still had to resort to the binary specification for it though—loaded CPE file in Ghidra as raw SH-2 binary, located animation names and started attempts to disassemble data around them. Eventually I got the function that looked very similar to the one in PC version (except that it decoded just luma instead of doing all three components and converting macroblock to RGB). Thus I got a working decoder for this format as well.

That’s how I got two more formats supported, which makes it almost 42% of my goal. The problem is still mostly to locate the formats that can be supported (most of the ones I haven’t implemented need a lot of work to unpack the binary specification). In either case I’m in no hurry and it was nice to learn more about old formats.

6 Responses to “One game, two rare-letter formats”

  1. Paul says:

    What a catchy title name. Multimedia (slowed) progress still presented in 2D.
    What encoding format and algorithms to use for fast and compact real 3D video storage?
    I need fresh news with new coding techniques, not new-old rehashed stories.

  2. Kostya says:

    I guess you need some other source for those news, this is a blog about (old) boring codecs, not new and exciting ones.

    And 3D can be done in many different ways: just encoding full surroundings and let you browse it (QTVR did it back in 1990s, new H.26x codecs support such coding mode out of the box); encode 3D models, textures and affine transforms on those (MPEG-4 did it, but normally it’s done as multiple assets for some 3D engine); MPEG also explored a standard on coding point cloud…

    I guess this is why you prefer filters, things must be more exciting there.

  3. Paul says:

    Real 3d is volumetric video, and needs volumetric display too.
    Now that everything is taken out by machine models exciting filters time are over too.

  4. Kostya says:

    Well, that explains it then—as I don’t have such hardware I don’t pay much interest to its development. And even cheap substitutes like plenoptics are too much for me.

    As for filters and AI, it has a certain appeal: you can not merely synthesise a filters, but also a long-winded documents praising it and explaining why it does what is needed to be done (even if your sensory organs claim otherwise). That’s why I’m dealing mostly with the old codecs, hopefully you can find another hobby for yourself too if the need arises.

  5. Paul says:

    In next few years, all new A/V codecs will be ML based, with couple GB of models to fetch.
    But yes, one can go into past and research all games if they have been preserved for present time. Will ML codecs have similar fate too?

  6. Kostya says:

    I’ve suggested that AV2 should be all like that back in the day – https://codecs.multimedia.cx/2020/09/a-modest-proposal-for-av2/

    And with new AI-based everything you don’t need to study how/why it’s designed: the tools for AI-based design of neural networks have been rolled out already. So just get a large storage unit and save all those models, the rest is not important.

Leave a Reply