[Ffmpeg-devel] H264 decoder internals
Sun Jun 19 02:52:51 CEST 2005
Michael Niedermayer <michaelni at gmx.at> writes:
> On Sunday 19 June 2005 01:03, M?ns Rullg?rd wrote:
>> Michael Niedermayer <michaelni at gmx.at> writes:
>> > Hi
>> > On Saturday 18 June 2005 16:26, M?ns Rullg?rd wrote:
>> >> I'm messing around with the H.264 decoder, and I'm having some trouble
>> >> figuring out how the standard maps to the code.
>> >> Around section 8.5.10 in the H.264 spec, there are a number of
>> >> equations similar to 8-339:
>> >> d_ij = (c_ij * LevelScale(qP % 6, i, j) + 2^(3-qP/6)) >> (4 - qP / 6)
>> >> I looks like the value of LevelScale() is precomputed for all
>> >> combinations in the dequant_coeff array. What I'm having some trouble
>> >> with, is understanding where the final value of that equation is
>> >> calculated. I suppose it's disguised in some clever optimization.
>> >> Could someone please explain what's going on?
>> > dequantization is done during bitstream decoding or during the dc
>> > inverse transform
>> I figured as much. I just can't quite make out for certain what
>> happens where. The multiplication I can see, but the add and the
>> shift have me confused.
> these where probably not part of the spec in their current form when
> this part of the code was implemented and
In the 05/2003 edition of the standard, the corresponding equation
(8-265) is the somewhat simpler
d_ij = (c_ij * LevelScale(qP % 6, i, j)) << (qP / 6)
which also agrees better with the code.
> with the default scaling matrix with constant 16 the right shift of
> up to 4 is really not needed, and neither is the add
Well, I was trying to add support for custom scaling matrixes, and
the pictures are not looking quite right.
> btw, am i the only one who thinks that the h.264 spec is the most
> obfuscated and unreadable spec ever?
At least it's a spec...
mru at inprovide.com
More information about the ffmpeg-devel