Commit e48041f4 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Restore profile check feature on add clip

parent 21ae98d1
......@@ -4244,8 +4244,7 @@ void Bin::adjustProjectProfileToItem()
std::shared_ptr<AbstractProjectItem> item = m_itemModel->getBinItemByIndex(m_proxyModel->mapToSource(current));
auto clip = std::static_pointer_cast<ProjectClip>(item);
if (clip) {
QDomDocument doc;
ClipLoadTask::checkProfile(clip->clipId(), clip->toXml(doc, false), clip->originalProducer());
ClipLoadTask::checkProfile(clip->originalProducer());
}
}
}
......
......@@ -91,6 +91,7 @@ bool Core::build(bool testMode)
qRegisterMetaType<QDomElement>("QDomElement");
qRegisterMetaType<requestClipInfo>("requestClipInfo");
qRegisterMetaType<QVector<QPair<QString, QVariant>>>("paramVector");
qRegisterMetaType<ProfileParam*>("ProfileParam*");
if (!testMode) {
// Check if we had a crash
......
......@@ -1416,13 +1416,12 @@ void KdenliveDoc::slotSwitchProfile(const QString &profile_path, bool reloadThum
emit docModified(true);
}
void KdenliveDoc::switchProfile(std::unique_ptr<ProfileParam> &profile, const QString &id, const QDomElement &xml)
void KdenliveDoc::switchProfile(ProfileParam* pf)
{
Q_UNUSED(id)
Q_UNUSED(xml)
// Request profile update
// Check profile fps so that we don't end up with an fps = 30.003 which would mess things up
QString adjustMessage;
std::unique_ptr<ProfileParam> profile(pf);
double fps = double(profile->frame_rate_num()) / profile->frame_rate_den();
double fps_int;
double fps_frac = std::modf(fps, &fps_int);
......
......@@ -247,7 +247,7 @@ public slots:
void slotAutoSave(const QString &scene);
/** @brief Groups were changed, save to MLT. */
void groupsChanged(const QString &groups);
void switchProfile(std::unique_ptr<ProfileParam> &profile, const QString &id, const QDomElement &xml);
void switchProfile(ProfileParam* pf);
private slots:
void slotModified();
......
......@@ -296,7 +296,7 @@ void ClipLoadTask::generateThumbnail(std::shared_ptr<ProjectClip>binClip, std::s
}
}
void ClipLoadTask::checkProfile(const QString &clipId, const QDomElement &xml, const std::shared_ptr<Mlt::Producer> &producer)
void ClipLoadTask::checkProfile(const std::shared_ptr<Mlt::Producer> &producer)
{
// Check if clip profile matches
QString service = producer->get("mlt_service");
......@@ -318,7 +318,7 @@ void ClipLoadTask::checkProfile(const QString &clipId, const QDomElement &xml, c
projectProfile->m_display_aspect_num = width;
projectProfile->m_display_aspect_den = height;
projectProfile->m_description.clear();
pCore->currentDoc()->switchProfile(projectProfile, clipId, xml);
QMetaObject::invokeMethod(pCore->currentDoc(), "switchProfile", Q_ARG(ProfileParam*,new ProfileParam(projectProfile.get())));
} else {
// Very small image, we probably don't want to use this as profile
}
......@@ -336,7 +336,7 @@ void ClipLoadTask::checkProfile(const QString &clipId, const QDomElement &xml, c
}
} else {
// Profiles do not match, propose profile adjustment
pCore->currentDoc()->switchProfile(clipProfile, clipId, xml);
QMetaObject::invokeMethod(pCore->currentDoc(), "switchProfile", Q_ARG(ProfileParam*,new ProfileParam(clipProfile.get())));
}
}
}
......@@ -673,6 +673,10 @@ void ClipLoadTask::run()
if (binClip) {
QMetaObject::invokeMethod(binClip.get(), "setProducer", Qt::QueuedConnection, Q_ARG(std::shared_ptr<Mlt::Producer>,producer),
Q_ARG(bool , true));
if (m_xml.hasAttribute(QStringLiteral("_checkProfile")) && producer->get_int("video_index") > -1) {
checkProfile(producer);
}
}
generateThumbnail(binClip, producer);
m_readyCallBack();
......
......@@ -46,7 +46,7 @@ public:
void processProducerProperties(const std::shared_ptr<Mlt::Producer> &prod, const QDomElement &xml);
void processSlideShow(std::shared_ptr<Mlt::Producer> producer);
// Do some checks on the profile
static void checkProfile(const QString &clipId, const QDomElement &xml, const std::shared_ptr<Mlt::Producer> &producer);
static void checkProfile(const std::shared_ptr<Mlt::Producer> &producer);
protected:
void run() override;
......
......@@ -190,6 +190,25 @@ ProfileParam::ProfileParam(ProfileInfo *p)
{
}
ProfileParam::ProfileParam(ProfileParam *p)
: m_path(qstrdup(p->path().toUtf8().constData()))
, m_description(qstrdup(p->description().toUtf8().constData()))
, m_frame_rate_num(p->frame_rate_num())
, m_frame_rate_den(p->frame_rate_den())
, m_width(p->width())
, m_height(p->height())
, m_progressive(p->progressive())
, m_sample_aspect_num(p->sample_aspect_num())
, m_sample_aspect_den(p->sample_aspect_den())
, m_display_aspect_num(p->display_aspect_num())
, m_display_aspect_den(p->display_aspect_den())
, m_colorspace(p->colorspace())
, m_fps(p->fps())
, m_sar(p->sar())
, m_dar(p->dar())
{
}
ProfileParam::ProfileParam(Mlt::Profile *p)
: m_frame_rate_num(p->frame_rate_num())
, m_frame_rate_den(p->frame_rate_den())
......
......@@ -88,6 +88,7 @@ public:
ProfileParam(QDomElement element);
ProfileParam(ProfileInfo *p);
ProfileParam(Mlt::Profile *p);
ProfileParam(ProfileParam *p);
QString path() const override;
QString description() const 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