[osg-users] [osgPlugins] Multiple video textures using ffmpeg plugin

Voerman, L. l.voerman at rug.nl
Fri Oct 6 05:56:48 PDT 2017


Hi Michael,
we use a modified version of the ffmpeg plugin with changes in
OpenSceneGraph\src\osgPlugins\ffmpeg\FFmpegDecoderVideo.cpp
to move the threads to different processors. (full modified file attached)
It's a crude bit of code,
but it allows us to decode and show 2  1920x1080 movies at 30 fps.
I've pulled out just the code for cpu affinity, this should work with osg
3.4.2 as well as git master.
Regards, Laurens.


+ #define RESERVERD_CORES 2
+ static int next_cpu = RESERVERD_CORES;

void FFmpegDecoderVideo::decodeLoop()
{
    FFmpegPacket packet;
    double pts;
+     {
+         int num_cpus = OpenThreads::GetNumberOfProcessors();
+         if (num_cpus > RESERVERD_CORES + 1) {
+             int cpu = next_cpu;
+             ++next_cpu;
+             if (next_cpu >= num_cpus) next_cpu -= num_cpus -
RESERVERD_CORES;
+             if (cpu >= num_cpus) cpu -= num_cpus - RESERVERD_CORES;
+             OpenThreads::SetProcessorAffinityOfCurrentThread(cpu);
+             OSG_WARN << "FFmpegDecoderVideo::run :
OpenThreads::SetProcessorAffinityOfCurrentThread" << cpu << std::endl;
+         }
+     }

On Thu, Oct 5, 2017 at 4:54 PM, Robert Osfield <robert.osfield at gmail.com>
wrote:

> Hi Michael,
>
> On 5 October 2017 at 15:41, Michael Maurus <michael.maurus at web.de> wrote:
>
>> This was actually a nice hint.
>> Only one of my CPUs was working at full capacity.
>>
>
> I haven't looked at the code recently so I'm a bit cold on the ffmpeg
> implementation side.  I don't recall any external way to control the
> threads that the ffmpeg creates.
>
> From what it sounds like is the threads that the ffmpeg plugin is creating
> is inheriting the affinity of the thread that created them.  In OSG master
> there is finer grained control over the affinity setting behaviour, in your
> case it might be appropriate to disable the default setting of affinity.
>
> In an ideal world you want to decided which threads you want to run on
> what threads, but this reques knowledge of all the threads, their needs,
> and the hardware you are working on.
>
> FYI, the OSG by default tries to make a best guess based on your the
> number of CPU cores the OS says the machine has and the configuration of
> your viewer, this scheme doesn't know about any extra threads that plugins
> might create though.  This scheme is more hardwired in OSG-3.4 and prior
> releases, so master might be the thing to use if you do end up needing more
> control.
>
> Robert.
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20171006/9d1816ba/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FFmpegDecoderVideo.zip
Type: application/zip
Size: 3682 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20171006/9d1816ba/attachment-0001.zip>


More information about the osg-users mailing list