I am currently trying to write an application that displays live “video” from a specialized USB device. The USB device provides approx. 10 frames/sec of 320×240 video in an array of gray levels. The application is written in Qt on an iMx51 (800Mhz arm) platform running linux and X11. My application needs to display this video, scaled by a factor of 2 (so 640×480) and use as little CPU as possible.
Currently, the images are displayed as a simple QLabel which updates it’s pixmap every time a new video frame has been transmitted from the device. When the QLabel is being displayed at 320×240 the video plays smoothly and the application uses 20% of the CPU.
When we attempt to scale the QLabel to 640×480 in size the CPU usage spikes, consuming all available resources at 10frames/sec. Our only means of reducing the CPU usage is to drop frames.
We have tried writing a widget with a custom paint event to paint the contents of the video image ourselves to no avail, this technique used slightly more CPU than the QLabel.
Our other products that do this have the capability to blit the image directly to a raw frame buffer (no x11) and despite their much slower CPU’s they can handle this task without any problem. It seems that X11 and Qt is adding an immense amount of overhead for us.
There must be a PROPER way to display a constantly updating image through Qt and X11 that is not so resource intensive. We are exploring the possibility of getting openGL ES up and running on the unit but that may be out of the question for the time being. Is there something I’m missing in the Qt Framework that will allow me to accomplish this relatively simple task?
After downloading and reading through the VLC source code I settled on using the Xvideo extension for X11. The VLC source code contains an xvideo output “engine” using xcb to communicated with the xserver. I used this as an example to code my own solution.
On our platform the scaling and display features of the xvideo extension are hardware accelerated.
I intend to provide a tutorial and example code as soon as time allows.