QT, convert raw image to jpg using Hardware acceleration (gpu)
Asked Answered
A

2

0

I need to convert an Raw image buffer into a jpg image buffer.

At the moment, I do this operation in the following way:

QImage tmpImage 
         = QImage(rawImgBuffer, img_width, img_height, image.format ); //image.format=RGB888 
QBuffer bufferJpeg(&ba);
bufferJpeg.open(QIODevice::WriteOnly);
tmpImage.save(&bufferJpeg, "JPG");
QByteArray finalJpgBuffer = bufferJpeg.data();

It works fine but the cpu load is too high (I have a lot of threads that do this operation a lot of time each second). Reading the Qt documentation I found this article: Hardware Acceleration &amp Embedded Platforms. If i understood, I can use the QPainter class to execute gpu operations... Is it possible to do this convertion (from raw to jpg) using this class? (or another similar Qt class that use hardware acceleration (gpu))!!

My application need to be platform indipendent.

Thanx at all.

Astrodynamics answered 5/10, 2011 at 14:18 Comment(0)
C
1

I don't think QImage uses the GPU to generate a jpeg.
This probably wouldn't help (except on very limited CPUs) since the transfer time of getting the data back out of the GPU would normally dominate. The reason for using hardware acceleration for display is that the result is then already in the GPU ready for display.

Claytor answered 5/10, 2011 at 14:39 Comment(1)
That is simply false. The link between the GPU and system memory is on the order of gigabytes per second, even in 2011. GPU encoding would save power and may be faster (depending on the speed of the GPU's encoding hardware).Sweeting
A
0

As far as I know decoding of image formats (jpeg in this case) is not handled by QPainter. It is done by Qt using libjpeg, which is controlled by Qt using a plugin. You can find the plugin in qt_source_tree/src/plugins/imageformats/jpeg. That is simply using the library you have available on your system (libjpeg.so in Linux). If it is hardware accelerated or not, it is up to your system.

I had a case in which hardware decoding required to use a specific library. In that case I had to create a specific Qt plugin to handle that.

Agrigento answered 5/10, 2011 at 15:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.