<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 12, 2016 at 7:14 AM, Deepthi Nandakumar <span dir="ltr"><<a href="mailto:deepthipnandakumar@gmail.com" target="_blank">deepthipnandakumar@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">You're handling pNals wrongly. framesize may be 1, but number of NALs in the stream may be greater than 1 (=iNal). So you need to copy all of those, not just pNals[0]. <br>
</p>
<div class="gmail_quote"><div><div class="h5">On 12-Aug-2016 2:53 am, "Dolevo Jay" <<a href="mailto:cmst@live.com" target="_blank">cmst@live.com</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<div dir="ltr">
<div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi all,</p>
<p><br>
</p>
<p>In my encoder application, I initialize the encoder as follows:</p>
<p><br>
</p>
<p></p>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#800000"> param</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>x265_param_alloc();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>x265_param_default(<span style="color:#800000">param</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>x265_param_default_preset(<span style="color:#800000">para<wbr>m</span>,<span style="color:#c0c0c0"> </span><span style="color:#008000">"ultrafast"</span>,<span style="color:#c0c0c0"> </span><span style="color:#008000">"zerolatency"</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">param</span>-><span style="color:#800000">fpsNum</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#000080">25</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">param</span>-><span style="color:#800000">fpsDenom</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#000080">1</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">param</span>-><span style="color:#800000">bRepeatHeaders</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#808000">true</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">param</span>-><span style="color:#800000">internalCsp</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#000080">X265_CSP_I420</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">param</span>-><span style="color:#800000">sourceWidth</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>aWidth;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">param</span>-><span style="color:#800000">sourceHeight</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>aHeight;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">y_size</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#800000">param</span>-><span style="color:#800000">sourceWidth</span><span style="color:#c0c0c0"> </span>*<span style="color:#c0c0c0"> </span><span style="color:#800000">param</span>-><span style="color:#800000">sourceHeight</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">param</span>-><span style="color:#800000">logLevel</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#000080">X265_LOG_FULL</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">encoder</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#000080">x265_encoder_open</span>(<span style="color:#800000">param</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">if</span><span style="color:#c0c0c0"> </span>(<span style="color:#000080">NULL</span><span style="color:#c0c0c0"> </span>==<span style="color:#c0c0c0"> </span><span style="color:#800000">encoder</span>)<span style="color:#c0c0c0"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><font color="#800000">print</font><span style="font-style:italic">Log</span>(<span style="color:#008000">"[X265]</span><span style="color:#c0c0c0"> </span><span style="color:#008000">x265_encoder_open</span><span style="color:#c0c0c0"> </span><span style="color:#008000">err"</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">return</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">param</span>-><span style="color:#800000">internalCsp</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#000080">X265_CSP_I420</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">pic_in</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>x265_picture_alloc();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>x265_picture_init(<span style="color:#800000">param</span>,<span style="color:#c0c0c0"> </span><span style="color:#800000">pic_in</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">pic_in</span>-><span style="color:#800000">planes</span>[<span style="color:#000080">0</span>]<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#808000">new</span><span style="color:#c0c0c0"> </span><span style="color:#808000">char</span>[<span style="color:#000080">32000000</span>];</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">pic_in</span>-><span style="color:#800000">planes</span>[<span style="color:#000080">1</span>]<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#808000">new</span><span style="color:#c0c0c0"> </span><span style="color:#808000">char</span>[<span style="color:#000080">32000000</span>];</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">pic_in</span>-><span style="color:#800000">planes</span>[<span style="color:#000080">2</span>]<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#808000">new</span><span style="color:#c0c0c0"> </span><span style="color:#808000">char</span>[<span style="color:#000080">32000000</span>];</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">pic_in</span>-><span style="color:#800000">stride</span>[<span style="color:#000080">0</span>]<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>aWidth;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">pic_in</span>-><span style="color:#800000">stride</span>[<span style="color:#000080">1</span>]<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>aWidth;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">pic_in</span>-><span style="color:#800000">stride</span>[<span style="color:#000080">2</span>]<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>aWidth;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800000">pic_out</span><span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>x265_picture_alloc();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>x265_picture_init(<span style="color:#800000">param</span>,<span style="color:#c0c0c0"> </span><span style="color:#800000">pic_out</span>);</pre>
<br>
<p></p>
<p><br>
</p>
<p>Then, I apply the following function for each incoming frame:</p>
<p><br>
</p>
<p></p>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">int</span><span style="color:#c0c0c0"> </span>frame_size<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#800080">x265_picture</span><span style="color:#c0c0c0"> </span>pic_out1;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>frame_size<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>x265_encoder_encode(<span style="color:#800000">encoder</span>,<span style="color:#c0c0c0"> </span>&<span style="color:#800000">pNals</span>,<span style="color:#c0c0c0"> </span>&<span style="color:#800000">iNal</span>,<span style="color:#c0c0c0"> </span>pic_in,<span style="color:#c0c0c0"> </span><span style="color:#000080">NULL</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">if</span><span style="color:#c0c0c0"> </span>(frame_size<span style="color:#c0c0c0"> </span><<span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>)<span style="color:#c0c0c0"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><font color="#800000">print</font><span style="font-style:italic">Log</span>(<span style="color:#008000">"[ERROR]</span><span style="color:#c0c0c0"> </span><span style="color:#008000">H265:</span><span style="color:#c0c0c0"> </span><span style="color:#008000">x265_encoder_encode</span><span style="color:#c0c0c0"> </span><span style="color:#008000">failed."</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">return</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#808000">if</span><span style="color:#c0c0c0"> </span>(frame_size<span style="color:#c0c0c0"> </span>><span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>)<span style="color:#c0c0c0"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>memcpy(aFramebuffer,<span style="color:#c0c0c0"> </span><span style="color:#800000">pNals</span>[<span style="color:#000080">0</span>].<span style="color:#800000">payload</span>,<span style="color:#c0c0c0"> </span><span style="color:#800000">pNals</span>[<span style="color:#000080">0</span>].<span style="color:#800000">sizeBytes</span>);</pre></div></div></div></div></blockquote></div></blockquote><div><br></div><div>You need to iterate over iNal and copy the payload for all the pNals from 0 to iNal.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:#008000"></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>*aFrameBufferSize<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#800000">pNals</span>[<span style="color:#000080">0</span>].<span style="color:#800000">sizeBytes</span>;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:#800000"> dumpfileEncodedData</span>.write((<span style="color:#808000">con<wbr>st</span><span style="color:#c0c0c0"> </span><span style="color:#808000">char</span><span style="color:#c0c0c0"> </span>*)aFramebuffer,<span style="color:#c0c0c0"> </span>*aFrameBufferSize);</pre><br></pre>
<br>
<p></p>
<p>Just to debug the encoded bitstream, I dump the data into a file </p>
<p><br>
</p>
</div>
</div>
<br></div></div>______________________________<wbr>_________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/l<wbr>istinfo/x265-devel</a><br>
<br></blockquote></div>
<br>______________________________<wbr>_________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/x265-devel</a><br>
<br></blockquote></div><br></div></div>