Oops
Apparently my nnz patch managed to break lossless mode and it took us nearly 2 weeks to realize it! Fortunately, I managed to fix it with this patch only 30 minutes after it was reported and it was soon after put into the official git repository. To begin with, to understand this, one has to understand what my nnz patch did.
CAVLC entropy encoding needs to know the number of nonzero coefficients in a DCT block to choose its variable-length codes properly (among other things, it adapts which VLC table to use based on the characteristics of the DCT block). This is a slightly intensive process; its an extra step to take on every single DCT block to count the number of nonzero values. Its not too slow, but in CABAC its completely unnecessary, so the purpose of the patch was to move all nnz calculations to CAVLC and in the macroblock encoding only calculate a single thing: whether the array had coefficients or not, which is very fast and trivial to calculate.
But in DCT arrays of AC coefficients only, such as in i16x16 and 8×8 chroma blocks (see this post for more info), we need to ignore the first coefficient, the DC coefficient, when doing this math. So the simplest way to do this is to just zero the DC coefficient at the same time we write the coefficients to memory so it doesn’t cause issues later.
But I forgot about lossless mode and forgot to set the DC coefficient to zero in that case. The end result? Well, it broke!
May 17th, 2008 at 2:47 am
Sounds like you guys need some regressions tests.
May 17th, 2008 at 8:16 am
If only there were some automated system for testing multimedia code on multiple platforms…
June 26th, 2008 at 11:03 am
Superprogrammers also get it wrong sometimes.
It’s all good !
Pascal
July 2nd, 2008 at 8:13 pm
Thanks authors for the specified materials, a lot of the compelling advice. All good.