-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 09/03/2011 01:06 AM, jb wrote:
> On Saturday 03 September 2011 00:44:46 Till Theato wrote:
>
>>> 1) Change the effect XML depending on the filter version
>>>
>>> I did some test and managed to have a working implementation
>>> that will bring different parameters depending on the filter
>>> version, see my last commit:
>>> http://kdenlive.svn.sourceforge.net/viewvc/kdenlive?view=revision&revisi
>>>
>>>
on=5855
>> Is
>>
>> it correct that only one file was committed?
>
> Yes. It is possible to put several effects description in just one
> file if we put the effects in a <group> tag.
>
>>
>>> 2) upgrade project files using older version of the filter
>>>
>>> Since MLT now stores the frei0r filter version in the xml data,
>>> it should be pretty straightforward. Till, are you taking care
>>> of it? I will have some time between the 5th an the 7th of
>>> September in case some work is required on that side.
>>
>> Sorry for the delay, I am fighting with QtScript for a week now
>> (with little spare time). The result unfortunately is a lot of
>> redundancy across the XML files and overall ugliness. As you can
>> see in the attached file: Way to much code for only a single
>> file... The adopt function could be replaced by what you
>> introduced in your latest commit or by what Dan proposed: Do the
>> same thing you implemented but on parameter level (-> less
>> duplication).
>
> Currently, it seems easier to me to check it at the effect level.
> Having it at the parameter level could bring some complicated stuff
> (imagine that we have 3 versions of a filter, each having different
> minimums, maximums, parameters appearing or removed... That would
> in the end result in a very complicated xml.
>
> In my version, we simple put one xml copy for each version of the
> filter, and Kdenlive will only load the correct version.
The attached patch is what i came up with. As I already said I will
drop the adopt function (and therefore the changes in initeffects.cpp)
again. With your system where should the routines part be placed?
Since it is needed in trackview it has to be inside <effect>. However
there will be at least two <effect> elements whenever a routine is needed.
Another problem is see with your approach is the amount of
duplication, since some XMl files are not that small (e.g. SOP/Sat).
Any ideas to avoid duplication in the update function (across multiple
effects)?
>
>
>> Regarding the update thing I don't know.... Levels is a rather
>> easy example but on other effects we can't just multiply the
>> whole thing by a factor since we also have to consider keyframes.
>> Rather easy however with the update function concept. Anyone any
>> ideas on how to do it with less code?
>
>> The adopt function is fully integrated in Kdenlive and works, but
>> is probably to be removed again. The result of the update
>> function is not yet replacing the original effect in the project.
>> I will try to finish it this weekend. Well that is unless someone
>> comes up with a better idea.
>>
>> For the update thing to work a MLT release would be required,
>> too. @Dan?
>
> Oh, you mean because the frei0r version is new in MLT... right I
> didn't think about it...
>
>>> Once both steps have been taken for the filters that will be
>>> modified in frei0r, I will prepare the release.
>>
>> What about that 10 tracks bug?
>
> That's an MLT issue, I have not investigated more.
>
> regards jb
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk5iqa0ACgkQzwEyz7QP6nSE7wCff81lR/DuZyTUEJ3cJsTlVGZn
CjYAnj+FjecLcrdPOtvXkvNfkXVjwluY
=4Yya
-----END PGP SIGNATURE-----
Index: /home/till/abs/kdenlive-svn/src/kdenlive/effects/frei0r_levels.xml
===================================================================
--- /home/till/abs/kdenlive-svn/src/kdenlive/effects/frei0r_levels.xml (revision 5852)
+++ /home/till/abs/kdenlive-svn/src/kdenlive/effects/frei0r_levels.xml (working copy)
@@ -1,9 +1,47 @@
<!DOCTYPE kpartgui>
-<effect tag="frei0r.levels" id="frei0r.levels">
+<effect LC_NUMERIC="C" tag="frei0r.levels" id="frei0r.levels">
<name>Levels</name>
<description>Adjust levels</description>
<author>Maksim Golovkin</author>
- <parameter type="list" name="Channel" default="3" paramlist="0;1;2;3">
+
+ <routines>
+ <![CDATA[
+ function adopt(serviceVersion, effectString) {
+ var doc = new QDomDocument();
+ doc.setContent(effectString);
+ if (serviceVersion < 0.2) {
+ var i = 0;
+ var parameters = doc.documentElement().elementsByTagName("parameter");
+ for (i = 0; i < parameters.count(); ++i) {
+ var parameter = parameters.at(i).toElement();
+ if (parameter.attribute("name") == "Channel" || parameter.attribute("name") == "Histogram position") {
+ parameter.setAttribute("paramlist", "0;1;2;3");
+ parameter.setAttribute("default", "3");
+ }
+ }
+ }
+ return doc.toString();
+ }
+ function update(serviceVersion, effectVersion, effectString) {
+ var locale = new QLocale();
+ var doc = new QDomDocument();
+ doc.setContent(effectString);
+ for (var node = doc.documentElement().firstChild(); !node.isNull(); node = node.nextSibling()) {
+ var effectparam = node.toElement();
+ if (effectparam.attribute("name") == "Channel" || effectparam.attribute("name") == "Histogram position") {
+ if (serviceVersion < effectVersion) {
+ effectparam.firstChild().toText().setData(locale.toString(effectparam.text() * 10));
+ } else {
+ effectparam.firstChild().toText().setData(locale.toString(effectparam.text() / 10.));
+ }
+ }
+ }
+ return doc.toString();
+ }
+ ]]>
+ </routines>
+
+ <parameter type="list" name="Channel" default="0.3" paramlist="0;0.1;0.2;0.3">
<paramlistdisplay>Red,Green,Blue,Luma</paramlistdisplay>
<name>Channel</name>
</parameter>
@@ -25,7 +63,7 @@
<parameter type="bool" name="Show histogram" default="0">
<name>Show histogram</name>
</parameter>
- <parameter type="list" name="Histogram position" default="3" paramlist="0;1;2;3">
+ <parameter type="list" name="Histogram position" default="0.3" paramlist="0;0.1;0.2;0.3">
<paramlistdisplay>Top Left,Top Right,Bottom Left,Bottom Right</paramlistdisplay>
<name>Histogram position</name>
</parameter>
Index: /home/till/abs/kdenlive-svn/src/kdenlive/src/trackview.cpp
===================================================================
--- /home/till/abs/kdenlive-svn/src/kdenlive/src/trackview.cpp (revision 5852)
+++ /home/till/abs/kdenlive-svn/src/kdenlive/src/trackview.cpp (working copy)
@@ -38,7 +38,9 @@
#include <QScrollBar>
#include <QInputDialog>
+#include <QScriptEngine>
+
TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
QWidget(parent),
m_scale(1.0),
@@ -751,6 +753,8 @@
QString effecttag;
QString effectid;
QString effectindex = QString::number(effectNb);
+ double effectVersion = -1;
+
// Get effect tag & index
for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
// parse effect parameters
@@ -765,6 +769,8 @@
} else if (effectparam.attribute("name") == "kdenlive_ix") {
// Fix effects index
effectparam.firstChild().setNodeValue(effectindex);
+ } else if (effectparam.attribute("name") == "version") {
+ effectVersion = effectparam.text().toDouble();
}
}
//kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
@@ -786,6 +792,33 @@
currenteffect.setAttribute("kdenlive_ix", effectindex);
QDomNodeList clipeffectparams = currenteffect.childNodes();
+ QDomElement routines = currenteffect.firstChildElement("routines");
+ if (!routines.isNull()) {
+ double serviceVersion = -1;
+ QDomElement serviceVersionElem = effect.firstChildElement("version");
+ if (!serviceVersionElem.isNull()) {
+ serviceVersion = serviceVersionElem.text().toDouble();
+ }
+
+ if (serviceVersion != effectVersion) {
+ QDomDocument scriptDoc;
+ scriptDoc.appendChild(scriptDoc.importNode(effect, true));
+
+ QScriptEngine sEngine;
+ sEngine.importExtension("qt.core");
+ sEngine.importExtension("qt.xml");
+ sEngine.evaluate(routines.text()).toString();
+ QString effectString = sEngine.globalObject().property("update").call(QScriptValue(), QScriptValueList() << serviceVersion << effectVersion << scriptDoc.toString()).toString();
+// kDebug() << "effStr" << effectString << "err" << sEngine.uncaughtExceptionLineNumber() << sEngine.uncaughtException().toString() << sEngine.uncaughtExceptionBacktrace();
+ if (!effectString.isEmpty()) {
+ scriptDoc.setContent(effectString);
+ QDomNode updatedEffect = effect.ownerDocument().importNode(scriptDoc.documentElement(), true);
+ effect.parentNode().replaceChild(updatedEffect, effect);
+ effect = updatedEffect.toElement();
+ }
+ }
+ }
+
if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
//kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND * * * * * * * * * * *";
// effect is key-framable, read all effects to retrieve keyframes
Index: /home/till/abs/kdenlive-svn/src/kdenlive/src/initeffects.cpp
===================================================================
--- /home/till/abs/kdenlive-svn/src/kdenlive/src/initeffects.cpp (revision 5852)
+++ /home/till/abs/kdenlive-svn/src/kdenlive/src/initeffects.cpp (working copy)
@@ -31,7 +31,9 @@
#include <qregexp.h>
#include <QDir>
#include <QIcon>
+#include <QScriptEngine>
+
initEffectsThumbnailer::initEffectsThumbnailer() :
QThread()
{
@@ -349,6 +351,39 @@
for (int i = 0; !effects.item(i).isNull(); ++i) {
documentElement = effects.item(i).toElement();
QString tag = documentElement.attribute("tag", QString());
+
+ double version = -1;
+ Mlt::Properties *metadata = repository->metadata(filter_type, tag.toUtf8().data());
+ if (metadata) {
+ if (metadata->is_valid()) {
+ version = metadata->get_double("version");
+ }
+ delete metadata;
+ }
+ if (documentElement.hasAttribute("version")) {
+ // a specific version of the filter is required
+ if (locale.toDouble(documentElement.attribute("version")) > version) {
+ return;
+ }
+ }
+
+ QDomElement routines = documentElement.firstChildElement("routines");
+ if (!routines.isNull()) {
+ QDomDocument effectDoc;
+ effectDoc.appendChild(effectDoc.importNode(documentElement, true));
+
+ QScriptEngine sEngine;
+ sEngine.importExtension("qt.core");
+ sEngine.importExtension("qt.xml");
+ sEngine.evaluate(routines.text()).toString();
+ QString effectString = sEngine.globalObject().property("adopt").call(QScriptValue(), QScriptValueList() << version << effectDoc.toString()).toString();
+ if (!effectString.isEmpty()) {
+ effectDoc.setContent(effectString);
+ doc.replaceChild(doc.importNode(effectDoc.documentElement(), true), documentElement);
+ documentElement = effects.item(i).toElement();
+ }
+ }
+
if (documentElement.hasAttribute("LC_NUMERIC")) {
// set a locale for that file
locale = QLocale(documentElement.attribute("LC_NUMERIC"));
@@ -377,18 +412,6 @@
}
}
- double version = -1;
- Mlt::Properties *metadata = repository->metadata(filter_type, tag.toUtf8().data());
- if (metadata && metadata->is_valid()) {
- version = metadata->get_double("version");
- }
- if (metadata) delete metadata;
- if (documentElement.hasAttribute("version")) {
- // a specific version of the filter is required
- if (locale.toDouble(documentElement.attribute("version")) > version) {
- return;
- }
- }
if (version > -1) {
// Add version info to XML
QDomNode versionNode = doc.createElement("version");
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Kdenlive-devel mailing list
Kdenlive-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kdenlive-devel