After building Qt 5.0 on Raspberry Pi, I focused the attention to hardware acceleration using OpenMAX. This
is quite an interesting subject to study. The most interesting element I found among those available for
VideoCore is the egl_render component. This component should be able to render content coming from the output
of the decoder component directly into an EGL image, which is bound to a texture.
Of much interest for me is rendering video into an texture, but I thought for the moment I could start just
with decoding an image and placing it to an OpenGL texture for rendering. This can be done by using the
image_decode component and the egl_render component. Refer to the
documentation in the git
for some more information.
Unfortunately not much documentation is available for this task, but I found something very interesting that
helped me out much:
- This source code by Matt Ownby: I reused much of his excellent work.
- This project by Qt
- The textures example from Qt sources
The code I wrote is provided in a package below. I ran some tests by using the original way of loading
textures:
QGLWidget::bindTexture(QPixmap(fileAbsolutePath, GL_TEXTURE_2D, GL_RGBA));
and the method using the egl_render OpenMAX component.
These are the results I got by loading 6 jpegs 1920x1080:
Average time out of 5 runs without OMX: 6750ms;
Average time out of 5 runs with OMX: 918ms.
Here is the package containing the sources (version 1.0):
PiOmxTextures.tar.bz2. The code links to Qt 5.0 and needs 6 images to be
specified on the command line to load. You need to move the images to the same directory (no spaces) and
to name those images like:
prefix{0, 1, 2, 3, 4, 5}.jpg
To compile you'll need Qt Creator or at least qmake:
cd PiOmxTextures
your_qmake
make
This is a video showing the performance loading 6 1080p jpegs, first the software decoding is used, second and third run are hardware accelerated:
Sorry the quality is really bad, but the performance can be appreciated anyway. Also it seems that for some reason the software implementation failed to load one image, you can see a black texture on the side of the cube. The same is not happening with the hardware implementation. Didn't investigate the reason.
This is not a ready-to-use code, just some notes that might be useful. I've almost never used OpenMAX or OpenGL so
if you happen to have any suggestion or observation, feel free to comment! ;-)