]> git.sesse.net Git - kdenlive/blobdiff - src/kthumb.cpp
edit and delete markers
[kdenlive] / src / kthumb.cpp
index 12b8403202b5a6c1f0d5c6eb6abf71d5c7d1bd66..5a91927c87d33ef67c0986bd3c7001e3add07b99 100644 (file)
@@ -20,8 +20,6 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <qapplication.h>
-
 #include <kio/netaccess.h>
 #include <kdebug.h>
 #include <klocale.h>
@@ -136,7 +134,7 @@ void MyThread::run() {
 #define _G(y,u,v) (0x2568*(y) - 0x0c92*(v) - 0x1a1e*(u)) /0x2000
 #define _B(y,u,v) (0x2568*(y) + 0x40cf*(v))                                          /0x2000
 
-KThumb::KThumb(ClipManager *clipManager, KUrl url, int width, int height, QObject * parent, const char *name): QObject(parent), m_clipManager(clipManager), m_url(url), m_width(width), m_height(height) {
+KThumb::KThumb(ClipManager *clipManager, KUrl url, QObject * parent, const char *name): QObject(parent), m_clipManager(clipManager), m_url(url) {
 
     m_profile = new Mlt::Profile((char*) KdenliveSettings::current_profile().data());
     QCryptographicHash context(QCryptographicHash::Sha1);
@@ -150,6 +148,9 @@ KThumb::~KThumb() {
     if (thumbProducer.isRunning()) thumbProducer.exit();
 }
 
+void KThumb::updateClipUrl(KUrl url) {
+    m_url = url;
+}
 
 //static
 QPixmap KThumb::getImage(KUrl url, int width, int height) {
@@ -190,20 +191,19 @@ void KThumb::extractImage(int frame, int frame2) {
     char *tmp = Render::decodedString(m_url.path());
     Mlt::Producer m_producer(*m_profile, tmp);
     delete[] tmp;
-
-    QPixmap pix(m_width, m_height);
+    int twidth = (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio());
     if (m_producer.is_blank()) {
-        QPixmap pix(m_width, m_height);
+        QPixmap pix(twidth, KdenliveSettings::trackheight());
         pix.fill(Qt::black);
         emit thumbReady(frame, pix);
         return;
     }
     if (frame != -1) {
-        QPixmap pix = getFrame(&m_producer, frame, m_width, m_height);
+        QPixmap pix = getFrame(&m_producer, frame, twidth, KdenliveSettings::trackheight());
         emit thumbReady(frame, pix);
     }
     if (frame2 != -1) {
-        QPixmap pix = getFrame(&m_producer, frame2, m_width, m_height);
+        QPixmap pix = getFrame(&m_producer, frame2, twidth , KdenliveSettings::trackheight());
         emit thumbReady(frame2, pix);
     }
 
@@ -223,7 +223,25 @@ QPixmap KThumb::getImage(KUrl url, int frame, int width, int height) {
         return pix;
     }
     return getFrame(&producer, frame, width, height);
+}
 
+QPixmap KThumb::getImage(QDomElement xml, int frame, int width, int height) {
+    Mlt::Profile profile((char*) KdenliveSettings::current_profile().data());
+    QPixmap pix(width, height);
+    QDomDocument doc;
+    QDomElement westley = doc.createElement("westley");
+    doc.appendChild(westley);
+    westley.appendChild(doc.importNode(xml, true));
+    char *tmp = Render::decodedString(doc.toString());
+    kDebug() << " - - - UPDATING THMB, XML: " << doc.toString();
+    Mlt::Producer producer(profile, "westley-xml", tmp);
+    delete[] tmp;
+
+    if (producer.is_blank()) {
+        pix.fill(Qt::black);
+        return pix;
+    }
+    return getFrame(&producer, frame, width, height);
 }
 
 QPixmap KThumb::getFrame(Mlt::Producer* producer, int frame, int width, int height) {
@@ -231,8 +249,8 @@ QPixmap KThumb::getFrame(Mlt::Producer* producer, int frame, int width, int heig
     Mlt::Filter m_convert(profile, "avcolour_space");
     m_convert.set("forced", mlt_image_rgb24a);
     producer->attach(m_convert);
-
-    producer->seek(frame);
+    if (frame > -1)
+        producer->seek(frame);
     Mlt::Frame * m_frame = producer->get_frame();
     mlt_image_format format = mlt_image_rgb24a;
     QPixmap pix(width, height);