]> git.sesse.net Git - kdenlive/commitdiff
Some smaller cleanups related to project loading
authorTill Theato <root@ttill.de>
Sun, 14 Nov 2010 19:59:49 +0000 (19:59 +0000)
committerTill Theato <root@ttill.de>
Sun, 14 Nov 2010 19:59:49 +0000 (19:59 +0000)
svn path=/trunk/kdenlive/; revision=5097

src/kthumb.cpp
src/projectlist.cpp
src/renderer.cpp

index f72bd22169eb9638163bb7ac1475a5456f69df13..3986e3e53eadbfaa8779b86f685676cf47ca4d49 100644 (file)
@@ -383,12 +383,20 @@ void KThumb::getAudioThumbs(int channel, double frame, double frameLength, int a
             slotAudioThumbOver();
             return;
         }
+
         kDebug() << "reading audio thumbs from file";
+
+        int h1 = arrayWidth * m_channels;
+        int h2 = (int) frame * h1;
+        int h3;
         for (int z = (int) frame; z < (int)(frame + frameLength); z++) {
+            h2 += h1;
+            h3 = 0;
             for (int c = 0; c < m_channels; c++) {
+                h3 += arrayWidth;
                 QByteArray m_array(arrayWidth, '\x00');
                 for (int i = 0; i < arrayWidth; i++)
-                    m_array[i] = channelarray[z*arrayWidth*m_channels + c*arrayWidth + i];
+                    m_array[i] = channelarray[h2 + h3 + i];
                 storeIn[z][c] = m_array;
             }
         }
index b674b1f9f5d8d1ca5e862d81394cb8b8b1a08681..b66803a909e11bf2796ba1ef0806adea3489489e 100644 (file)
@@ -1446,7 +1446,8 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
         }
         if (update)
             emit projectModified();
-        QTimer::singleShot(30, this, SLOT(slotProcessNextThumbnail()));
+
+        slotProcessNextThumbnail();
     }
 }
 
@@ -1462,7 +1463,6 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
             toReload = clipId;
         }
-        //Q_ASSERT_X(item->referencedClip(), "void ProjectList::slotReplyGetFileProperties", QString("Item with groupName %1 does not have a clip associated").arg(item->groupName()).toLatin1());
         item->referencedClip()->setProducer(producer, replace);
         item->referencedClip()->askForAudioThumbs();
         if (!replace && item->data(0, Qt::DecorationRole).isNull())
@@ -1470,7 +1470,6 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
         if (!toReload.isEmpty())
             item->slotSetToolTip();
 
-        //emit receivedClipDuration(clipId);
         if (m_listView->isEnabled() && replace) {
             // update clip in clip monitor
             emit clipSelected(NULL);
@@ -1489,7 +1488,6 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             requestClipThumbnail(clipId);
         }*/
     } else kDebug() << "////////  COULD NOT FIND CLIP TO UPDATE PRPS...";
-    int max = m_doc->clipManager()->clipsCount();
     if (item && m_infoQueue.isEmpty() && m_thumbnailQueue.isEmpty()) {
         m_listView->setCurrentItem(item);
         bool updatedProfile = false;
@@ -1502,12 +1500,14 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
         }
         if (updatedProfile == false) emit clipSelected(item->referencedClip());
     } else {
+        int max = m_doc->clipManager()->clipsCount();
         emit displayMessage(i18n("Loading clips"), (int)(100 *(max - m_infoQueue.count()) / max));
     }
     if (!toReload.isEmpty())
         emit clipNeedsReload(toReload, true);
-    // small delay so that the app can display the progress info
-    QTimer::singleShot(30, this, SLOT(slotProcessNextClipInQueue()));
+
+    qApp->processEvents();
+    slotProcessNextClipInQueue();
 }
 
 bool ProjectList::adjustProjectProfileToItem(ProjectItem *item)
index 7c63b47912048781748ec7235ad3112d75c42264..d48e8c94c037f661c9a3b108a8df30e609d2da8a 100644 (file)
@@ -517,14 +517,17 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
 {
     KUrl url = KUrl(xml.attribute("resource", QString()));
     Mlt::Producer *producer = NULL;
+    CLIPTYPE type = (CLIPTYPE)xml.attribute("type").toInt();
+
     //kDebug() << "PROFILE WIDT: "<< xml.attribute("mlt_service") << ": "<< m_mltProfile->width() << "\n...................\n\n";
     /*if (xml.attribute("type").toInt() == TEXT && !QFile::exists(url.path())) {
         emit replyGetFileProperties(clipId, producer, QMap < QString, QString >(), QMap < QString, QString >(), replaceProducer);
         return;
     }*/
-    if (xml.attribute("type").toInt() == COLOR) {
+
+    if (type == COLOR) {
         producer = new Mlt::Producer(*m_mltProfile, 0, ("colour:" + xml.attribute("colour")).toUtf8().constData());
-    } else if (xml.attribute("type").toInt() == TEXT) {
+    } else if (type == TEXT) {
         producer = new Mlt::Producer(*m_mltProfile, 0, ("kdenlivetitle:" + xml.attribute("resource")).toUtf8().constData());
         if (producer && producer->is_valid() && xml.hasAttribute("xmldata"))
             producer->set("xmldata", xml.attribute("xmldata").toUtf8().constData());
@@ -598,8 +601,7 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
     }
 
     // setup length here as otherwise default length (currently 15000 frames in MLT) will be taken even if outpoint is larger
-    if (xml.attribute("type").toInt() == COLOR || xml.attribute("type").toInt() == TEXT
-            || xml.attribute("type").toInt() == IMAGE || xml.attribute("type").toInt() == SLIDESHOW)
+    if (type == COLOR || type == TEXT || type == IMAGE || type == SLIDESHOW)
         producer->set("length", xml.attribute("out").toInt() - xml.attribute("in").toInt() + 1);
 
     if (xml.hasAttribute("out"))
@@ -628,7 +630,7 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
 
     Mlt::Frame *frame = producer->get_frame();
 
-    if (xml.attribute("type").toInt() == SLIDESHOW) {
+    if (type == SLIDESHOW) {
         int ttl = xml.hasAttribute("ttl") ? xml.attribute("ttl").toInt() : 0;
         if (ttl) producer->set("ttl", ttl);
         if (!xml.attribute("animation").isEmpty()) {