]> git.sesse.net Git - kdenlive/blobdiff - src/renderer.cpp
Fixed: All scopes were working forever when the input image had size 0
[kdenlive] / src / renderer.cpp
index 3e7e53f113e958cf0d715afeb38d607bbc59cbf0..07c2e98cea472828661ed3ec5ef02edfffdc1224 100644 (file)
@@ -65,6 +65,8 @@ static void consumer_frame_show(mlt_consumer, Render * self, mlt_frame frame_ptr
 #endif
 
     self->emitFrameNumber(mlt_frame_get_position(frame_ptr));
+    if (frame_ptr->convert_image)
+        self->emitFrameUpdated(frame);
     if (frame.get_double("_speed") == 0.0) {
         self->emitConsumerStopped();
     } else if (frame.get_double("_speed") < 0.0 && mlt_frame_get_position(frame_ptr) <= 0) {
@@ -750,10 +752,14 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int
             int frame_height = imageHeight;
             uint8_t *data = frame->get_image(format, frame_width, frame_height, 0);
             QImage image((uchar *)data, frame_width, frame_height, QImage::Format_ARGB32);
-            QPixmap pix(frame_width, frame_height);
+            QPixmap pix;
 
             if (!image.isNull()) {
-                pix = QPixmap::fromImage(image.rgbSwapped());
+                if (frame_width > (2 * width)) {
+                    // there was a scaling problem, do it manually
+                    QImage scaled = image.scaled(width, imageHeight);
+                    pix = QPixmap::fromImage(scaled.rgbSwapped());
+                } else pix = QPixmap::fromImage(image.rgbSwapped());
             } else
                 pix.fill(Qt::black);
 
@@ -1434,12 +1440,19 @@ const QString & Render::rendererName() const
     return m_name;
 }
 
+void Render::emitFrameUpdated(Mlt::Frame& frame)
+{
+    mlt_image_format format = mlt_image_rgb24a;
+    int width = 0;
+    int height = 0;
+    const uchar* image = frame.get_image(format, width, height);
+    QImage qimage(width, height, QImage::Format_ARGB32);
+    memcpy(qimage.bits(), image, width * height * 4);
+    emit frameUpdated(qimage.rgbSwapped());
+}
+
 void Render::emitFrameNumber(double position)
 {
-    if (position == m_framePosition) {
-        emit frameUpdated((int) position);
-        return;
-    }
     m_framePosition = position;
     emit rendererPosition((int) position);
 }
@@ -3203,14 +3216,32 @@ void Render::mltUpdateTransitionParams(QString type, int a_track, int b_track, G
             QMap<QString, QString>::Iterator it;
             QString key;
             mlt_properties transproperties = MLT_TRANSITION_PROPERTIES(tr);
+
+            QString currentId = mlt_properties_get(transproperties, "kdenlive_id");
+            if (currentId != xml.attribute("id")) {
+                // The transition ID is not the same, so reset all properties
+                char *tmp = decodedString(xml.attribute("id"));
+                mlt_properties_set(transproperties, "kdenlive_id", tmp);
+                delete[] tmp;
+                // Cleanup previous properties
+                QStringList permanentProps;
+                permanentProps << "factory" << "kdenlive_id" << "mlt_service" << "mlt_type" << "in";
+                permanentProps << "out" << "a_track" << "b_track";
+                for (int i = 0; i < mlt_properties_count(transproperties); i++) {
+                    QString propName = mlt_properties_get_name(transproperties, i);
+                    if (!propName.startsWith('_') && ! permanentProps.contains(propName)) {
+                        tmp = decodedString(propName);
+                        mlt_properties_set(transproperties, tmp, "");
+                        delete[] tmp;
+                    }
+                }
+            }
+
             mlt_properties_set_int(transproperties, "force_track", xml.attribute("force_track").toInt());
             mlt_properties_set_int(transproperties, "automatic", xml.attribute("automatic", "0").toInt());
-            // update the transition id in case it uses the same MLT service but different Kdenlive id
-            char *tmp = decodedString(xml.attribute("id"));
-            mlt_properties_set(transproperties, "kdenlive_id", tmp);
-            delete[] tmp;
+
             if (currentBTrack != a_track) {
-                mlt_properties_set_int(properties, "a_track", a_track);
+                mlt_properties_set_int(transproperties, "a_track", a_track);
             }
             for (it = map.begin(); it != map.end(); ++it) {
                 key = it.key();