Hi,<br> Now I am reading the source code of rate control in x264. The function clip_qscale adjusts qscale according to vbv buffer state. <br>I find some comments are not consistent with source codes.<br>Here is the codes:
<br><br> /* Check B-frame complexity, and use up any bits that would<br> * overflow before the next P-frame. */<br> if( h->sh.i_type == SLICE_TYPE_P )<br> {<br> int nb = rcc->bframes;
<br> double pbbits = bits;<br> double bbits = predict_size( rcc->pred_b_from_p, q * h->param.rc.f_pb_factor, rcc->last_satd );<br> double space;<br><br> if( bbits > rcc->buffer_rate )
<br> nb = 0;<br> pbbits += nb * bbits;<br><br> space = rcc->buffer_fill + (1+nb)*rcc->buffer_rate - rcc->buffer_size;<br> if( pbbits < space )<br> {<br>
q *= X264_MAX( pbbits / space,<br> bits / (0.5 * rcc->buffer_size) );<br> }<br> q = X264_MAX( q0-5, q );<br> }<br><br>The comments tell us that the following codes adjust qscale for B slices. But the codes are executed in the case the slice is P.
<br>I have one question. VBV buffer allows us to change the rate according the content of current frame. But how do we make good use of <br>vbv buffer? What is the objective pf vbv buffer in rate control? Try to make it full always?
<br><br>Thanks<br>Jogging <br><br><br><br>