I'm working on code, that would simply play video frames using ffmpeg in QWidget. All of code is based on this tutorial: http://dranger.com/ffmpeg/tutorial01.c

I'll show only the part where I paint the image (since the rest is the same as in the tutorial I linked):
Qt Code:
  1. void MagicCube::PaintFrame(AVFrame *pFrame, int width, int height)
  2. {
  3. QImage image(width, height, QImage::Format_RGB32);
  4. int x, y;
  5. int *src = (int*)pFrame->data[0];
  6.  
  7. for (y = 0; y < height; y++)
  8. {
  9. for (x = 0; x < width; x++)
  10. {
  11. image.setPixel(x, y, src[x] & 0x00ffffff);
  12. }
  13. src += width;
  14. }
  15.  
  16. QPainter painter(this);
  17. painter.drawImage(QRect(10, 37, width, height), image);
  18. }
To copy to clipboard, switch view to plain text mode 
The current code is working, but it has its problems - it's using 40+% of CPU. So, is there a way to avoid all the loops and just load the data into image (I tried a lot of combinations but with no success) or any other method?

Thanks.