Software rendering is not the only possible performance killer.
I also used to use QWidget for similar kinds of jobs, and it seems to be OK.
I assume the result of FFmpeg processing is an uncompressed byte array with YUV or RGB color scheme.
- You already have some memory allocated for your FFmpeg image frame.
- I believe you're creating your pixmaps with
QPixmap::fromImage(...), which implies copying.
- But first, you need to construct QImage, which may imply copying.
So we have one or two full copies every frame.
Try one of the QImage constructors that uses an existing memory buffer (see Qt docs).
Or, ideally, you should have a once allocated QImage and use its memory buffer with FFmpeg (FFmpeg directly writes to QImage)
Sublass QWidget, reimplement paintEvent() and paint your QImage (not QPixmap) there.
Ideally, it should be the same QImage from the previous step.
ffmpeg
{
mutex.lock();
write(image);
mutex.unlock();
}
QWidet::paintEvent
{
mutex.lock();
paint(image);
mutex.unlock();
}
You definitely can use QOpenGLWidget for GPU drawing, which, in my opinion, wouldn't help you much.
QOpenGLWidget uses buffered rendering (i.e. copying), and it will take some cycles to upload your image from the CPU side to the GPU side.
Transform operations will become faster, though.