- Mlt::Frame * m_frame;
- mlt_image_format format = mlt_image_rgb24a;
- Mlt::Filter m_convert(prof, "avcolour_space");
- m_convert.set("forced", mlt_image_rgb24a);
- m_producer.attach(m_convert);
- //m_producer.seek(frame);
- m_frame = m_producer.get_frame();
- if (m_frame && m_frame->is_valid()) {
- uint8_t *thumb = m_frame->get_image(format, width, height);
- QImage image(thumb, width, height, QImage::Format_ARGB32);
- if (!image.isNull()) {
- pix = pix.fromImage(image);
- }
- else pix.fill(Qt::black);
+ Mlt::Frame *mltFrame;
+ 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(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(frame2, pix);
+ }