I have looked at about dozen of codecs and for me KMVC (codec used for FMV in Worms games) is surely the kinkiest.
Here is what I think is kinky:
- Usability – there are two version of codecs, one uses for decoding kmvidc32.dll, other can be played by DOS player (player and samples for second type can be found atMPlayer samples repository). DLL cannot play files played by DOS player and vice versa and all these two types differ is just extradata (another 12 bytes), frame format is the same!
- Strange bit reading policy: read 8 bits at once, when this bit buffer exhausts, read another byte (and a lot of data may be read between those two bitbuffer reads). I understand that was made to avoid bit reading issues, but it’s still very strange.
- Another credit goes straight to m$ visual C. I cannot make myself think that any more or less sane coder would write this:
; load something into al
add al, al
And that is the simplest example of this – sometimes block L2 occurs in the beginning of function and L1 is near the end of it! Is this some kind of disoptimization to run the code on modern CPUs (which don’t like branching) with the speed of ol’ good i486?
I hope to finish spec and decoder to May.