<div dir="ltr"><div dir="ltr"><div></div><div>I can't think of any good way to multithread the encoder without ruining efficiency, because so much efficiency is gained from holding state over, from the good old MP2 days all the way up to now. Running at 12x even on an RPi makes it very questionable whether to spend <i>any </i>engineer resources in that direction, too. On desktop systems it's closer to 100x for single-threaded stereo CELT encoding.<br></div><div><br></div><div>You could easily separate decoding/SRC and encapsulating onto their own threads, but I doubt that would gain you more than 10% or so, since those are normally very fast operations. Splitting the encoder stages into individual threads seems like it would be promising, even if the referenced PDF abandoned the idea due to implementation effort, but you rapidly run into the problem of memory contention: So much time is wasted moving data between cores and caches and main memory. While real throughput goes slightly up, electrical efficiency goes way down.<br></div><div><br></div><div>If fidelity is less important than raw speed, then just chopping the stream into X chunks and encoding each on its own thread will work; the shorter the chunks, the more wasted data, but at least it generally works. As jm says, there may be compatibility issues. You might be able to get around that with a combination of FEC packets and marking other packets lost, instead of stitching, but I'm not sure if relying on FEC would even be more or less compatible than relying on stitching.<br></div><div><br></div><div>As for the direct question, no, there's no drop-in replacement available. Opusenc could use a general cleanup, so if someone threw some basic pthreads into that effort it might well be accepted.</div><div><br></div><div>Em</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 29, 2020 at 5:57 PM Jesus Cea <<a href="mailto:jcea@jcea.es" target="_blank">jcea@jcea.es</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I am interested in being able to encode a single Opus stream using<br>
several CPU cores.<br>
<br>
I get a raw audio input and "opusenc" can transcode it at 1200% speed<br>
(Raspberry PI 3B+). It saturates a single CPU core, but the other three<br>
are idle.<br>
<br>
Is out there any project to add multithreading options to "opusenc", or<br>
something in that line?<br>
<br>
Looking around, I have found this:<br>
<br>
<a href="https://github.com/enzo1982/superfast#superfast-codecs" rel="noreferrer" target="_blank">https://github.com/enzo1982/superfast#superfast-codecs</a><br>
<a href="https://hydrogenaud.io/index.php?topic=114598.0" rel="noreferrer" target="_blank">https://hydrogenaud.io/index.php?topic=114598.0</a><br>
<<a href="https://github.com/enzo1982/superfast/blob/master/doc/SuperFast%20Codecs.pdf" rel="noreferrer" target="_blank">https://github.com/enzo1982/superfast/blob/master/doc/SuperFast%20Codecs.pdf</a>><br>
<br>
Is it out there any other multithreaded "opusenc" drop in replacement?.<br>
Any plan for future "opusenc" improvement in this area?<br>
<br>
Thanks.<br>
<br>
-- <br>
Jesús Cea Avión                         _/_/      _/_/_/        _/_/_/<br>
<a href="mailto:jcea@jcea.es" target="_blank">jcea@jcea.es</a> - <a href="https://www.jcea.es/" rel="noreferrer" target="_blank">https://www.jcea.es/</a>    _/_/    _/_/  _/_/    _/_/  _/_/<br>
Twitter: @jcea                        _/_/    _/_/          _/_/_/_/_/<br>
jabber / <a href="mailto:xmpp%3Ajcea@jabber.org" target="_blank">xmpp:jcea@jabber.org</a>  _/_/  _/_/    _/_/          _/_/  _/_/<br>
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/<br>
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/<br>
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz<br>
<br>
_______________________________________________<br>
opus mailing list<br>
<a href="mailto:opus@xiph.org" target="_blank">opus@xiph.org</a><br>
<a href="http://lists.xiph.org/mailman/listinfo/opus" rel="noreferrer" target="_blank">http://lists.xiph.org/mailman/listinfo/opus</a><br>
</blockquote></div></div>