Archive for October, 2026

NihAV: now with VP9 playback support*

Saturday, October 31st, 2026

Recently I’ve discovered some videos on archive.org that I’d like to watch. The problem is that they are VP8/VP9 plus Vorbis/Opus in WebMKV container which NihAV did not support. So I essentially had three options: re-encode it, use a third-party player, or implement support for it. Of course I went the fourth way—implement minimum support for the larger parts and re-encode the audio.

First thing was to determine what has to be done. Since avconv can’t put VP9 into MP4, I had to implement Matroska support. It was moderately annoying but not hard. And it did not lose much respect in my eyes either (mostly because there was not much of it in the first place). Of course I ignored a lot of finer details but it seems to be good enough for my needs, I’ll eventually try it on some 10-bit H.264 plus FLAC files I have somewhere around (another codec not fit for MP4; and don’t point out at the unofficial mapping schemes—my principles say no to it).

Then, audio track. That one was easy, just re-encode it to AC3 from whatever input format. It’s fast and beats writing decoders for Xiph formats.

Finally, video. I have VP8 decoder already (mostly written for the completeness sake) but no VP9 decoder. Re-encoding video is a long process, writing decoder is not particularly fast either. The not so obvious solution was to rely on VA-API for hardware decoder. One thing that’s definitely better in Duck codecs against ITU codecs is much simpler metadata and frame management, so VP9 VA-API decoder is much smaller and simpler than H.264 one. Essentially it’s just read frame header, generate some parameter structures, send it to the decoding and update frame references afterwards—compare that to parsing data in order to find frame header, picture parameter sets it references, sequence parameter set referenced by PPS and preparing various structures for that along with complex frame management rules. VP9 is not that simple either, with its potentially present segmentation and whatnot, but it’s much more manageable for the common case. As a side note, the follow-up codecs (VP 1.0 errata 1 and VP II) are much worse in that aspect, so I don’t know if I’ll ever want to deal with them.

And there it is, my solution for watching some files without wasting too much effort on implementing full support for all involved formats. Of course it would be easier just to re-use some existing code for demuxing support and wrap decoding libraries; some may even point out the futility of it all since there are perfectly working solutions already. But as I have committed to using my own software for my multimedia needs (except for the rare cases which avconv is allowed to handle), I’ll keep improving what I have. But had the things developed better in the past, I’d have no such problem as avp from rust-av project would be usable for my needs. Alas!

na_eofdec 0.1.5 release

Tuesday, October 27th, 2026

Now as the PHP calamity is temporarily over and the sites are back online, it’s as good time as ever to make a release.

I’ve come to realisation that I don’t have enough non-gaming video formats in store to reverse engineer, so instead of waiting indefinitely until I discover enough of them I’m making a release now. Half a dozen new formats are enough for 0.1.5 by my standards, and maybe it will be useful as a reference for somebody.

Since the reason for this point release is the lack of formats, don’t expect new releases in the foreseeable future. From my point of view the tool served both its purposes well: testing decoding of some exotic format and being a proving ground for MOV muxer. It makes sense to port the parts that handle variable framerates and uneven audio blocks to na_game_tool but so far I was not bored enough to do that. Anyway, the new release is at the usual place and I should not bother you with this tool ever again.

A bit about really ancient format

Monday, October 5th, 2026

While researching the formats to support I’ve finally encountered an animation format for CGA, from the times when H.261 was ratified (i.e. 1988) but a bit simpler than that format.

Essentially it’s RLE-compressed CGA memory buffers either in 640×400 monochrome or 320×200 eye-gouging 2-bit colour mode. RLE has a twist as instead of the usual mode switch or symbol repeating it sends the list of symbols that have run lengths after them.

The hardest part was to actually render the resulting frame. For some reason CGA video modes organisation is not as widely documented as EGA or VGA, and it differs enough from them. The 256-colour VGA mode is simple: there are four planes responsible for interleaved parts of the frame or you can even simply pretend it’s one contiguous blocks (with VLB and 80486 you probably won’t care about hidden performance hit anyway). EGA as many video formats of the era (like Amiga but not as exquisite; and most of VGA modes as well) simply separates data into bit-planes. CGA on the other hand first splits data into even/odd lines using two different pages for that and packs bits continuously. I can guess what technical limitations made it work this way but I still don’t like the result.

Anyway, I think this obscure format from the past really stands out and deserves a mention at least somewhere (like this blog). Oh, and README.TXT mentions the program was written by an attorney—I don’t know what aspect of it all is merely mundane.