- mlt_image_format format = mlt_image_yuv422;
- if (m_producer->is_blank()) {
- QPixmap pix(twidth, theight);
- pix.fill(Qt::black);
- emit thumbReady(frame, pix);
- return;
- }
- 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);
- }
- }
+void KThumb::getThumb(int frame)
+{
+ const int theight = Kdenlive::DefaultThumbHeight;
+ const int swidth = (int)(theight * m_ratio + 0.5);
+ const int dwidth = (int)(theight * m_dar + 0.5);
+ QImage img = getProducerFrame(frame, swidth, dwidth, theight);
+ emit thumbReady(frame, img);
+}
+
+void KThumb::getGenericThumb(int frame, int height, int type)
+{
+ const int swidth = (int)(height * m_ratio + 0.5);
+ const int dwidth = (int)(height * m_dar + 0.5);
+ QImage img = getProducerFrame(frame, swidth, dwidth, height);
+ m_clipManager->projectTreeThumbReady(m_id, frame, img, type);