Archive for June, 2025

The end of FFhistory

Thursday, June 19th, 2025

For those who infer from the title I’m going to talk about something negative, this is a philosophical term with rather positive definition. Also I guess this post goes against the old Latin principle noli stercus tangere et non olebit but oh well.

I happen to observe FFmpeg (not sure how to call this iteration of it) and it looks like it’s been never greater before, with a further potential to grow:

  • there’s a new developer who not only looks like a perfect fit for the project but also seemed to unite other developers;
  • the development has achieved new levels and got to the modern standards as can be seen from this patchset;
  • even long-standing complaints about inaction against badly behaved developers have been addressed and bans are enacted (since last year even);
  • important patchsets are pushed without unnecessary delays (for example, caused by reviews);
  • participating in various trade shows with constant success;
  • and thanks to STF the core developers can get funding for the crucial (or even critical) work in transparent way; and apparently cryptocurrency is an option too.

The things are going so well that FFmpeg can really afford not to care about every potential contributor (that ship has sailed indeed). More than that, they’ve even got their own soft Jia Tan—a person writing under multiple accounts and who introduced what others considered a glaring security hole (like there’s anything wrong with ffmpeg launching a third-party application on user’s request). All the tell-tale signs of success are there!

I honestly don’t see how the project can get any better (and yes, I feel that I’m not worthy to use it so I don’t).

NihAV: now with TealMovie support

Wednesday, June 11th, 2025

Back in the day I looked at the format and recently, to distract myself from game formats, I decided that it might be a good not the worst idea to implement decoding it.

And in the course of doing that I discovered some things that make it even more peculiar. For starters, it flips every second sample in its ADPCM coding. I don’t know if it improves compression in this particular case or it was done just to be different. Similarly split sub- or sub-sub-blocks are coded in コ-order instead of more traditional zigzag order.

But there are more interesting things about it. For starters, the file is organised into blocks instead of frames. First block always contains metadata (streams parameters, title, creator and such), next blocks contain one or more video frames (which you have to decode one after another; I implemented frame parsing for finding out frame boundaries but that’s inelegant solution), and last blocks are used to store audio. This means demuxer either has to demux audio frames after all video frames are sent or jump places in order to maintain synchronisation. Since this is not na_game_tool, I picked the former. The samples are short, so it’s easier to decode them to AVI+WAV and remux properly (or decode both streams to AVI and make AVI demuxer handle unsynchronised streams better—but that’s a task for another day).

Another surprising thing is that there is 16-bit RGB support, done in a very peculiar way. Frame decoding remains the same, except that now frame data is actually a pseudo-YUV frame with two chroma planes following the luma plane. And of course the conversion is done using one of two tables (depending on file version) using the formula yuv2rgbtab[(u + v) * 128 + y]. I guess it’s coding luma, colour difference and colour difference difference here.

And finally, intra frames in TealMovie are stored raw. But when frame width exceeds 160, it is stored half-size.

That’s why I’m looking at those old formats: there’s significantly more variety there in employed coding methods and storage format nuances. Not all of them make much sense but sometimes they’re entertaining or so original that it makes you wonder why such approaches got no further development.

P.S. Maybe I should take another look at the handheld console video formats.

P.P.S. But I think I’ll have to do some boring things instead. With BaidUTube changing its available formats it seems I finally need my own MP4 muxer. In either case that’s easier than to fix libav.

na_game_tool 0.4.0 release

Tuesday, June 3rd, 2025

At last a new version, now with over a hundred various formats being supported!

About a third of them are console formats of mostly raw variety (you need just to figure out how tile data is represented) but some of them required some reverse engineering as well (e.g. Road Avenger employs LZ77-based compression). Another third comes from known sources (either The Wiki or ScummVM source code. Last third is from my reverse-engineering efforts on DOS games.

What’s next? I don’t make plans, but I like the idea (suggested by Paul of librempeg fame) to make the tool more versatile. So version 0.5.0 should at least support extracting data from game archives: some of the currently supported video formats can be found only inside large game archives, so why not provide a way to obtain the files as well?

Beside that, I’ll probably focus on more complex codecs, namely the ones that are based on other codecs like Cinepak, JPEG or Smacker. I’m not sure I’ll be able to find another dozen formats to RE but at least there should be something new beside merely archive extraction.

Meanwhile grab the current version here (or don’t, it shan’t make a difference).