Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Fix loading keyframes now that we use click times instead of frames

parent f1ed81e7
......@@ -25,6 +25,7 @@
#include "macros.hpp"
#include "rotoscoping/bpoint.h"
#include "rotoscoping/rotohelper.hpp"
#include "profiles/profilemodel.hpp"
#include <QDebug>
#include <QJsonDocument>
......@@ -744,21 +745,23 @@ void KeyframeModel::parseAnimProperty(const QString &prop)
QLocale locale;
disconnect(this, &KeyframeModel::modelChanged, this, &KeyframeModel::sendModification);
removeAllKeyframes(undo, redo);
mlt_prop.set("_profile", pCore->getCurrentProfile()->get_profile(), 0);
mlt_prop.set("key", prop.toUtf8().constData());
// This is a fake query to force the animation to be parsed
(void)mlt_prop.anim_get_int("key", 0, 0);
(void)mlt_prop.anim_get_double("key", 0, 0);
Mlt::Animation *anim = mlt_prop.get_anim("key");
std::shared_ptr<Mlt::Animation> anim(mlt_prop.get_anim("key"));
int in = 0;
if (auto ptr = m_model.lock()) {
in = ptr->data(m_index, AssetParameterModel::ParentInRole).toInt();
}
qDebug() << "Found" << anim->key_count() << "animation properties";
qDebug() << "Found" << anim->key_count() << "animation properties: "<<prop;
bool useDefaultType = !prop.contains(QLatin1Char('='));
for (int i = 0; i < anim->key_count(); ++i) {
int frame;
mlt_keyframe_type type;
anim->key_get(i, frame, type);
if (!prop.contains(QLatin1Char('='))) {
if (useDefaultType) {
// TODO: use a default user defined type
type = mlt_keyframe_linear;
}
......@@ -783,7 +786,6 @@ void KeyframeModel::parseAnimProperty(const QString &prop)
}
addKeyframe(GenTime(frame, pCore->getCurrentFps()), convertFromMltType(type), value, true, undo, redo);
}
delete anim;
connect(this, &KeyframeModel::modelChanged, this, &KeyframeModel::sendModification);
}
......@@ -797,6 +799,7 @@ void KeyframeModel::resetAnimProperty(const QString &prop)
removeAllKeyframes(undo, redo);
Mlt::Properties mlt_prop;
mlt_prop.set("_profile", pCore->getCurrentProfile()->get_profile(), 0);
QLocale locale;
int in = 0;
if (auto ptr = m_model.lock()) {
......@@ -935,6 +938,7 @@ QVariant KeyframeModel::getInterpolatedValue(const GenTime &pos) const
--prev;
// We now have surrounding keyframes, we use mlt to compute the value
Mlt::Properties prop;
prop.set("_profile", pCore->getCurrentProfile()->get_profile(), 0);
QLocale locale;
int p = pos.frames(pCore->getCurrentFps());
if (m_paramType == ParamType::KeyframeParam) {
......@@ -1091,6 +1095,7 @@ void KeyframeModel::reset()
QList<QPoint> KeyframeModel::getRanges(const QString &animData)
{
Mlt::Properties mlt_prop;
mlt_prop.set("_profile", pCore->getCurrentProfile()->get_profile(), 0);
QLocale locale;
mlt_prop.set("key", animData.toUtf8().constData());
// This is a fake query to force the animation to be parsed
......
......@@ -24,7 +24,6 @@
#include "kdenlive_debug.h"
#include "kdenlivesettings.h"
#include <KLocalizedString>
#include <mlt++/MltProfile.h>
#include <KMessageWidget>
#include <QDir>
......@@ -134,6 +133,11 @@ QString ProfileModel::path() const
return m_path;
}
mlt_profile ProfileModel::get_profile() const
{
return m_profile->get_profile();
}
void ProfileModel::set_explicit(int b)
{
m_profile->set_explicit(b);
......
......@@ -27,9 +27,7 @@
#include <QString>
#include <memory>
namespace Mlt {
class Profile;
}
#include <mlt++/MltProfile.h>
/** @brief This is a wrapper around Mlt::Profile to be used by the rest of kdenlive.
* It has implicit conversion to Mlt::Profile so you can use it directly in calls to Mlt backend.
......@@ -64,6 +62,7 @@ public:
int is_explicit() const;
void set_explicit(int b);
int colorspace() const override;
mlt_profile get_profile() const;
QString path() const override;
void adjustDimensions() override{};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment