[MEncoder-users] Backup policies

Loren Merritt lorenm at u.washington.edu
Mon Nov 19 13:34:21 CET 2007


On Sat, 17 Nov 2007, Michael Rozdoba wrote:

> Reimar Döffinger wrote:
>> Hello,
>> On Sat, Nov 17, 2007 at 08:26:11PM +0000, Michael Rozdoba wrote:
>> [...]
>>> My immediate intuitive reaction is to say what if one has a video with
>>> 30 minutes of a static scene followed by 30 minutes of noise? 2pass
>>> surely allocates most bits to the 2nd half while CRF, whatever it does,
>>> can't allocate different bit distributions in awareness of the
>>> distinction between 1st & 2nd halves (*).
>>
>> Of course it does "allocate different bit distributions", it since it
>> trivially reaches the desired quality in the first part so it uses very
>> few bits, whereas in the second part it must use lots to get the desired
>> quality.
>
> Which is why I said 'in awareness of...'; it allocates them
> independently, which isn't a problem given no bitrate restrictions. The
> intuitive feeling however, which is probably wrong, is that awareness of
> the bit distribution needs across the entire video (from a first pass)
> should be of benefit in influencing the bit distributing in a subsequent
> pass. It seems this isn't needed.

Where you went wrong is thinking of bit distributing. "Distribution" 
carries a connotation that you have some bits and then decide where to 
put them. That's not how x264 works, CRF nor 2pass. It's better to think 
of "bit requisitioning": decide how many bits you need at any given time 
and take that many, out of an infinite reservoir. The limitation on 
bitrate is then not some quota, but rather a price tag attached to each 
bit. CRF buys bits until it can't justify the cost due to diminishing 
returns on quality-improvement-per-bit.
Then it should be obvious that if you do have a bit quota (i.e. 2pass 
target bitrate), optimally allocating bits from that quota is equivalent 
to finding some quality-per-bit cost threshold such that all frames are 
satisfied within your quota. If that were not the case, then to get 
from CRF's choice to 2pass's choice there must be some pair of frames 
A and B such that A takes bits away from B. That means A can make 
better use of those bits than B could. But CRF uses the same 
quality-per-bit threshold everywhere, so it would have already made the 
same decision that A deserves more bits.
Now the only factor that needs a lookahead is the estimation of how much 
quality you'd get out of a given bit, which is where the discussion of a 
20 frame window came in. The repercussions of any decision are local; 
changes to objective metrics are strictly limited to one GOP and usually 
smaller, while psychovisual repercussions are not strictly limited but 
still can't possibly extend more than a few seconds.

--Loren Merritt


More information about the MEncoder-users mailing list