Update Luma files with HD versions from Massimo Stella, update luma loading routines

parent a7fb7f44
INSTALL(FILES
bi-linear_x.pgm
bi-linear_y.pgm
burst.pgm
checkerboard_small.pgm
clock.pgm
cloud.pgm
curtain.pgm
horizontal_blinds.pgm
linear_x.pgm
linear_y.pgm
radial-bars.pgm
radial.pgm
spiral.pgm
spiral2.pgm
square.pgm
square2-bars.pgm
square2.pgm
symmetric_clock.pgm
DESTINATION ${DATA_INSTALL_DIR}/kdenlive/lumas)
PAL/bi-linear_x.pgm
PAL/bi-linear_y.pgm
PAL/burst.pgm
PAL/checkerboard_small.pgm
PAL/clock.pgm
PAL/cloud.pgm
PAL/curtain.pgm
PAL/horizontal_blinds.pgm
PAL/linear_x.pgm
PAL/linear_y.pgm
PAL/radial-bars.pgm
PAL/radial.pgm
PAL/spiral.pgm
PAL/spiral2.pgm
PAL/square.pgm
PAL/square2-bars.pgm
PAL/square2.pgm
PAL/symmetric_clock.pgm
DESTINATION ${DATA_INSTALL_DIR}/kdenlive/lumas/PAL)
INSTALL(FILES
HD/bi-linear_x.pgm
HD/bi-linear_y.pgm
HD/burst.pgm
HD/checkerboard_small.pgm
HD/clock.pgm
HD/cloud.pgm
HD/curtain.pgm
HD/horizontal_blinds.pgm
HD/linear_x.pgm
HD/linear_y.pgm
HD/radial-bars.pgm
HD/radial.pgm
HD/spiral.pgm
HD/spiral2.pgm
HD/square.pgm
HD/square2-bars.pgm
HD/square2.pgm
HD/symmetric_clock.pgm
DESTINATION ${DATA_INSTALL_DIR}/kdenlive/lumas/HD)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -6,7 +6,7 @@
<parameter type="double" name="softness" max="100" min="0" default="0" factor="100">
<name>Softness</name>
</parameter>
<parameter type="list" name="luma" default="%lumaDefault" paramlist="%lumaPaths" optional="1">
<parameter type="list" name="luma" default="linear_x.pgm" paramlist="%lumaPaths" optional="1">
<paramlistdisplay>%lumaNames</paramlistdisplay>
<name>Wipe Method</name>
</parameter>
......
......@@ -71,6 +71,13 @@ bool DocumentChecker::hasErrorInClips()
QString root = m_doc.documentElement().attribute(QStringLiteral("root"));
if (!root.isEmpty()) root = QDir::cleanPath(root) + QDir::separator();
QDomNodeList documentProducers = m_doc.elementsByTagName(QStringLiteral("producer"));
QDomElement profile = m_doc.documentElement().firstChildElement(QStringLiteral("profile"));
bool hdProfile = true;
if (!profile.isNull()) {
if (profile.attribute(QStringLiteral("width")).toInt() < 1000) {
hdProfile = false;
}
}
// List clips whose proxy is missing
QList <QDomElement> missingProxies;
// List clips who have a working proxy but no source clip
......@@ -175,6 +182,15 @@ bool DocumentChecker::hasErrorInClips()
if (!filePath.startsWith('/')) filePath.prepend(root);
if (!QFile::exists(filePath)) {
QString fixedLuma;
// check if this was an old format luma, not in correct folder
fixedLuma = filePath.section("/", 0, -2);
fixedLuma.append(hdProfile ? "/HD/" : "/PAL/");
fixedLuma.append(filePath.section("/", -1));
if (QFile::exists(fixedLuma)) {
// Auto replace pgm with png for lumas
autoFixLuma.insert(filePath, fixedLuma);
continue;
}
if (filePath.endsWith(".pgm")) {
fixedLuma = filePath.section(".", 0, -2) + ".png";
}
......
......@@ -45,8 +45,9 @@ QDomElement EffectsList::getEffectByName(const QString & name) const
QDomNodeList params = effect.elementsByTagName(QStringLiteral("parameter"));
for (int i = 0; i < params.count(); ++i) {
QDomElement e = params.item(i).toElement();
if (!e.hasAttribute(QStringLiteral("value")))
if (!e.hasAttribute(QStringLiteral("value")) && e.attribute(QStringLiteral("paramlist")) != QLatin1String("%lumaPaths")) {
e.setAttribute(QStringLiteral("value"), e.attribute(QStringLiteral("default")));
}
}
return effect;
}
......
......@@ -44,6 +44,30 @@
void initEffects::refreshLumas()
{
// Check for Kdenlive installed luma files, add empty string at start for no luma
QStringList imagefiles;
QStringList fileFilters;
QString defaultWipeLuma;
MainWindow::m_lumaFiles.clear();
fileFilters << QStringLiteral("*.png") << QStringLiteral("*.pgm");
QStringList customLumas = QStandardPaths::locateAll(QStandardPaths::DataLocation, QStringLiteral("lumas"), QStandardPaths::LocateDirectory);
customLumas.append(QString(mlt_environment("MLT_DATA")) + "/lumas");
foreach(const QString &folder, customLumas) {
QDir topDir(folder);
QStringList folders = topDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
foreach(const QString &f, folders) {
QDir dir(topDir.absoluteFilePath(f));
QStringList filesnames = dir.entryList(fileFilters, QDir::Files);
if (MainWindow::m_lumaFiles.contains(f)) {
imagefiles = MainWindow::m_lumaFiles.value(f);
}
foreach(const QString & fname, filesnames) {
imagefiles.append(dir.absoluteFilePath(fname));
}
MainWindow::m_lumaFiles.insert(f, imagefiles);
}
}
/*
QStringList imagenamelist = QStringList() << i18n("None");
QStringList imagefiles = QStringList() << QString();
QStringList filters;
......@@ -88,7 +112,7 @@ void initEffects::refreshLumas()
e.setAttribute(QStringLiteral("paramlist"), imagefiles.join(QStringLiteral(";")));
break;
}
}
}*/
}
// static
......@@ -191,35 +215,7 @@ bool initEffects::parseEffectFiles(Mlt::Repository* repository, const QString &l
transitionsItemList.sort();
// Get list of installed luma files
QStringList imagenamelist;
QStringList imagefiles;
QStringList fileFilters;
QString defaultWipeLuma;
fileFilters << QStringLiteral("*.png") << QStringLiteral("*.pgm");
QStringList customLumas = QStandardPaths::locateAll(QStandardPaths::DataLocation, QStringLiteral("lumas"), QStandardPaths::LocateDirectory);
foreach(const QString &folder, customLumas) {
QDir dir(folder);
QStringList filesnames = dir.entryList(fileFilters, QDir::Files);
foreach(const QString & fname, filesnames) {
imagenamelist.append(fname);
imagefiles.append(dir.absoluteFilePath(fname));
if (fname.startsWith(QLatin1String("linear_x"))) {
defaultWipeLuma = dir.absoluteFilePath(fname);
}
}
}
// Check for MLT luma files.
QUrl folder(QString(mlt_environment("MLT_DATA")) + QDir::separator() + "lumas" + QDir::separator() + QString(mlt_environment("MLT_NORMALISATION")));
QDir lumafolder(folder.path());
QStringList filesnames = lumafolder.entryList(fileFilters, QDir::Files);
foreach(const QString & fname, filesnames) {
imagenamelist.append(fname);
imagefiles.append(lumafolder.absoluteFilePath(fname));
}
imagenamelist.prepend(i18n("None (Dissolve)"));
imagefiles.prepend(QString());
refreshLumas();
// Parse xml transition files
QStringList direc = QStandardPaths::locateAll(QStandardPaths::DataLocation, QStringLiteral("transitions"), QStandardPaths::LocateDirectory);
......@@ -231,7 +227,7 @@ bool initEffects::parseEffectFiles(Mlt::Repository* repository, const QString &l
fileList = directory.entryList(filter, QDir::Files);
for (it = fileList.begin(); it != fileList.end(); ++it) {
itemName = directory.absoluteFilePath(*it);
parseTransitionFile(&MainWindow::transitions, itemName, repository, transDescriptions, imagefiles, imagenamelist, defaultWipeLuma);
parseTransitionFile(&MainWindow::transitions, itemName, repository, transDescriptions);
}
}
......@@ -249,7 +245,7 @@ bool initEffects::parseEffectFiles(Mlt::Repository* repository, const QString &l
}
// Fill transitions list.
fillTransitionsList(repository, &MainWindow::transitions, transitionsItemList, imagefiles, imagenamelist);
fillTransitionsList(repository, &MainWindow::transitions, transitionsItemList);
// Remove blacklisted effects from the filters list.
QStringList mltFiltersList = filtersList;
......@@ -654,7 +650,7 @@ QDomDocument initEffects::createDescriptionFromMlt(Mlt::Repository* repository,
return ret;
}
void initEffects::fillTransitionsList(Mlt::Repository *repository, EffectsList *transitions, QStringList names, QStringList imagefiles, QStringList imagenamelist)
void initEffects::fillTransitionsList(Mlt::Repository *repository, EffectsList *transitions, QStringList names)
{
// Remove transitions that are not implemented.
int pos = names.indexOf(QStringLiteral("mix"));
......@@ -752,7 +748,7 @@ void initEffects::fillTransitionsList(Mlt::Repository *repository, EffectsList *
paramList.append(quickParameterFill(ret, i18n("Align"), QStringLiteral("aligned"), QStringLiteral("bool"), QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Fill"), QStringLiteral("fill"), QStringLiteral("bool"), QStringLiteral("1"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Distort"), QStringLiteral("distort"), QStringLiteral("bool"), QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Wipe Method"), QStringLiteral("luma"), QStringLiteral("list"), QLatin1String(""), QLatin1String(""), QLatin1String(""), imagefiles.join(QStringLiteral(";")), imagenamelist.join(QStringLiteral(","))));
paramList.append(quickParameterFill(ret, i18n("Wipe Method"), QStringLiteral("luma"), QStringLiteral("list"), QLatin1String(""), QLatin1String(""), QLatin1String(""), QStringLiteral("%lumaPaths"), QLatin1String("")));
paramList.append(quickParameterFill(ret, i18n("Wipe Softness"), QStringLiteral("softness"), QStringLiteral("double"), QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("100"), QLatin1String(""), QLatin1String(""), QStringLiteral("100")));
paramList.append(quickParameterFill(ret, i18n("Wipe Invert"), QStringLiteral("luma_invert"), QStringLiteral("bool"), QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Force Progressive Rendering"), QStringLiteral("progressive"), QStringLiteral("bool"), QStringLiteral("1"), QStringLiteral("0"), QStringLiteral("1")));
......@@ -797,7 +793,7 @@ void initEffects::fillTransitionsList(Mlt::Repository *repository, EffectsList *
paramList.append(quickParameterFill(ret, i18n("Align"), QStringLiteral("composite.aligned"), QStringLiteral("bool"), QStringLiteral("1"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Fill"), QStringLiteral("composite.fill"), QStringLiteral("bool"), QStringLiteral("1"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Distort"), QStringLiteral("composite.distort"), QStringLiteral("bool"), QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Wipe File"), QStringLiteral("composite.luma"), QStringLiteral("list"), QLatin1String(""), QLatin1String(""), QLatin1String(""), imagefiles.join(QStringLiteral(";")), imagenamelist.join(QStringLiteral(","))));
paramList.append(quickParameterFill(ret, i18n("Wipe File"), QStringLiteral("composite.luma"), QStringLiteral("list"), QLatin1String(""), QLatin1String(""), QLatin1String(""), QStringLiteral("%lumaPaths"), QLatin1String("")));
paramList.append(quickParameterFill(ret, i18n("Wipe Softness"), QStringLiteral("composite.softness"), QStringLiteral("double"), QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("100"), QLatin1String(""), QLatin1String(""), QStringLiteral("100")));
paramList.append(quickParameterFill(ret, i18n("Wipe Invert"), QStringLiteral("composite.luma_invert"), QStringLiteral("bool"), QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("1")));
paramList.append(quickParameterFill(ret, i18n("Force Progressive Rendering"), QStringLiteral("composite.progressive"), QStringLiteral("bool"), QStringLiteral("1"), QStringLiteral("0"), QStringLiteral("1")));
......@@ -854,7 +850,7 @@ QDomElement initEffects::quickParameterFill(QDomDocument & doc, const QString &n
}
// static
void initEffects::parseTransitionFile(EffectsList *transitionList, const QString &name, Mlt::Repository *repository, QMap <QString, QString> effectDescriptions, QStringList imagefiles, QStringList imagenamelist, const QString &defaultWipeLuma)
void initEffects::parseTransitionFile(EffectsList *transitionList, const QString &name, Mlt::Repository *repository, QMap <QString, QString> effectDescriptions)
{
QDomDocument doc;
QFile file(name);
......@@ -864,10 +860,6 @@ void initEffects::parseTransitionFile(EffectsList *transitionList, const QString
QTextStream out(&file);
QString fileContent = out.readAll();
file.close();
// Check for special keywords
fileContent.replace(QLatin1String("%lumaPaths"), imagefiles.join(QLatin1Char(';')));
fileContent.replace(QLatin1String("%lumaNames"), imagenamelist.join(QLatin1Char(',')));
fileContent.replace(QLatin1String("%lumaDefault"), defaultWipeLuma);
doc.setContent(fileContent, false);
QDomElement documentElement;
QDomNodeList effects;
......
......@@ -55,7 +55,7 @@ public:
* It creates an element for each transition, asking to MLT for information
* when possible, using default parameters otherwise. It also adds some
* "virtual" transition, and removes those not implemented. */
static void fillTransitionsList(Mlt::Repository *repository, EffectsList *transitions, QStringList names, QStringList imagefiles, QStringList imagenamelist);
static void fillTransitionsList(Mlt::Repository *repository, EffectsList *transitions, QStringList names);
/** @brief Creates an element describing a transition parameter.
* @param doc document containing the transition element
......@@ -89,7 +89,7 @@ public:
const QString &name, QStringList filtersList,
QStringList producersList,
Mlt::Repository *repository, QMap <QString, QString> effectDescriptions);
static void parseTransitionFile(EffectsList *transitionList, const QString &name, Mlt::Repository *repository, QMap <QString, QString> effectDescriptions, QStringList imagefiles, QStringList imagenamelist, const QString &defaultWipeLuma);
static void parseTransitionFile(EffectsList *transitionList, const QString &name, Mlt::Repository *repository, QMap <QString, QString> effectDescriptions);
/** @brief Reloads information about custom effects. */
static void parseCustomEffectsFile();
......
......@@ -241,33 +241,49 @@ ParameterContainer::ParameterContainer(const QDomElement &effect, const ItemInfo
Listval *lsval = new Listval;
lsval->setupUi(toFillin);
lsval->list->setFocusPolicy(Qt::StrongFocus);
QStringList listitems = pa.attribute(QStringLiteral("paramlist")).split(';');
if (listitems.count() == 1) {
// probably custom effect created before change to ';' as separator
listitems = pa.attribute(QStringLiteral("paramlist")).split(',');
}
QDomElement list = pa.firstChildElement(QStringLiteral("paramlistdisplay"));
QStringList listitemsdisplay;
if (!list.isNull()) {
listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
} else {
listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
}
if (listitemsdisplay.count() != listitems.count())
listitemsdisplay = listitems;
lsval->list->setIconSize(QSize(30, 30));
for (int i = 0; i < listitems.count(); ++i) {
lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
QString entry = listitems.at(i);
if (!entry.isEmpty() && (entry.endsWith(QLatin1String(".png")) || entry.endsWith(QLatin1String(".pgm")))) {
if (!MainWindow::m_lumacache.contains(entry)) {
QImage pix(entry);
MainWindow::m_lumacache.insert(entry, pix.scaled(30, 30, Qt::KeepAspectRatio, Qt::SmoothTransformation));
QString items = pa.attribute(QStringLiteral("paramlist"));
QStringList listitems;
if (items == QLatin1String("%lumaPaths")) {
// Special case: Luma files
// Create thumbnails
lsval->list->setIconSize(QSize(50, 30));
if (m_metaInfo->monitor->profileInfo().profileSize.width() > 1000) {
// HD project
listitems = MainWindow::m_lumaFiles.value(QStringLiteral("HD"));
} else {
listitems = MainWindow::m_lumaFiles.value(QStringLiteral("PAL"));
}
lsval->list->addItem(i18n("None (Dissolve)"));
for (int i = 0; i < listitems.count(); ++i) {
QString entry = listitems.at(i);
lsval->list->addItem(listitems.at(i).section(QStringLiteral("/"), -1), entry);
if (!entry.isEmpty() && (entry.endsWith(QLatin1String(".png")) || entry.endsWith(QLatin1String(".pgm")))) {
if (!MainWindow::m_lumacache.contains(entry)) {
QImage pix(entry);
MainWindow::m_lumacache.insert(entry, pix.scaled(50, 30, Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
lsval->list->setItemIcon(i + 1, QPixmap::fromImage(MainWindow::m_lumacache.value(entry)));
}
lsval->list->setItemIcon(i, QPixmap::fromImage(MainWindow::m_lumacache.value(entry)));
}
lsval->list->setCurrentText(pa.attribute(QStringLiteral("default")));
if (!value.isEmpty() && listitems.contains(value)) lsval->list->setCurrentIndex(listitems.indexOf(value) + 1);
} else {
listitems = items.split(';');
if (listitems.count() == 1) {
// probably custom effect created before change to ';' as separator
listitems = pa.attribute(QStringLiteral("paramlist")).split(',');
}
QDomElement list = pa.firstChildElement(QStringLiteral("paramlistdisplay"));
QStringList listitemsdisplay;
if (!list.isNull()) {
listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
} else {
listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
}
if (listitemsdisplay.count() != listitems.count())
listitemsdisplay = listitems;
if (!value.isEmpty() && listitems.contains(value)) lsval->list->setCurrentIndex(listitems.indexOf(value));
}
if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
lsval->name->setText(paramName);
lsval->setToolTip(comment);
lsval->labelComment->setText(comment);
......
......@@ -120,6 +120,7 @@ EffectsList MainWindow::customEffects;
EffectsList MainWindow::transitions;
QMap <QString,QImage> MainWindow::m_lumacache;
QMap <QString,QStringList> MainWindow::m_lumaFiles;
/*static bool sortByNames(const QPair<QString, QAction *> &a, const QPair<QString, QAction*> &b)
{
......
......@@ -82,9 +82,10 @@ public:
static EffectsList audioEffects;
static EffectsList customEffects;
static EffectsList transitions;
/** @brief Cache for luma files thumbnails. */
static QMap <QString,QImage> m_lumacache;
static QMap <QString,QStringList> m_lumaFiles;
/** @brief Adds an action to the action collection and stores the name. */
void addAction(const QString &name, QAction *action);
......
......@@ -19,12 +19,11 @@
#include "transitionhandler.h"
#include "mainwindow.h"
TransitionHandler::TransitionHandler(Mlt::Tractor *tractor) :
m_tractor(tractor)
{
}
bool TransitionHandler::addTransition(QString tag, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml, bool do_refresh)
......@@ -74,15 +73,44 @@ QMap<QString, QString> TransitionHandler::getTransitionParamsFromXml(const QDomE
for (int i = 0; i < attribs.count(); ++i) {
QDomElement e = attribs.item(i).toElement();
QString name = e.attribute(QStringLiteral("name"));
map[name] = e.attribute(QStringLiteral("default"));
if (e.hasAttribute(QStringLiteral("value"))) {
map[name] = e.attribute(QStringLiteral("value"));
} else {
QString defaultValue = e.attribute(QStringLiteral("default"));
// special case: luma file, we need to find full path for the default luma
if (!defaultValue.isEmpty() && e.attribute(QStringLiteral("paramlist")) == QLatin1String("%lumaPaths")) {
QString lumaFolder;
if (m_tractor->profile()->width() > 1000) {
lumaFolder = QStringLiteral("HD");
} else {
lumaFolder = QStringLiteral("PAL");
}
QStringList lumas = MainWindow::m_lumaFiles.value(lumaFolder);
bool found = false;
foreach(const QString &luma, lumas) {
if (QUrl::fromLocalFile(luma).fileName() == defaultValue) {
map[name] = luma;
found = true;
break;
}
}
if (!found) {
if (lumas.isEmpty()) {
// Something is wrong
map[name] = QString();
} else {
map[name] = lumas.first();
}
}
} else {
map[name] = defaultValue;
}
}
double factor = e.attribute(QStringLiteral("factor"), QStringLiteral("1")).toDouble();
double offset = e.attribute(QStringLiteral("offset"), QStringLiteral("0")).toDouble();
if (factor!= 1 || offset != 0) {
if (e.attribute(QStringLiteral("type")) == QLatin1String("simplekeyframe")) {
QStringList values = e.attribute(QStringLiteral("value")).split(';', QString::SkipEmptyParts);
QStringList values = map.value(name).split(';', QString::SkipEmptyParts);
for (int j = 0; j < values.count(); ++j) {
QString pos = values.at(j).section(QLatin1Char('='), 0, 0);
double val = (values.at(j).section(QLatin1Char('='), 1, 1).toDouble() - offset) / factor;
......@@ -98,7 +126,7 @@ QMap<QString, QString> TransitionHandler::getTransitionParamsFromXml(const QDomE
//TODO: Deprecated, does not seem used anywhere...
QString format = e.attribute(QStringLiteral("format"));
QStringList separators = format.split(QStringLiteral("%d"), QString::SkipEmptyParts);
QStringList values = e.attribute(QStringLiteral("value")).split(QRegExp("[,:;x]"));
QStringList values = map.value(name).split(QRegExp("[,:;x]"));
QString neu;
QTextStream txtNeu(&neu);
if (values.size() > 0)
......@@ -110,7 +138,7 @@ QMap<QString, QString> TransitionHandler::getTransitionParamsFromXml(const QDomE
}
if (i < separators.size())
txtNeu << separators[i];
map[e.attribute(QStringLiteral("name"))] = neu;
map[name] = neu;
}
}
......
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