[Ffmpeg-devel] [PATCH] increase max numbers of B frames

Loren Merritt lorenm
Mon Feb 20 21:58:39 CET 2006


On Mon, 20 Feb 2006, Erik Slagter wrote:

> On Sun, 2006-02-19 at 13:24 -0800, Loren Merritt wrote:
>>> This increases max B frames, this is necessary for h264 encoding, which
>>> allows 16 B frames (maybe more?).
>>
>> H.264 allows an arbitrarily large number of B-frames, but the useful
>> number is no more than in mpeg4 (i.e. 3).
>> Not that there's anything wrong with the patch.
>
> Interesting?! Would you care to elaborate a bit on this? The stats of
> x264 tell me that the b-frames (ok, on average) are a lot smaller than
> the I/P frames, what am I missing here? Maybe useful for the docs?

PPP.
PBPBP: the B-frames are much smaller than the P-frames, but the P-frames 
are bigger than when there weren't any B-frames.
PBBPBBP: P-frames are bigger than above because more has changed since the 
previous P-frame, and B-frames are bigger than above because the 
referenced P-frames are farther apart. But this is still usually lower 
bitrate in total than 1 consecutive, due to the higher fraction of 
B-frames.
PBBBPBBBP: again, each frame is bigger than it would be in 2 consecutive, 
and now there's a decent chance that 67%->75% B-frames isn't enough to 
pay off. Though it's a bit more useful than in mpeg4, due to B-pyramid 
(which I won't detail here) and miscellaneous other improvements in the 
codec.
PBBBBP: almost never worthwhile. x264 uses this only in scenes where 
basically nothing at all moves, in which case you'll get equally low 
bitrate from any of the patterns.
PBBBBBBBBBBBBBBBBBBBBP: legal, but insane. As far as I know, this is legal 
in mpeg4 too, just even more insane.
IBBBBBBBBBBBBBBBBBBBBB: also legal. You don't strictly need any P-frames 
at all.

Additionally, the stats overestimate the smallness of B-frames: 
B-frames are more useful in low-motion scenes, and low motion scenes have 
smaller frames than high-motion. So the average B-frame size would be less 
than the average P-frame size even if any one B-frame were the same size 
as the adjacent P-frame.
For the same reason, you sometimes see that the average B-frame quantizer 
is less than the average P-frame quantizer even though each B-frame has 
higher quantizer than the adjacent P-frames.

--Loren Merritt





More information about the ffmpeg-devel mailing list