Commit 209e4fcc authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Merge branch '17.04'

parents 9f01d936 3404da90
This diff is collapsed.
......@@ -33,7 +33,6 @@
#include <QColor>
#include <QString>
#include <QDir>
#include <QScriptEngine>
#include <mlt++/Mlt.h>
......@@ -1809,135 +1808,6 @@ bool DocumentValidator::isModified() const
return m_modified;
}
/*
void DocumentValidator::updateEffects()
{
// WARNING: order by findDirs will determine which js file to use (in case multiple scripts for the same filter exist)
QMap<QString, QUrl> paths;
QMap<QString, QScriptProgram> scripts;
QStringList directories = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, "effects/update");
foreach (const QString &directoryName, directories) {
QDir directory(directoryName);
QStringList fileList = directory.entryList(QStringList() << "*.js", QDir::Files);
foreach (const QString &fileName, fileList) {
QString identifier = fileName;
// remove extension (".js")
identifier.chop(3);
paths.insert(identifier, QUrl(directoryName + fileName));
}
}
QDomNodeList effects = m_doc.elementsByTagName("filter");
int max = effects.count();
QStringList safeEffects;
for(int i = 0; i < max; ++i) {
QDomElement effect = effects.at(i).toElement();
QString effectId = EffectsList::property(effect, "kdenlive_id");
if (safeEffects.contains(effectId)) {
// Do not check the same effect twice if it is at the correct version
// (assume we don't have different versions of the same effect in a project file)
continue;
}
QString effectTag = EffectsList::property(effect, "tag");
QString effectVersionStr = EffectsList::property(effect, "version");
double effectVersion = effectVersionStr.isNull() ? -1 : effectVersionStr.toDouble();
QDomElement effectDescr = MainWindow::customEffects.getEffectByTag(QString(), effectId);
if (effectDescr.isNull()) {
effectDescr = MainWindow::videoEffects.getEffectByTag(effectTag, effectId);
}
if (effectDescr.isNull()) {
effectDescr = MainWindow::audioEffects.getEffectByTag(effectTag, effectId);
}
if (!effectDescr.isNull()) {
double serviceVersion = -1;
QDomElement serviceVersionElem = effectDescr.firstChildElement("version");
if (!serviceVersionElem.isNull()) {
serviceVersion = serviceVersionElem.text().toDouble();
}
if (serviceVersion != effectVersion && paths.contains(effectId)) {
if (!scripts.contains(effectId)) {
QFile scriptFile(paths.value(effectId).path());
if (!scriptFile.open(QIODevice::ReadOnly)) {
continue;
}
QScriptProgram scriptProgram(scriptFile.readAll());
scriptFile.close();
scripts.insert(effectId, scriptProgram);
}
QScriptEngine scriptEngine;
scriptEngine.importExtension("qt.core");
scriptEngine.importExtension("qt.xml");
scriptEngine.evaluate(scripts.value(effectId));
QScriptValue updateRules = scriptEngine.globalObject().property("update");
if (!updateRules.isValid())
continue;
if (updateRules.isFunction()) {
QDomDocument scriptDoc;
scriptDoc.appendChild(scriptDoc.importNode(effect, true));
QString effectString = updateRules.call(QScriptValue(), QScriptValueList() << serviceVersion << effectVersion << scriptDoc.toString()).toString();
if (!effectString.isEmpty() && !scriptEngine.hasUncaughtException()) {
scriptDoc.setContent(effectString);
QDomNode updatedEffect = effect.ownerDocument().importNode(scriptDoc.documentElement(), true);
effect.parentNode().replaceChild(updatedEffect, effect);
m_modified = true;
}
} else {
m_modified = updateEffectParameters(effect.childNodes(), &updateRules, serviceVersion, effectVersion);
}
// set version number since MLT won't change it (only initially set it)
QDomElement versionElem = effect.firstChildElement("version");
if (EffectsList::property(effect, "version").isNull()) {
versionElem = effect.ownerDocument().createTextNode(QLocale().toString(serviceVersion)).toElement();
versionElem.setTagName("property");
versionElem.setAttribute("name", "version");
effect.appendChild(versionElem);
} else {
EffectsList::setProperty(effect, "version", QLocale().toString(serviceVersion));
}
}
else safeEffects.append(effectId);
}
}
}
bool DocumentValidator::updateEffectParameters(const QDomNodeList &parameters, const QScriptValue* updateRules, const double serviceVersion, const double effectVersion)
{
bool updated = false;
bool isDowngrade = serviceVersion < effectVersion;
for (int i = 0; i < parameters.count(); ++i) {
QDomElement parameter = parameters.at(i).toElement();
QScriptValue rules = updateRules->property(parameter.attribute("name"));
if (rules.isValid() && rules.isArray()) {
int rulesCount = rules.property("length").toInt32();
if (isDowngrade) {
// start with the highest version and downgrade step by step
for (int j = rulesCount - 1; j >= 0; --j) {
double version = rules.property(j).property(0).toNumber();
if (version <= effectVersion && version > serviceVersion) {
parameter.firstChild().setNodeValue(rules.property(j).property(1).call(QScriptValue(), QScriptValueList() << parameter.text() << isDowngrade).toString());
updated = true;
}
}
} else {
for (int j = 0; j < rulesCount; ++j) {
double version = rules.property(j).property(0).toNumber();
if (version > effectVersion && version <= serviceVersion) {
parameter.firstChild().setNodeValue(rules.property(j).property(1).call(QScriptValue(), QScriptValueList() << parameter.text() << isDowngrade).toString());
updated = true;
}
}
}
}
}
return updated;
}
*/
bool DocumentValidator::checkMovit()
{
QString playlist = m_doc.toString();
......
......@@ -26,8 +26,6 @@
#include <QUrl>
#include <QMap>
class QScriptValue;
class DocumentValidator
{
......@@ -51,13 +49,6 @@ private:
void checkOrphanedProducers();
QStringList getInfoFromEffectName(const QString &oldName);
QString colorToString(const QColor &c);
/*
/// @brief Updates effects that were created using a different version of the underlaying filter than the one installed.
void updateEffects();
/// @brief Updates the parameters according to the updateRules.
/// @see the related in README in effects/update
bool updateEffectParameters(const QDomNodeList &parameters, const QScriptValue *updateRules, const double serviceVersion, const double effectVersion);
*/
QString factorizeGeomValue(const QString &value, double factor);
/** @brief Kdenlive <= 0.9.10 saved title clip item position/opacity with locale which was wrong, fix. */
void fixTitleProducerLocale(QDomElement &producer);
......
......@@ -18,6 +18,7 @@ extern "C"
#include "kdenlive_debug.h"
#include <QTime>
#include <algorithm>
#include <vector>
void FFTCorrelation::correlate(const qint64 *left, const int leftSize,
const qint64 *right, const int rightSize,
......@@ -61,7 +62,7 @@ void FFTCorrelation::correlate(const qint64 *left, const int leftSize,
}
}
// One side needs to be reverted, since multiplication in frequency domain (fourier space)
// One side needs to be reversed, since multiplication in frequency domain (fourier space)
// calculates the convolution: \sum l[x]r[N-x] and not the correlation: \sum l[x]r[x]
for (int i = 0; i < leftSize; ++i) {
leftF[i] = double(left[i]) / maxLeft;
......@@ -97,30 +98,27 @@ void FFTCorrelation::convolve(const float *left, const int leftSize,
while (size / 2 < largestSize) {
size = size << 1;
}
const int fft_size = size / 2 + 1;
kiss_fftr_cfg fftConfig = kiss_fftr_alloc(size, false, nullptr, nullptr);
kiss_fftr_cfg ifftConfig = kiss_fftr_alloc(size, true, nullptr, nullptr);
kiss_fft_cpx leftFFT[size / 2];
kiss_fft_cpx rightFFT[size / 2];
kiss_fft_cpx correlatedFFT[size / 2];
std::vector<kiss_fft_cpx> leftFFT(fft_size);
std::vector<kiss_fft_cpx> rightFFT(fft_size);
std::vector<kiss_fft_cpx> correlatedFFT(fft_size);
// Fill in the data into our new vectors with padding
float *leftData = new float[size];
float *rightData = new float[size];
float *convolved = new float[size];
std::fill(leftData, leftData + size, 0);
std::fill(rightData, rightData + size, 0);
std::vector<float> leftData(size, 0);
std::vector<float> rightData(size, 0);
std::vector<float> convolved(size);
std::copy(left, left + leftSize, leftData);
std::copy(right, right + rightSize, rightData);
std::copy(left, left + leftSize, leftData.begin());
std::copy(right, right + rightSize, rightData.begin());
// Fourier transformation of the vectors
kiss_fftr(fftConfig, leftData, leftFFT);
kiss_fftr(fftConfig, rightData, rightFFT);
kiss_fftr(fftConfig, &leftData[0], &leftFFT[0]);
kiss_fftr(fftConfig, &rightData[0], &rightFFT[0]);
// Convolution in spacial domain is a multiplication in fourier domain. O(n).
for (int i = 0; i < size / 2; ++i) {
for (int i = 0; i < correlatedFFT.size(); ++i) {
correlatedFFT[i].r = leftFFT[i].r * rightFFT[i].r - leftFFT[i].i * rightFFT[i].i;
correlatedFFT[i].i = leftFFT[i].r * rightFFT[i].i + leftFFT[i].i * rightFFT[i].r;
}
......@@ -131,16 +129,12 @@ void FFTCorrelation::convolve(const float *left, const int leftSize,
*out_convolved = 0;
int out_size = leftSize + rightSize + 1;
kiss_fftri(ifftConfig, correlatedFFT, convolved);
std::copy(convolved, convolved + out_size - 1, out_convolved + 1);
kiss_fftri(ifftConfig, &correlatedFFT[0], &convolved[0]);
std::copy(convolved.begin(), convolved.begin() + out_size - 1, out_convolved + 1);
// Finally some cleanup.
kiss_fftr_free(fftConfig);
kiss_fftr_free(ifftConfig);
delete[] leftData;
delete[] rightData;
delete[] convolved;
qCDebug(KDENLIVE_LOG) << "FFT convolution computed. Time taken: " << time.elapsed() << " ms";
}
......@@ -25,7 +25,7 @@ public:
/**
Computes the convolution between \c left and \c right.
\c out_correlated must be a pre-allocated vector of size
\c leftSize + \c rightSize.
\c leftSize + \c rightSize + 1.
*/
static void convolve(const float *left, const int leftSize,
const float *right, const int rightSize,
......@@ -34,7 +34,7 @@ public:
/**
Computes the correlation between \c left and \c right.
\c out_correlated must be a pre-allocated vector of size
\c leftSize + \c rightSize.
\c leftSize + \c rightSize + 1.
*/
static void correlate(const qint64 *left, const int leftSize,
const qint64 *right, const int rightSize,
......
......@@ -650,6 +650,10 @@ void MainWindow::init(const QString &MltPath, const QUrl &Url, const QString &cl
KdenliveSettings::setDecklink_extension(data.section(QLatin1Char(';'), 1, 1));
}
}
if (!QDir(KdenliveSettings::currenttmpfolder()).isReadable())
KdenliveSettings::setCurrenttmpfolder(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
pCore->projectManager()->init(Url, clipsToLoad);
QTimer::singleShot(0, pCore->projectManager(), &ProjectManager::slotLoadOnOpen);
QTimer::singleShot(0, this, &MainWindow::GUISetupDone);
......
......@@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "effectstack/widgets/animationwidget.h"
#include "kdenlive_debug.h"
#include <QScriptEngine>
EffectInfo::EffectInfo()
{
......@@ -227,12 +226,13 @@ void EffectsController::adjustEffectParameters(EffectsParameterList &parameters,
double EffectsController::getStringEval(const ProfileInfo &info, QString eval, const QPoint &frameSize)
{
QScriptEngine sEngine;
sEngine.globalObject().setProperty(QStringLiteral("maxWidth"), info.profileSize.width() > frameSize.x() ? info.profileSize.width() : frameSize.x());
sEngine.globalObject().setProperty(QStringLiteral("maxHeight"), info.profileSize.height() > frameSize.y() ? info.profileSize.height() : frameSize.y());
sEngine.globalObject().setProperty(QStringLiteral("width"), info.profileSize.width());
sEngine.globalObject().setProperty(QStringLiteral("height"), info.profileSize.height());
return sEngine.evaluate(eval.remove('%')).toNumber();
eval.replace(QLatin1String("%maxWidth"), QString::number(info.profileSize.width() > frameSize.x() ? info.profileSize.width() : frameSize.x()))
.replace(QLatin1String("%maxHeight"), QString::number(info.profileSize.height() > frameSize.y() ? info.profileSize.height() : frameSize.y()))
.replace(QLatin1String("%width"), QString::number(info.profileSize.width()))
.replace(QLatin1String("%height"), QString::number(info.profileSize.height()));
Mlt::Properties p;
p.set("eval", eval.toLatin1().constData());
return p.get_double("eval");
}
QString EffectsController::getStringRectEval(const ProfileInfo &info, QString eval)
......
......@@ -754,14 +754,12 @@ void Render::switchPlay(bool play, double speed)
}
m_mltProducer->set_speed(speed);
} else {
m_mltConsumer->set("refresh", 0);
m_mltConsumer->purge();
m_mltProducer->set_speed(0.0);
m_mltConsumer->stop();
m_mltConsumer->set("real_time", -1);
m_mltConsumer->set("buffer", 0);
m_mltConsumer->set("prefill", 0);
m_mltConsumer->set("real_time", -1);
m_mltProducer->set_speed(0.0);
m_mltProducer->seek(m_mltConsumer->position() + 1);
m_mltConsumer->purge();
}
}
......@@ -1010,9 +1008,7 @@ bool Render::checkFrameNumber(int pos)
}
} else {
m_isRefreshing = false;
if (m_mltProducer->get_speed() == 0) {
m_mltConsumer->purge();
} else if (m_isZoneMode) {
if (m_isZoneMode && m_mltProducer->get_speed() != 0) {
if (pos >= m_mltProducer->get_int("out") - 1) {
if (m_isLoopMode) {
m_mltConsumer->purge();
......
......@@ -142,7 +142,7 @@
<item row="3" column="0" colspan="3">
<widget class="QLabel" name="parametersLabel">
<property name="text">
<string>Parameters (see &lt;a href=&quot;http://www.mltframework.org/bin/view/MLT/ConsumerAvformat&quot;&gt;MLT documentation&lt;/a&gt;)</string>
<string>Parameters (see &lt;a href=&quot;https://www.mltframework.org/plugins/ConsumerAvformat/&quot;&gt;MLT documentation&lt;/a&gt;)</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
......
......@@ -205,14 +205,15 @@ void ThemeManager::populateThemeMenu()
updateCurrentKDEdefaultThemePreview();
setCurrentTheme(theme);
d->themeMenuAction->addSeparator();
QAction *config = new QAction(i18n("Configuration..."), d->themeMenuAction);
config->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-theme")));
d->themeMenuAction->addAction(config);
connect(config, &QAction::triggered,
this, &ThemeManager::slotConfigColors);
if (!QStandardPaths::findExecutable(QStringLiteral("kcmshell5")).isEmpty()) {
d->themeMenuAction->addSeparator();
QAction *config = new QAction(i18n("Configuration..."), d->themeMenuAction);
config->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-theme")));
d->themeMenuAction->addAction(config);
connect(config, &QAction::triggered,
this, &ThemeManager::slotConfigColors);
}
}
void ThemeManager::slotConfigColors()
......
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