Reduce preview rendering chunks to 100 frames, don't invalidate on audio effects

parent 2c0987f0
......@@ -121,6 +121,11 @@ ProducerQueue *Core::producerQueue()
return m_producerQueue;
}
Mlt::Repository *Core::mltRepository()
{
return m_binController->mltRepository();
}
LibraryWidget *Core::library()
{
return m_library;
......
......@@ -22,6 +22,10 @@ class Bin;
class LibraryWidget;
class ProducerQueue;
namespace Mlt {
class Repository;
};
#define pCore Core::self()
......@@ -48,7 +52,7 @@ public:
/** @brief Returns a pointer to the singleton object. */
static Core *self();
/** @brief Builds all necessary parts. */
void initialize();
......@@ -61,6 +65,7 @@ public:
MonitorManager *monitorManager();
/** @brief Returns a pointer to the project bin controller. */
BinController *binController();
Mlt::Repository *mltRepository();
/** @brief Returns a pointer to the project bin. */
Bin *bin();
/** @brief Returns a pointer to the producer queue. */
......
......@@ -1857,9 +1857,9 @@ void Render::previewRendering(QPoint zone, const QString &cacheDir, const QStrin
}
QDir dir(cacheDir);
dir.mkpath(QStringLiteral("."));
// Data is rendered in 200 frames chunks
int startChunk = zone.x() / 200;
int endChunk = rintl(zone.y() / 200);
// Data is rendered in 100 frames chunks
int startChunk = zone.x() / 100;
int endChunk = rintl(zone.y() / 100);
// Save temporary scenelist
QString sceneListFile = dir.absoluteFilePath(documentId + ".mlt");
Mlt::Consumer xmlConsumer(*m_qmlView->profile(), "xml", sceneListFile.toUtf8().constData());
......@@ -1889,14 +1889,14 @@ void Render::doPreviewRender(int start, int end, QDir folder, QString id, QStrin
}
if (folder.exists(fileName)) {
// This chunk already exists
emit previewRender(i * 200, folder.absoluteFilePath(fileName), progress);
emit previewRender(i * 100, folder.absoluteFilePath(fileName), progress);
continue;
}
// Build rendering process
QStringList args;
args << scene;
args << "in=" + QString::number(i * 200);
args << "out=" + QString::number(i * 200 + 199);
args << "in=" + QString::number(i * 100);
args << "out=" + QString::number(i * 100 + 99);
args << "-consumer" << "avformat:" + folder.absoluteFilePath(fileName);
args << "an=1";
int result = QProcess::execute(KdenliveSettings::rendererpath(), args);
......@@ -1904,7 +1904,7 @@ void Render::doPreviewRender(int start, int end, QDir folder, QString id, QStrin
// Something is wrong, abort
break;
}
emit previewRender(i * 200, folder.absoluteFilePath(fileName), progress);
emit previewRender(i * 100, folder.absoluteFilePath(fileName), progress);
}
QFile::remove(scene);
m_abortPreview = false;
......
......@@ -1361,7 +1361,6 @@ EffectsParameterList ClipItem::addEffect(ProfileInfo info, QDomElement effect, b
needInOutSync = true;
}
// check if it is a fade effect
if (effectId == QLatin1String("fadein")) {
needRepaint = true;
......
......@@ -477,7 +477,7 @@ void CustomRuler::paintEvent(QPaintEvent *e)
// draw Rendering preview zones
QColor preview(Qt::green);
foreach(int frame, m_renderingPreviews) {
QRect rec(frame * m_factor - m_offset, MAX_HEIGHT - 2, 199 * m_factor, 2);
QRect rec(frame * m_factor - m_offset, MAX_HEIGHT - 2, 99 * m_factor, 2);
p.fillRect(rec, preview);
}
......@@ -509,5 +509,5 @@ void CustomRuler::updatePreview(int frame, bool rendered)
m_renderingPreviews << frame;
else
m_renderingPreviews.removeAll(frame);
update(frame * m_factor - offset(), MAX_HEIGHT - 2, (199) * m_factor, 2);
update(frame * m_factor - offset(), MAX_HEIGHT - 2, (99) * m_factor, 2);
}
......@@ -258,7 +258,7 @@ bool EffectManager::editEffect(EffectsParameterList params, int duration, bool r
if (!params.paramValue(QStringLiteral("keyframes")).isEmpty() || replaceEffect || tag.startsWith(QLatin1String("ladspa")) || tag == QLatin1String("sox") || tag == QLatin1String("autotrack_rectangle")) {
// This is a keyframe effect, to edit it, we remove it and re-add it.
if (removeEffect(index, false)) {
if (!removeEffect(index, false).isEmpty()) {
return addEffect(params, duration);
}
}
......@@ -332,17 +332,17 @@ bool EffectManager::editEffect(EffectsParameterList params, int duration, bool r
return true;
}
bool EffectManager::removeEffect(int effectIndex, bool updateIndex)
const QString &EffectManager::removeEffect(int effectIndex, bool updateIndex)
{
m_producer.lock();
bool success = false;
int ct = 0;
QString filterTag;
Mlt::Filter *filter = m_producer.filter(ct);
while (filter) {
if ((effectIndex == -1 && strcmp(filter->get("kdenlive_id"), "")) || filter->get_int("kdenlive_ix") == effectIndex) {
if (m_producer.detach(*filter) == 0) {
filterTag = filter->get("tag");
delete filter;
success = true;
}
} else if (updateIndex) {
// Adjust the other effects index
......@@ -352,7 +352,7 @@ bool EffectManager::removeEffect(int effectIndex, bool updateIndex)
filter = m_producer.filter(ct);
}
m_producer.unlock();
return success;
return filterTag;
}
......
......@@ -45,7 +45,7 @@ public:
bool addEffect(EffectsParameterList params, int duration);
bool doAddFilter(EffectsParameterList params, int duration);
bool editEffect(EffectsParameterList params, int duration, bool replaceEffect);
bool removeEffect(int effectIndex, bool updateIndex);
const QString &removeEffect(int effectIndex, bool updateIndex);
public Q_SLOTS:
......
......@@ -1755,21 +1755,21 @@ void Timeline::invalidatePreview(int startFrame, int length)
{
if (!m_hasOverlayTrack)
return;
int start = startFrame / 200;
int end = lrintf((startFrame + length) / 200);
int start = startFrame / 100;
int end = lrintf((startFrame + length) / 100);
Mlt::Producer *overlayTrack = m_tractor->track(tracksCount());
m_tractor->lock();
Mlt::Playlist trackPlaylist((mlt_playlist) overlayTrack->get_service());
delete overlayTrack;
QList <int> list;
for (int i = start; i <=end; i++) {
int ix = trackPlaylist.get_clip_index_at(200 * i);
if (trackPlaylist.is_blank(i))
int ix = trackPlaylist.get_clip_index_at(100 * i);
if (trackPlaylist.is_blank(ix))
continue;
list << i;
Mlt::Producer *prod = trackPlaylist.replace_with_blank(ix);
delete prod;
m_ruler->updatePreview(i * 200, false);
m_ruler->updatePreview(i * 100, false);
}
trackPlaylist.consolidate_blanks();
m_tractor->unlock();
......
......@@ -26,6 +26,7 @@
#include "kdenlivesettings.h"
#include "clip.h"
#include "effectmanager.h"
#include "core.h"
#include <QtGlobal>
#include <QDebug>
......@@ -897,14 +898,36 @@ bool Track::addEffect(double start, EffectsParameterList params)
}
Mlt::Service clipService(clip->get_service());
EffectManager effect(clipService);
return effect.addEffect(params, duration);
bool success = effect.addEffect(params, duration);
if (success) {
checkEffect(params.paramValue(QStringLiteral("tag")), pos, duration);
}
return success;
}
void Track::checkEffect(const QString effectName, int pos, int duration)
{
Mlt::Repository *rep = pCore->mltRepository();
Mlt::Properties *metadata = rep->metadata(filter_type, effectName.toLatin1().data());
Mlt::Properties tags((mlt_properties) metadata->get_data("tags"));
if (QString(tags.get(0)) != QLatin1String("Audio")) {
emit invalidatePreview(pos, duration);
} else {
// This is an audio effect, don't touch
}
delete metadata;
}
bool Track::addTrackEffect(EffectsParameterList params)
{
Mlt::Service trackService(m_playlist.get_service());
EffectManager effect(trackService);
return effect.addEffect(params, m_playlist.get_playtime() - 1);
int duration = m_playlist.get_playtime() - 1;
bool success = effect.addEffect(params, duration);
if (success) {
checkEffect(params.paramValue(QStringLiteral("tag")), 0, duration);
}
return success;
}
bool Track::editEffect(double start, EffectsParameterList params, bool replace)
......@@ -918,31 +941,49 @@ bool Track::editEffect(double start, EffectsParameterList params, bool replace)
}
Mlt::Service clipService(clip->get_service());
EffectManager effect(clipService);
return effect.editEffect(params, duration, replace);
bool success = effect.editEffect(params, duration, replace);
if (success) {
checkEffect(params.paramValue(QStringLiteral("tag")), pos, duration);
}
return success;
}
bool Track::editTrackEffect(EffectsParameterList params, bool replace)
{
EffectManager effect(m_playlist);
return effect.editEffect(params, m_playlist.get_playtime() - 1, replace);
int duration = m_playlist.get_playtime() - 1;
bool success = effect.editEffect(params, duration, replace);
if (success) {
checkEffect(params.paramValue(QStringLiteral("tag")), 0, duration);
}
return success;
}
bool Track::removeEffect(double start, int effectIndex, bool updateIndex)
{
int pos = frame(start);
int clipIndex = m_playlist.get_clip_index_at(pos);
int duration = m_playlist.clip_length(clipIndex);
QScopedPointer<Mlt::Producer> clip(m_playlist.get_clip(clipIndex));
if (!clip) {
return false;
}
Mlt::Service clipService(clip->get_service());
EffectManager effect(clipService);
return effect.removeEffect(effectIndex, updateIndex);
const QString effectTag = effect.removeEffect(effectIndex, updateIndex);
if (!effectTag.isEmpty()) {
checkEffect(effectTag, pos, duration);
}
return (!effectTag.isEmpty());
}
bool Track::removeTrackEffect(int effectIndex, bool updateIndex)
{
EffectManager effect(m_playlist);
return effect.removeEffect(effectIndex, updateIndex);
const QString effectTag = effect.removeEffect(effectIndex, updateIndex);
if (!effectTag.isEmpty()) {
checkEffect(effectTag, 0, m_playlist.get_playtime() - 1);
}
return (!effectTag.isEmpty());
}
......@@ -216,6 +216,7 @@ private:
Mlt::Playlist m_playlist;
/** @brief Returns true is this MLT service needs duplication to work on multiple tracks */
bool needsDuplicate(const QString &service) const;
void checkEffect(const QString effectName, int pos, int duration);
};
#endif // TRACK_H
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