I am trying to write a video application in PyQt4, and I used Python types to connect to the old generation video decoder library. The library gives me 32-bit ARGB data, and I need to turn this into a QImage. It works for me as follows:
memmove(self.rgb_buffer, self.rgb_buffer_ptr, self.buffer_size)
imgdata = ""
for a in self.rgb_buffer:
imgdata = imgdata + a
img = QImage(imgdata, 720, 288, QImage.Format_ARGB32)
The problem is that ctypes displays the data as a type " ctypes.c_char_Array_829440", and I need to turn it into a python string so that I can build a QImage. Currently, my copy engine takes almost 300 ms per image, so it is very slow. Part of the decoding and display of the process takes only about 50 ms.
Can someone think of some tricky shortcuts that I can take to speed up this process and avoid having to copy the buffer twice, as I am doing now?
source
share