+ return getFrame(producer, frame, width, height);
+}*/
+
+//static
+QPixmap KThumb::getFrame(Mlt::Producer *producer, int framepos, int width, int height) {
+ if (producer == NULL) {
+ QPixmap p(width, height);
+ p.fill(Qt::red);
+ return p;
+ }
+
+ producer->seek(framepos);
+ Mlt::Frame *frame = producer->get_frame();
+ if (!frame) {
+ kDebug() << "///// BROKEN FRAME";
+ QPixmap p(width, height);
+ p.fill(Qt::red);
+ return p;
+ }
+
+ mlt_image_format format = mlt_image_yuv422;
+ int frame_width = 0;
+ int frame_height = 0;
+ frame->set("normalised_height", height);
+ frame->set("normalised_width", width);
+ QPixmap pix(width, height);
+ uint8_t *data = frame->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);