-void ThumbThread::run() {
- if (m_frame1 != -1 && m_prod) {
- //mutex.lock();
- m_prod->seek(m_frame1);
- Mlt::Frame *avframe = m_prod->get_frame();
- //mutex.unlock();
- if (!avframe) {
- kDebug() << "///// BROKEN FRAME";
- } else {
- mlt_image_format format = mlt_image_yuv422;
- int frame_width = m_width;
- int frame_height = m_height;
- avframe->set("normalised_height", m_height);
- avframe->set("normalised_width", m_width);
- uint8_t *data = avframe->get_image(format, frame_width, frame_height, 0);
- uint8_t *new_image = (uint8_t *)mlt_pool_alloc(frame_width * (frame_height + 1) * 4);
- mlt_convert_yuv422_to_rgb24a((uint8_t *)data, new_image, frame_width * frame_height);
-
- QImage image((uchar *)new_image, frame_width, frame_height, QImage::Format_ARGB32);
-
- if (!image.isNull()) {
- emit gotStartThumb(image.rgbSwapped());
- //QApplication::postEvent(m_parent, new ThumbEvent(m_frame1, image.rgbSwapped(), (QEvent::Type)10006));
- //pix = QPixmap::fromImage(image.rgbSwapped());
- } /*else
- pix.fill(Qt::red);*/
- mlt_pool_release(new_image);
- delete avframe;
- }
- //pix.fill(Qt::red);
-
- }
- if (m_frame2 != -1 && m_prod) {
- //mutex.lock();
- m_prod->seek(m_frame2);
- Mlt::Frame *avframe = m_prod->get_frame();
- //mutex.unlock();
- if (!avframe) {
- kDebug() << "///// BROKEN FRAME";
- } else {
- mlt_image_format format = mlt_image_yuv422;
- int frame_width = 0;
- int frame_height = 0;
- avframe->set("normalised_height", m_height);
- avframe->set("normalised_width", m_width);
- uint8_t *data = avframe->get_image(format, frame_width, frame_height, 0);
- uint8_t *new_image = (uint8_t *)mlt_pool_alloc(frame_width * (frame_height + 1) * 4);
- mlt_convert_yuv422_to_rgb24a((uint8_t *)data, new_image, frame_width * frame_height);
-
- QImage image((uchar *)new_image, frame_width, frame_height, QImage::Format_ARGB32);
-
- if (!image.isNull()) {
- emit gotEndThumb(image.rgbSwapped());
- //QApplication::postEvent(m_parent, new ThumbEvent(m_frame2, image.rgbSwapped(), (QEvent::Type)10006));
- //pix = QPixmap::fromImage(image.rgbSwapped());
- } /*else
- pix.fill(Qt::red);*/
- mlt_pool_release(new_image);
- delete avframe;
- }
- //pix.fill(Qt::red);
- //QApplication::postEvent(m_parent, new ThumbEvent(m_frame2, pix, (QEvent::Type)10006));
- }