- if (m_producer->is_blank()) {
- QPixmap pix(twidth, theight);
- pix.fill(Qt::black);
- if (frame != -1) emit thumbReady(frame, pix);
- if (frame2 != -1) emit thumbReady(frame2, pix);
- return;
- }
- Mlt::Frame *mltFrame;
- mlt_image_format format = mlt_image_yuv422;
- if (frame != -1) {
- //videoThumbProducer.getThumb(frame);
- m_producer->seek(frame);
- mltFrame = m_producer->get_frame();
- if (frame2 != -1) m_producer->seek(frame2);
- if (!mltFrame) {
- kDebug() << "///// BROKEN FRAME";
- QPixmap p(twidth, theight);
- p.fill(Qt::red);
- emit thumbReady(frame, p);
- return;
- } else {
- int frame_width = 0;
- int frame_height = 0;
- mltFrame->set("normalised_height", theight);
- mltFrame->set("normalised_width", twidth);
- QPixmap pix(twidth, theight);
- uint8_t *data = mltFrame->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()) {
- pix = QPixmap::fromImage(image.rgbSwapped());
- } else
- pix.fill(Qt::red);
-
- mlt_pool_release(new_image);
- delete mltFrame;
- emit thumbReady(frame, pix);
- }
- } else if (frame2 != -1) m_producer->seek(frame2);
- if (frame2 != -1) {
- mltFrame = m_producer->get_frame();
- if (!mltFrame) {
- kDebug() << "///// BROKEN FRAME";
- QPixmap p(twidth, theight);
- p.fill(Qt::red);
- emit thumbReady(frame2, p);
- return;
- } else {
- int frame_width = 0;
- int frame_height = 0;
- mltFrame->set("normalised_height", theight);
- mltFrame->set("normalised_width", twidth);
- QPixmap pix(twidth, theight);
- uint8_t *data = mltFrame->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()) {
- pix = QPixmap::fromImage(image.rgbSwapped());
- } else
- pix.fill(Qt::red);
-
- mlt_pool_release(new_image);
- delete mltFrame;
- emit thumbReady(frame2, pix);
- }
- }