[MEncoder-users] x264encopts equivalent for some x264 parameters ?

Corey Hickey bugfood-ml at fatooh.org
Fri Apr 13 01:05:06 CEST 2007


Nicolas George wrote:
> Le tridi 23 germinal, an CCXV, Corey Hickey a écrit :
>> If you don't understand the difference between --crf and -q, ask and 
>> I'll explain. --But first read the descriptions of crf and qp in the 
>> mplayer man page.
> 
> I am not the "you" in your message, but I would very much like details about
> that. As I understand it, crf will try tu adapt the quantizer value to the
> complexity of the frame, but I would very like to know more about it: how it
> does it in details, and the correspondence between the crf value and the
> resulting quantizer, for example.

Ok... I wasn't planning on a technical explanation, but I'll take a stab 
at it. My understanding of the details is quite tentative, so take it 
with a grain of salt* unless someone who knows more than I do (Michael, 
Loren, ...) responds to this message and affirms/refutes what I've written.

*Or maybe 10 liters of salt if I'm way off.

---------
Numbers in [] are line numbers of encoder/ratecontrol.c, x264 svn r650.

---For each frame---

First, x264 generates a rate factor based on:
- the number of macroblocks (hence the physical size of the frame) [275]
- whether the frame is a B-frame [275]
- "arbitrary rescaling to make CRF somewhat similar to QP" [275]
- the crf value you specify [277]
- a translation from a qp value ("h.264's quantizer") to a qscale value
   ("linearized quantizer = Lagrange multiplier") [277,165]
- the qcomp value you specify (or the default value) [276]

Next, x264 calculates a qscale based on:
- the rate factor calculated earlier
- the ratecontrol equation; by default, blurCplx^(1-qComp) [1311] where:
   - blurCplx is the value of the difference between the current frame
     and the previous frame, blurred (partially averaged) with the
     previous value difference (which was blurred with the the one
     before, etc., so that older frames have a diminishing effect.
     [1294-1300]
   - qComp is the qcomp value you specified, or the default

Last, the final h.264 quantizer is found:
- a translation from qscale back to qp [640,169]


-Corey



More information about the MEncoder-users mailing list