Hi, everyone:<span lang="EN-US"> </span>
<p class="MsoNormal" style="text-align: left;" align="left"><span lang="EN-US">I have some questions about vbv buffer update
in x264. The specification said that it is the data with the access units that
flow into the CPB. The data include not only the coded frame size but also all
the other NAL units flow into the CPB. <br></span></p>
<p class="MsoNormal" style="text-align: left;" align="left"><span lang="EN-US">Bellows are from h264 specification:</span><br><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">"The HRD
operates as follows. <span style="color: red;">Data associated with access units
that flow into the CPB according to a specified arrival schedule are delivered
by the HSS. </span>¡¡"</span><br><b><span style="font-size: 10pt; font-family: "TimesNewRoman,Bold";" lang="EN-US">"access unit</span></b><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">
: A set of </span><i><span style="font-size: 10pt; font-family: "TimesNewRoman,Italic";" lang="EN-US">NAL units </span></i><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">always containing exactly one
</span><i><span style="font-size: 10pt; font-family: "TimesNewRoman,Italic";" lang="EN-US">primary coded picture</span></i><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">. <span style="color: red;">
In addition to</span> the </span><i><span style="font-size: 10pt; font-family: "TimesNewRoman,Italic";" lang="EN-US">primary
coded picture</span></i><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">, an
access unit may <span style="color: red;">also contain </span>one or more </span><i><span style="font-size: 10pt; font-family: "TimesNewRoman,Italic";" lang="EN-US">redundant
coded pictures<span style="color: red;"> </span></span></i><span style="font-size: 10pt; font-family: TimesNewRoman; color: red;" lang="EN-US">or </span><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">
other </span><i><span style="font-size: 10pt; font-family: "TimesNewRoman,Italic";" lang="EN-US">NAL units </span></i><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">not containing </span>
<i><span style="font-size: 10pt; font-family: "TimesNewRoman,Italic";" lang="EN-US">slices </span></i><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">or </span><i><span style="font-size: 10pt; font-family: "TimesNewRoman,Italic";" lang="EN-US">
slice data partitions </span></i><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">of a </span><i><span style="font-size: 10pt; font-family: "TimesNewRoman,Italic";" lang="EN-US">coded picture
</span></i><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">. The decoding of an access unit always results
in a </span><i><span style="font-size: 10pt; font-family: "TimesNewRoman,Italic";" lang="EN-US">decoded
picture</span></i><span style="font-size: 10pt; font-family: TimesNewRoman;" lang="EN-US">." <br></span></p>
<p class="MsoNormal"><span lang="EN-US">So I think the function "update_vbv" has
some bugs. The parameter "bits" should be equal to the total bits in the "h->out.nal[X264_NAL_MAX]".
Such as bellows:</span></p><p class="MsoNormal"><span lang="EN-US"><span style=""> </span>for(nNalLoop=0;
nNalLoop<X264_NAL_MAX; nNalLoop++)</span></p>
<p class="MsoNormal"><span lang="EN-US"><span style=""> </span>{</span></p>
<p class="MsoNormal"><span lang="EN-US"><span style=""> </span>if(h->out.nal[nNalLoop].i_type
> 0)</span></p>
<p class="MsoNormal" style="text-align: left;" align="left"><span lang="EN-US"><span style=""> </span>nRealBits
+= h->out.nal[nNalLoop].i_payload + 5;</span></p>
<p class="MsoNormal"><span lang="EN-US"><span style=""> </span>}</span></p>
<p class="MsoNormal"><span lang="EN-US"><span style="">
</span>rcc->buffer_fill += rcc->buffer_rate - nRealBits*8;</span></p>
<p class="MsoNormal" style="text-align: left;" align="left"><span lang="EN-US">The number 5 is that 4 bytes "start_code_prefix"
add 1 byte "nal_unit_start". i.e.<span style=""> </span>"00 00 00 01 65".
</span></p>
<p class="MsoNormal"><span lang="EN-US">At the same time the "h->out.nal[nNalLoop].i_type"
should be set as zero at the begin of the function "x264_encoder_encode" to
avoid the influence of last frame. <br></span></p>
<p class="MsoNormal"><span lang="EN-US">I want to know my idea is right. Give me
some advice please. <br></span></p>
<p class="MsoNormal"><span lang="EN-US">Best wishes,</span></p><p class="MsoNormal"><span lang="EN-US"></span><span style="font-size: 10.5pt; font-family: "Times New Roman";" lang="EN-US">Alexander tian</span></p>