[Interest] How does QVideoFilterRunnable manage the OpenGL Context ?

Nicolas FANJAT nicolas.fanjat at lab-solutec.fr
Thu May 19 09:23:05 CEST 2016


Hi all,
I am currently working on a mobile application that would display the camera stream.
Since I need to process every frame before rendering I chose to use QAbstractVideoFilter and QVideoFilterRunnable classes. And since I am developing for Android devices (the video frames come as GL textures) I want to use as many raw OpenGL calls before sending back the video frame to the CPU.
The run function would look to something like that :
QVideoFrame MyFilterRunnable::run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags)
{
    Q_UNUSED(surfaceFormat);
    Q_UNUSED(flags);

    // Checking Input first...

    // Getting the texture ID
    texture = input->handle().toUInt();

    // ...
    // Processing the frame using GL calls
    // ...

    return QVideoFrame(frameFromTexture(outTexture, inputSize, input->pixelFormat()));
}
The idea doesn't seem complicated but I noticed a few things about the GL context used by the filter that bother me, and I need some help understanding the whole picture behind it :

  *   According to the documentation the run function is always called on the render thread (the one which is supposed to hold the OpenGL context) - that I'm ok with
  *   The FilterRunnable object is created once and then the run function is launched at every new frame received - that I'm still ok with
  *   On every new call to the run function the context seems to have been reset (I can provide some examples if needed) - that I'm not ok with
Now, I wish I understood what happens just before and after run calls. To me it really looks like that between every call the GL context is somewhat cleared, but I'm not sure of it.
I'm developing an app that needs to be as efficient as possible (processing the frames in less than 40ms), so that's why I really want to understand as clearly as possible what's happening so that I can optimize the process as much as possible.
Thank you if anyone can explain me the behavior of these two classes,
Nicolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160519/b3aea21a/attachment.html>


More information about the Interest mailing list