19 Aug 2009

JianFeng Zheng sent me a good question about H.264 inverse transform and quantization. In the H.264 standard, there is an extra division by 16 that occurs in section 8.5.8 (in the 2007 version of the document) that I don't mention in my tutorial on the inverse transform. It's not easy to see where this factor comes from.

H.264 includes the option to send a non-uniform quantization scaling matrix ("scaling list"), which makes it possible to quantize coefficients differently depending on their position in the block. The default scaling matrix, Flat_4x4_16 (or 8x8 equivalent) is a constant value for every coefficient position. The constant value is 16 (rather than 1 as might be expected). This is cancelled out by the division by 16 (implemented as a right-shift by 4 binary places) in section 8.5.8. So it all works out neatly.

Thanks to JianFeng for the question.

- Iain.