]> git.sesse.net Git - kdenlive/blobdiff - src/kthumb.cpp
Update free space info every 30 seconds when capturing
[kdenlive] / src / kthumb.cpp
index faff1ab8fe1206d814c5d9502267b0c8dda14b72..8d15736749f784f9d763652812faa4e89c48723f 100644 (file)
@@ -88,11 +88,10 @@ void MyThread::run()
         m_producer.seek(z);
         Mlt::Frame *mlt_frame = m_producer.get_frame();
         if (mlt_frame && mlt_frame->is_valid()) {
-            double m_framesPerSecond = mlt_producer_get_fps(m_producer.get_producer());   //mlt_frame->get_double( "fps" );
+            double m_framesPerSecond = mlt_producer_get_fps(m_producer.get_producer());
             int m_samples = mlt_sample_calculator(m_framesPerSecond, m_frequency, mlt_frame_get_position(mlt_frame->get_frame()));
             mlt_audio_format m_audioFormat = mlt_audio_pcm;
-
-                       qint16* m_pcm = static_cast<qint16*>( mlt_frame->get_audio(m_audioFormat, m_frequency, m_channels, m_samples));
+            qint16* m_pcm = static_cast<qint16*>(mlt_frame->get_audio(m_audioFormat, m_frequency, m_channels, m_samples));
 
             for (int c = 0; c < m_channels; c++) {
                 QByteArray m_array;
@@ -191,18 +190,18 @@ void KThumb::extractImage(int frame, int frame2)
     const int theight = KdenliveSettings::trackheight();
 
     if (frame != -1) {
-        QPixmap pix = getFrame(m_producer, frame, twidth, theight);
+        QPixmap pix = QPixmap::fromImage(getFrame(m_producer, frame, twidth, theight));
         emit thumbReady(frame, pix);
     }
     if (frame2 != -1) {
-        QPixmap pix = getFrame(m_producer, frame2, twidth, theight);
+        QPixmap pix = QPixmap::fromImage(getFrame(m_producer, frame2, twidth, theight));
         emit thumbReady(frame2, pix);
     }
 }
 
 QPixmap KThumb::extractImage(int frame, int width, int height)
 {
-    return getFrame(m_producer, frame, width, height);
+    return QPixmap::fromImage(getFrame(m_producer, frame, width, height));
 }
 
 //static
@@ -220,16 +219,16 @@ QPixmap KThumb::getImage(KUrl url, int frame, int width, int height)
     Mlt::Producer *producer = new Mlt::Producer(profile, tmp);
     delete[] tmp;
 
-    pix = getFrame(producer, frame, width, height);
+    pix = QPixmap::fromImage(getFrame(producer, frame, width, height));
     delete producer;
     return pix;
 }
 
 
 //static
-QPixmap KThumb::getFrame(Mlt::Producer *producer, int framepos, int width, int height)
+QImage KThumb::getFrame(Mlt::Producer *producer, int framepos, int width, int height)
 {
-    QPixmap p(width, height);
+    QImage p(width, height, QImage::Format_ARGB32);
     if (producer == NULL) {
         p.fill(Qt::red);
         return p;
@@ -248,14 +247,17 @@ QPixmap KThumb::getFrame(Mlt::Producer *producer, int framepos, int width, int h
         return p;
     }
 
+    /*Mlt::Producer parentProd(producer->parent());
+    Mlt::Service service(parentProd.get_service());
+    mlt_service_lock(service.get_service());*/
+
     mlt_image_format format = mlt_image_rgb24a;
-    int frame_width = width;
-    int frame_height = height;
-    uint8_t *data = frame->get_image(format, frame_width, frame_height, 0);
-    QImage image((uchar *)data, frame_width, frame_height, QImage::Format_ARGB32);
+    uint8_t *data = frame->get_image(format, width, height, 0);
+    QImage image((uchar *)data, width, height, QImage::Format_ARGB32);
+    //mlt_service_unlock(service.get_service());
 
     if (!image.isNull()) {
-        p = QPixmap::fromImage(image.rgbSwapped());
+        p = image.rgbSwapped();
     } else
         p.fill(Qt::red);