Some words about Alien Isolation CDA2

Some of you might’ve heard about a Finnish adventure game called Alien Incident. Apparently it had a CD release with intro and final cutscenes re-done as an animation format. Of course that’s enough to draw my attention.

It turned out that it has several features making it one of the most advanced game formats: multiple soft subtitles and checksums for each frame. The file header is followed by the text block with subtitles in several languages that are rendered by the player over the video (and the font itself is RLE-compressed). Then there’s a table of 32-bit checksums for each frame, and only after that there’s frame size table followed by actual frame data.

Video is coded in 32×40 tiles with one of several coding modes: read full tile, update marked pixels in the tile, update 2×2 blocks in the tile, or update 4×4 blocks in the tile. That data is further compressed with slightly modified LZSS. Additionally frames carry audio data and some additional commands such as fading or setting frame duration. By default player operates on 70 or 75Hz clock and each frame is displayed for several ticks (usually 5-8). So a special command in the frame data tells player to display each frame for N ticks until further notice.

And now it is time for a rant. There is an issue uncovered by decoding these files. Both files are long (finale is over 11 minutes at 18.75 fps) and have lots of palette changes (because of both scene changes and fading)—and those two things helped uncover a problem with FFmpeg. Its AVI demuxer is the problem: it scans index, finds palette change chunks (which I explicitly mark with AVIIF_NO_TIME flag), adds them to the video stream statistics (despite the flag), concludes that video stream has significantly more frames than audio stream and switches to non-interleaved mode; in that mode it disregards actual index contents and treats palette change chunks as video data. Personally I don’t care because I have my own set of tools for decoding, transcoding or playing videos that does not have this problem, but considering that virtually every other piece of software uses libavformat for handling input data, that may pose a problem for everybody else (I can afford to not care but somebody else would have to change perfectly valid output just to work around third-party bug). This is a fun case demonstrating that monopoly is evil, even if it’s a monopoly of open-source software.

P.S. Probably it’s a good occasion to remind that librempeg exists and probably both it and you can benefit from your attention to it.

4 Responses to “Some words about Alien Isolation CDA2”

  1. Paul says:

    At least with Librempeg you can play HVQM2 and HVQM4 game movies.
    Also full Bink2 decoding coming soonTM !
    Looking for different video/audio coding combination for current USM demuxer, so if anybody have it and librempeg does not support it please share on github.

    If there is really monopoly there would be only gstreamer and nothing else in OSS.

  2. Peter says:

    Fundamentally all software is broken, you just need to find a rare enough use case. Or you can twist it around and say the software is fine, but use case is wrong.

    Speaking of this, did you get my email from a few weeks ago about NihAV RV60 artefact patch? 😀

  3. Kostya says:

    @Peter
    Explaining to users that you’re holding your iPhone wrong is more common though. And I have not received your mail, did you send it to my old baidumail address that I have no access to?

    @Paul
    Nice, looking forward to it! Technically Bink 2 is also a console video format after all, so the more of them the merrier 😉

    As for the monopoly, I remember that back in the day every multimedia project used its own AVI demuxer, now they all predominantly use libavformat even if they have their legacy demuxer enabled (gst is no exception, and I remember funny bug where MPlayer could play Escape130 in AVI fine with its native demuxer while libavformat-based mpv completely botched the demuxing).

  4. Kostya says:

    @Peter Just in case – I got your mail from two days ago and even replied to it.

Leave a Reply