<p class="MsoNormal"><span lang="EN-US">Loren, thanks for your reply.<br>
<br>
&gt;A NAL unit is just the type and contents, not including the &quot;00 00 00
01&quot;.<br>
&gt;Startcode could be considered &quot;data associated with an access
unit&quot;, but<br>
&gt;it might not be present at all, depending on what container is used. And<br>
&gt;libx264 can&#39;t possibly know what container you&#39;re putting the output<br>
&gt;stream in.<br>
Yes, you are right. A NAL unit is only the type and contents. It doesn&#39;t
include the &quot;start_code_prefix&quot;. </span></p>



<p class="MsoNormal"><span lang="EN-US">But I do not clearly know what you mean. Does
the different container correspond to different way? What does the container mean
here? Could you explain it in detail? Or give me some references please. <br>
<br>
Why I change them is because of some experience results. I use the x264 to
produce h264 es file by using 1pass, CBR mode. I use the software "Elecard
Buffer Analyzer" to analyze these files. I find that the vbv buffer will
underflow if the time is above 60 seconds. I think the accumulative errors for
input size result in the end. The buffer would not underflow if I change the
input size from encoded frame size to the all data size. So I believe that the vbv operation should be changed. <br></span></p>

<p class="MsoNormal"><span lang="EN-US">&gt;Plus, you count bytes in a variable
called &quot;bits&quot;, and you use a<br>
&gt;complicated loop depending on nal type when it could just count up to<br>
&gt;h-&gt;out.i_nal.</span></p>

<span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;;" lang="EN-US">Oh, yes. Your way is
simple. I will use this way. <br><br>Any advices will be welcome. Thanks in advance.<br></span><br><div><span class="gmail_quote">2007/3/28, Loren Merritt &lt;<a href="mailto:lorenm@u.washington.edu">lorenm@u.washington.edu
</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Wed, 28 Mar 2007, alexander tian wrote:<br><br>&gt; I have some questions about vbv buffer update in x264. The specification
<br>&gt; said that it is the data with the access units that flow into the CPB. The<br>&gt; data include not only the coded frame size but also all the other NAL units<br>&gt; flow into the CPB.<br>&gt;<br>&gt; Bellows are from h264 specification:
<br>&gt; &quot;The HRD operates as follows. Data associated with access units that flow<br>&gt; into the CPB according to a specified arrival schedule are delivered by the<br>&gt; HSS. ¡­¡­&quot;<br>&gt; *&quot;access unit*: A set of *NAL units *always containing exactly one *primary
<br>&gt; coded picture*. In addition to the *primary coded picture*, an access unit<br>&gt; may also contain one or more *redundant coded pictures *or other *NAL units<br>&gt; *not containing *slices *or *slice data partitions *of a *coded picture*.
<br>&gt; The decoding of an access unit always results in a *decoded picture*.&quot;<br>&gt;<br>&gt; So I think the function &quot;update_vbv&quot; has some bugs. The parameter &quot;bits&quot;<br>&gt; should be equal to the total bits in the &quot;h-&gt;
out.nal[X264_NAL_MAX]&quot;. Such as<br>&gt; bellows:<br>&gt;<br>&gt;&nbsp;&nbsp; for(nNalLoop=0; nNalLoop&lt;X264_NAL_MAX; nNalLoop++)<br>&gt;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(h-&gt;out.nal[nNalLoop].i_type &gt; 0)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nRealBits += h-&gt;
out.nal[nNalLoop].i_payload + 5;<br>&gt;&nbsp;&nbsp; }<br>&gt;&nbsp;&nbsp; rcc-&gt;buffer_fill += rcc-&gt;buffer_rate - nRealBits*8;<br>&gt;<br>&gt; The number 5 is that 4 bytes &quot;start_code_prefix&quot; add 1 byte<br>&gt; &quot;nal_unit_start&quot;. 
i.e.&nbsp;&nbsp;&quot;00 00 00 01 65&quot;.<br>&gt;<br>&gt; At the same time the &quot;h-&gt;out.nal[nNalLoop].i_type&quot; should be set as zero at<br>&gt; the begin of the function &quot;x264_encoder_encode&quot; to avoid the influence of
<br>&gt; last frame.<br><br>A NAL unit is just the type and contents, not including the &quot;00 00 00 01&quot;.<br>Startcode could be considered &quot;data associated with an access unit&quot;, but<br>it might not be present at all, depending on what container is used. And
<br>libx264 can&#39;t possibly know what container you&#39;re putting the output<br>stream in.<br><br>Plus, you count bytes in a variable called &quot;bits&quot;, and you use a<br>complicated loop depending on nal type when it could just count up to
<br>h-&gt;out.i_nal.<br><br>--Loren Merritt</blockquote></div><br>