- QApplication::postEvent(m_parent, new ProgressEvent(-1, (QEvent::Type)10005));
-
-}
-
-void ThumbThread::init(QObject *parent, Mlt::Producer *prod, int width, int height) {
- stop_me = false;
- m_parent = parent;
- m_isWorking = false;
- m_prod = prod;
- m_width = width;
- m_height = height;
- m_frame1 = -1;
- m_frame2 = -1;
-}
-
-bool ThumbThread::isWorking() {
- return m_isWorking;
-}
-
-void ThumbThread::setThumbFrames(Mlt::Producer *prod, int frame1, int frame2) {
- if (!m_prod) m_prod = prod;
- m_frame1 = frame1;
- m_frame2 = frame2;
-}
-
-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);