mhoover
27th July 2010, 22:24
My organization has created some software that displays video by reading frames over UDP and converting the uchar* data into a QImage that gets converted into a QPixmap which we display using setPixmap().
Machines with eight or so cores handle 30 Hz frames nicely, but they tend to get bogged down on conventional CPUs. A single player instance displaying 720x480 frames at 30 Hz ends up occupying 50% of the CPU (this is a dual-core MacBook Pro).
After learning about the performance overhead in converting QImages to QPixmaps (and with some help from the folks here on QtCenter.org) I was able to drop my uchar* data into a QByteArray and convert to a QPixmap. This ends up using about 56% of the CPU –or about 6% more than the QPixmap->QImage conversion.
Instead of creating a separate QByteArray for every frame, I added a QByteArray member to the class that I resize to the size of the header + data. This shaved off about 2% of the cpu expense, but it’s still 4% more costly than the QImage->QPixmap conversion. I’m not sure why that would be?
I’m wondering if there is a way to optimize this process further … could the QByteArray be making a deep copy and slowing things up?
Any guesses?
This thread basically details how I did it:
http://www.qtcentre.org/threads/27998-Creating-a-pixmap-from-unsigned-char*
Machines with eight or so cores handle 30 Hz frames nicely, but they tend to get bogged down on conventional CPUs. A single player instance displaying 720x480 frames at 30 Hz ends up occupying 50% of the CPU (this is a dual-core MacBook Pro).
After learning about the performance overhead in converting QImages to QPixmaps (and with some help from the folks here on QtCenter.org) I was able to drop my uchar* data into a QByteArray and convert to a QPixmap. This ends up using about 56% of the CPU –or about 6% more than the QPixmap->QImage conversion.
Instead of creating a separate QByteArray for every frame, I added a QByteArray member to the class that I resize to the size of the header + data. This shaved off about 2% of the cpu expense, but it’s still 4% more costly than the QImage->QPixmap conversion. I’m not sure why that would be?
I’m wondering if there is a way to optimize this process further … could the QByteArray be making a deep copy and slowing things up?
Any guesses?
This thread basically details how I did it:
http://www.qtcentre.org/threads/27998-Creating-a-pixmap-from-unsigned-char*