Greetings QtCenters,

I'm currently trying to render a VLC video inside a QGraphicsScene.

I'm using the following code:
Qt Code:
  1. //------------------------------------------------------------------------------------------
  2. // VLC callbacks
  3. //------------------------------------------------------------------------------------------
  4.  
  5. /* static */ void * Player::lock(void * data, void ** buffer)
  6. {
  7. Player * player = static_cast<Player *> (data);
  8.  
  9. *buffer = player->_image.bits();
  10.  
  11. return NULL;
  12. }
  13.  
  14. /* static */ void Player::unlock(void * data, void *, void * const *)
  15. {
  16. Player * player = static_cast<Player *> (data);
  17.  
  18. QCoreApplication::postEvent(player, new QEvent(QEvent::User));
  19. }
  20.  
  21. //------------------------------------------------------------------------------------------
  22.  
  23. bool Player::event(QEvent * event)
  24. {
  25. if (event->type() == QEvent::User)
  26. {
  27. update();
  28.  
  29. return true;
  30. }
  31. else return QObject::event(event);
  32. }
  33.  
  34. void Player::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
  35. {
  36. painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
  37.  
  38. painter->setBrush(Qt::black);
  39.  
  40. painter->drawRect(option->rect);
  41.  
  42. painter->drawImage(0, 0, _image);
  43.  
  44. // The next call is very slow, even using an Opengl viewport
  45. painter->drawImage(_targetRect, _image, QRectF(0, 0, _image.width(), _image.height()));
  46. }
To copy to clipboard, switch view to plain text mode 
I'm testing with a 1080p video. For some reason the drawImage call seems to slow things down. This is not a surprise in software, but it's also pretty slow in Opengl.

My question is, assuming I want to use Opengl, is there a faster way to render a video frame into a QGraphicsScene using Qt 4.8 ?

Thanks.