<div>Hi,</div>
<div> </div>
<div>in encoder.c line 1477 we have:</div>
<div><font size="2">
<p></p></font><font color="#008000" size="2">
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<p><font color="#008000" size="2">/* Write frame */<br></font><font color="#0000ff" size="2">if</font><font size="2">( </font><font color="#010001" size="2">h</font><font size="2">-></font><font color="#010001" size="2">
param</font><font size="2">.</font><font color="#010001" size="2">i_threads</font><font size="2"> > 1 )<br>{<br></font><font color="#010001" size="2"> x264_pthread_create</font><font size="2">( &</font><font color="#010001" size="2">
h</font><font size="2">-></font><font color="#010001" size="2">thread_handle</font><font size="2">, </font><font color="#010001" size="2">NULL</font><font size="2">, (</font><font color="#0000ff" size="2">void</font><font size="2">
*)</font><font color="#010001" size="2">x264_slices_write</font><font size="2">, </font><font color="#010001" size="2">h</font><font size="2"> );<br></font><font color="#010001" size="2"> h</font><font size="2">-></font>
<font color="#010001" size="2">b_thread_active</font><font size="2"> = 1;<br>}</font></p></blockquote>
<p><font color="#000000">IMHO, this approach might be flawed (at least on windows with pthreads-w32) because threads are not lightweight enough to be created<br></font><font color="#000000">and destoryed on every frame.
</font></p>
<p><font color="#000000">to get an impression it is easy to see how this affects performance by looking at the task manager:</font></p>
<p><font color="#000000">when using only a single thread, almost all the cpu used (30% for 320x240) is used by the application (indicated in task manager by the green line).<br>when using two threads (on my core 2 duo machine), significantly more cpu is utilized (50% for 320X240), and the difference is due to an increase
<br>in cpu used inside the kernel (indicated in task manager by the red line)</font></p>
<p><font color="#000000">time spent in the kernel does is wasted when it could have been used for actually decoding.</font></p>
<p><font color="#000000">my suggestion is to use a thread pool instead of creating and deleting threads.<br>what do you think? do you believe its a good idea?<br>how many people are even using threads with x264?<br>is there someone who is actively developing in this direction? if not and you think its a good idea, I think I can do it.
<br></font><font color="#000000"></font></p>
<p><font color="#000000">Regards<br></font><font color="#000000">Aviad Rozenhek</font></p></font>
<p><font color="#000000"> </font></p>
<p><font color="#000000"> </font></p>
<p><font color="#000000"></font><font color="#0000ff" size="2"> </font></p></div>