Cleanup profile handling, fix crash when opening some project files

parent 593e6d48
......@@ -198,6 +198,7 @@ bool EventEater::eventFilter(QObject *obj, QEvent *event)
Bin::Bin(QWidget* parent) :
QWidget(parent)
, isLoading(false)
, m_itemModel(NULL)
, m_itemView(NULL)
, m_rootFolder(NULL)
......@@ -847,6 +848,7 @@ void Bin::rowsRemoved(const QModelIndex &/*parent*/, int start, int /*end*/)
void Bin::selectProxyModel(const QModelIndex &id)
{
if (isLoading) return;
if (id.isValid()) {
AbstractProjectItem *currentItem = static_cast<AbstractProjectItem*>(m_proxyModel->mapToSource(id).internalPointer());
if (currentItem) {
......
......@@ -297,6 +297,8 @@ class Bin : public QWidget
public:
explicit Bin(QWidget* parent = 0);
~Bin();
bool isLoading;
/** @brief Sets the document for the bin and initialize some stuff */
void setDocument(KdenliveDoc *project);
......
......@@ -238,6 +238,25 @@ void ProfilesDialog::slotDeleteProfile()
if (!success) qDebug()<< "//// Cannot delete profile " << path << ", does not seem to be custom one";
}
// static
MltVideoProfile ProfilesDialog::getVideoProfileFromXml(const QDomElement &element)
{
MltVideoProfile result;
result.description = element.attribute("description");
result.frame_rate_num = element.attribute("frame_rate_num").toInt();
result.frame_rate_den = element.attribute("frame_rate_den").toInt();
result.width = element.attribute("width").toInt();
result.height = element.attribute("height").toInt();
result.progressive = element.attribute("progressive").toInt();
result.sample_aspect_num = element.attribute("sample_aspect_num").toInt();
result.sample_aspect_den = element.attribute("sample_aspect_den").toInt();
result.display_aspect_num = element.attribute("display_aspect_num").toInt();
result.display_aspect_den = element.attribute("display_aspect_den").toInt();
result.colorspace = element.attribute("colorspace").toInt();
result.path = existingProfile(result);
return result;
}
// static
MltVideoProfile ProfilesDialog::getVideoProfile(const QString &name)
{
......
......@@ -37,10 +37,13 @@ public:
void fillList(const QString &selectedProfile = QString());
static QMap< QString, QString > getSettingsFromFile(const QString& path);
/** @brief Create profile from xml in MLT project file */
static MltVideoProfile getVideoProfileFromXml(const QDomElement &element);
static MltVideoProfile getVideoProfile(const QString &name);
static MltVideoProfile getVideoProfile(Mlt::Profile &profile);
static QMap <QString, QString> getProfilesInfo();
static void saveProfile(MltVideoProfile &profile, QString profilePath = QString());
/** @brief Check if a given profile has a profile file describing it */
static QString existingProfile(const MltVideoProfile &profile);
static bool existingProfileDescription(const QString &desc);
......
......@@ -1238,6 +1238,7 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
EffectsList::setProperty(playlist, "kdenlive:customeffects", d2.toString());
}
EffectsList::setProperty(playlist, "kdenlive:docproperties.version", QString::number(currentVersion));
if (!infoXml.isNull()) EffectsList::setProperty(playlist, "kdenlive:docproperties.projectfolder", infoXml.attribute("projectfolder"));
}
m_modified = true;
return true;
......
......@@ -106,7 +106,6 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QUrl &projectFolder, QUndoGroup
connect(&m_fileWatcher, &KDirWatch::deleted, this, &KdenliveDoc::slotClipMissing);
connect(&m_modifiedTimer, &QTimer::timeout, this, &KdenliveDoc::slotProcessModifiedClips);
// init default document properties
m_documentProperties["zoom"] = '7';
m_documentProperties["verticalzoom"] = '1';
......@@ -127,7 +126,7 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QUrl &projectFolder, QUndoGroup
i.next();
m_documentProperties[i.key()] = i.value();
}
// Load metadata
QMapIterator<QString, QString> j(metadata);
while (j.hasNext()) {
......@@ -302,8 +301,10 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QUrl &projectFolder, QUndoGroup
// Something went wrong, or a new file was requested: create a new project
if (!success) {
m_url.clear();
setProfilePath(profileName);
//setProfilePath(profileName);
m_profile = ProfilesDialog::getVideoProfile(profileName);
m_document = createEmptyDocument(tracks.x(), tracks.y());
updateProjectProfile();
}
// Ask to create the project directory if it does not exist
......@@ -357,11 +358,13 @@ KdenliveDoc::~KdenliveDoc()
int KdenliveDoc::setSceneList()
{
m_render->resetProfile(KdenliveSettings::current_profile(), true);
//m_render->resetProfile(m_profile);
pCore->bin()->isLoading = true;
if (m_render->setSceneList(m_document.toString(), m_documentProperties.value("position").toInt()) == -1) {
// INVALID MLT Consumer, something is wrong
return -1;
}
pCore->bin()->isLoading = false;
pCore->binController()->checkThumbnails(projectFolder().path() + "/thumbs/");
m_documentProperties.remove("position");
return 0;
......@@ -410,6 +413,20 @@ QDomDocument KdenliveDoc::createEmptyDocument(const QList <TrackInfo> &tracks)
// Create black producer
// For some unknown reason, we have to build the black producer here and not in renderer.cpp, otherwise
// the composite transitions with the black track are corrupted.
/*QDomElement pro = doc.createElement("profile");
pro.setAttribute("frame_rate_den", QString::number(m_profile.frame_rate_den));
pro.setAttribute("frame_rate_num", QString::number(m_profile.frame_rate_num));
pro.setAttribute("display_aspect_den", QString::number(m_profile.display_aspect_den));
pro.setAttribute("display_aspect_num", QString::number(m_profile.display_aspect_num));
pro.setAttribute("sample_aspect_den", QString::number(m_profile.sample_aspect_den));
pro.setAttribute("sample_aspect_num", QString::number(m_profile.sample_aspect_num));
pro.setAttribute("width", QString::number(m_profile.width));
pro.setAttribute("height", QString::number(m_profile.height));
pro.setAttribute("progressive", QString::number((int) m_profile.progressive));
pro.setAttribute("colorspace", QString::number(m_profile.colorspace));
pro.setAttribute("description", m_profile.description);
mlt.appendChild(pro);*/
QDomElement blk = doc.createElement("producer");
blk.setAttribute("in", 0);
blk.setAttribute("out", 500);
......@@ -842,16 +859,8 @@ bool KdenliveDoc::setProfilePath(QString path)
setModified(true);
}
}
KdenliveSettings::setProject_display_ratio((double) m_profile.display_aspect_num / m_profile.display_aspect_den);
double fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
KdenliveSettings::setProject_fps(fps);
m_width = m_profile.width;
m_height = m_profile.height;
//qDebug() << "Kdenlive document, init timecode from path: " << path << ", " << m_fps;
m_timecode.setFormat(fps);
KdenliveSettings::setCurrent_profile(m_profile.path);
return (current_fps != fps);
updateProjectProfile();
return (current_fps != KdenliveSettings::project_fps());
}
double KdenliveDoc::dar() const
......@@ -1645,19 +1654,43 @@ const QMap <QString, QString> KdenliveDoc::documentProperties()
void KdenliveDoc::loadDocumentProperties()
{
QDomElement pl = m_document.firstChildElement("playlist");
if (pl.isNull()) return;
QDomNodeList props = pl.elementsByTagName("property");
QString name;
QDomElement e;
for (int i = 0; i < props.count(); i++) {
e = props.at(i).toElement();
name = e.attribute("name");
if (name.startsWith("kdenlive:docproperties.")) {
name = name.section(".", 1);
m_documentProperties.insert(name, e.firstChild().nodeValue());
QDomNodeList list = m_document.elementsByTagName("playlist");
if (!list.isEmpty()) {
QDomElement pl = list.at(0).toElement();
if (pl.isNull()) return;
QDomNodeList props = pl.elementsByTagName("property");
QString name;
QDomElement e;
for (int i = 0; i < props.count(); i++) {
e = props.at(i).toElement();
name = e.attribute("name");
if (name.startsWith("kdenlive:docproperties.")) {
name = name.section(".", 1);
m_documentProperties.insert(name, e.firstChild().nodeValue());
}
}
}
m_projectFolder = QUrl::fromLocalFile(m_documentProperties.value("projectfolder"));
//setProfilePath(m_documentProperties.value("profile"));
list = m_document.elementsByTagName("profile");
if (!list.isEmpty()) {
m_profile = ProfilesDialog::getVideoProfileFromXml(list.at(0).toElement());
}
updateProjectProfile();
}
void KdenliveDoc::updateProjectProfile()
{
KdenliveSettings::setProject_display_ratio((double) m_profile.display_aspect_num / m_profile.display_aspect_den);
double fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
KdenliveSettings::setProject_fps(fps);
m_width = m_profile.width;
m_height = m_profile.height;
m_timecode.setFormat(fps);
KdenliveSettings::setCurrent_profile(m_profile.path);
}
void KdenliveDoc::resetProfile()
{
m_profile = ProfilesDialog::getVideoProfile(KdenliveSettings::current_profile());
updateProjectProfile();
}
......@@ -105,7 +105,8 @@ public:
/** @brief Informs Kdenlive of the audio thumbnails generation progress. */
void setThumbsProgress(const QString &message, int progress);
const QString &profilePath() const;
Q_DECL_DEPRECATED MltVideoProfile mltProfile() const;
/** @brief Returns current project profile. */
MltVideoProfile mltProfile() const;
ProfileInfo getProfileInfo() const;
//Mlt::Profile *profile();
const QString description() const;
......@@ -159,6 +160,7 @@ public:
QString documentNotes() const;
/** @brief Saves effects embedded in project file. */
void saveCustomEffects(const QDomNodeList &customeffects);
void resetProfile();
private:
QUrl m_url;
......@@ -207,6 +209,8 @@ private:
void cleanupBackupFiles();
/** @brief Load document properties from the xml file */
void loadDocumentProperties();
/** @brief update document properties to reflect a change in the current profile */
void updateProjectProfile();
public slots:
void slotCreateXmlClip(const QString &name, const QDomElement &xml, const QString &group, const QString &groupId);
......
......@@ -210,7 +210,6 @@ QImage KThumb::getFrame(Mlt::Frame *frame, int width, int height)
QImage p(width, height, QImage::Format_ARGB32_Premultiplied);
/*p.fill(QColor(Qt::red).rgb());
return p;*/
if (frame == NULL || !frame->is_valid()) {
p.fill(QColor(Qt::red).rgb());
return p;
......
......@@ -1356,7 +1356,8 @@ void MainWindow::slotEditProjectSettings()
slotSwitchAudioThumbs();
}
if (project->profilePath() != profile) {
slotUpdateProjectProfile(profile);
KdenliveSettings::setCurrent_profile(profile);
pCore->projectManager()->slotResetProfiles();
}
if (project->getDocumentProperty("proxyparams") != w->proxyParams()) {
project->setModified();
......@@ -1405,48 +1406,6 @@ void MainWindow::slotDisableProxies()
slotUpdateProxySettings();
}
void MainWindow::slotUpdateProjectProfile(const QString &profile)
{
KdenliveDoc *project = pCore->projectManager()->current();
// Recreate the stopmotion widget if profile changes
if (m_stopmotion) {
delete m_stopmotion;
m_stopmotion = NULL;
}
// Deselect current effect / transition
m_effectStack->slotClipItemSelected(NULL);
m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
m_clipMonitor->openClip(NULL);
bool updateFps = project->setProfilePath(profile);
project->renderer()->resetBinProfile(profile);
KdenliveSettings::setProject_fps(project->fps());
setWindowTitle(project->description());
setWindowModified(project->isModified());
pCore->monitorManager()->resetProfiles(project->timecode());
m_transitionConfig->updateProjectFormat();
m_effectStack->updateProjectFormat(project->timecode());
if (m_renderWidget) {
m_renderWidget->setProfile(project->mltProfile());
}
if (updateFps) {
pCore->projectManager()->currentTimeline()->updateProjectFps();
}
project->clipManager()->clearCache();
pCore->projectManager()->currentTimeline()->updateProfile();
project->setModified(true);
m_commandStack->activeStack()->clear();
//Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
slotUpdateMousePosition(0);
//TODO
//m_projectList->slotReloadClip();
// We need to desactivate & reactivate monitors to get a refresh
//pCore->monitorManager()->switchMonitors();
}
void MainWindow::slotRenderProject()
{
KdenliveDoc *project = pCore->projectManager()->current();
......@@ -1539,12 +1498,8 @@ void MainWindow::connectDocument()
{
KdenliveDoc *project = pCore->projectManager()->current();
Timeline *trackView = pCore->projectManager()->currentTimeline();
qDebug()<<"------------------------- CONNECT DOCUMENT\n"<<project->profilePath()<<"\n- - - - -- - - -- -";
pCore->binController()->resetProfile(project->profilePath());
connect(project, SIGNAL(startAutoSave()), pCore->projectManager(), SLOT(slotStartAutoSave()));
connect(project, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
// Resetting monitor profiles should now be handled by binController
//pCore->monitorManager()->resetProfiles(project->timecode());
KdenliveSettings::setProject_fps(project->fps());
m_clipMonitorDock->raise();
m_transitionConfig->updateProjectFormat();
......@@ -1702,7 +1657,7 @@ void MainWindow::slotPreferences(int page, int option)
KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, m_gpuAllowed, this);
connect(dialog, SIGNAL(settingsChanged(QString)), this, SLOT(updateConfiguration()));
connect(dialog, SIGNAL(settingsChanged(QString)), SIGNAL(configurationChanged()));
connect(dialog, SIGNAL(doResetProfile()), pCore->monitorManager(), SLOT(slotResetProfiles()));
connect(dialog, SIGNAL(doResetProfile()), pCore->projectManager(), SLOT(slotResetProfiles()));
connect(dialog, SIGNAL(restartKdenlive()), this, SLOT(slotRestart()));
if (m_recMonitor) {
connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
......
......@@ -274,8 +274,6 @@ private slots:
void slotAddEffect(const QDomElement &effect);
void slotEditProfiles();
void slotEditProjectSettings();
/** @brief Change current document MLT profile. */
void slotUpdateProjectProfile(const QString &profile);
void slotDisplayActionMessage(QAction *a);
/** @brief Turns automatic splitting of audio and video on/off. */
......
......@@ -29,7 +29,6 @@ static const char* kPlaylistTrackId = "main bin";
BinController::BinController(QString profileName) :
QObject()
{
m_mltProfile = NULL;
m_binPlaylist = NULL;
// Disable VDPAU that crashes in multithread environment.
//TODO: make configurable
......@@ -38,12 +37,11 @@ BinController::BinController(QString profileName) :
if (profileName.isEmpty()) {
profileName = KdenliveSettings::current_profile();
}
resetProfile(profileName);
//resetProfile(profileName);
}
BinController::~BinController()
{
delete m_mltProfile;
}
Mlt::Repository *BinController::mltRepository()
......@@ -51,30 +49,9 @@ Mlt::Repository *BinController::mltRepository()
return m_repository;
}
void BinController::resetProfile(const QString &newProfile)
{
m_activeProfile = newProfile;
if (m_mltProfile) {
Mlt::Profile tmpProfile(m_activeProfile.toUtf8().constData());
m_mltProfile->set_colorspace(tmpProfile.colorspace());
m_mltProfile->set_frame_rate(tmpProfile.frame_rate_num(), tmpProfile.frame_rate_den());
m_mltProfile->set_height(tmpProfile.height());
m_mltProfile->set_width(tmpProfile.width());
m_mltProfile->set_progressive(tmpProfile.progressive());
m_mltProfile->set_sample_aspect(tmpProfile.sample_aspect_num(), tmpProfile.sample_aspect_den());
m_mltProfile->get_profile()->display_aspect_num = tmpProfile.display_aspect_num();
m_mltProfile->get_profile()->display_aspect_den = tmpProfile.display_aspect_den();
} else {
m_mltProfile = new Mlt::Profile(m_activeProfile.toUtf8().constData());
}
setenv("MLT_PROFILE", m_activeProfile.toUtf8().constData(), 1);
m_mltProfile->set_explicit(true);
KdenliveSettings::setCurrent_profile(m_activeProfile);
}
Mlt::Profile *BinController::profile()
{
return m_mltProfile;
return m_binPlaylist->profile();
}
void BinController::destroyBin()
......@@ -180,10 +157,10 @@ QMap<double,QString> BinController::takeGuidesData()
return guidesData;
}
void BinController::createIfNeeded()
void BinController::createIfNeeded(Mlt::Profile *profile)
{
if (m_binPlaylist) return;
m_binPlaylist = new Mlt::Playlist(*m_mltProfile);
m_binPlaylist = new Mlt::Playlist(*profile);
m_binPlaylist->set("id", kPlaylistTrackId);
}
......@@ -304,7 +281,7 @@ bool BinController::removeBinClip(const QString &id)
Mlt::Producer *BinController::cloneProducer(Mlt::Producer &original)
{
QString xml = getProducerXML(original);
Mlt::Producer *clone = new Mlt::Producer(*m_mltProfile, "xml-string", xml.toUtf8().constData());
Mlt::Producer *clone = new Mlt::Producer(*original.profile(), "xml-string", xml.toUtf8().constData());
return clone;
}
......@@ -335,12 +312,12 @@ Mlt::Producer *BinController::getBinVideoProducer(const QString &id)
double BinController::fps() const
{
return m_mltProfile->fps();
return m_binPlaylist->profile()->fps();
}
double BinController::dar() const
{
return m_mltProfile->dar();
return m_binPlaylist->profile()->dar();
}
void BinController::duplicateFilters(Mlt::Producer original, Mlt::Producer clone)
......@@ -357,7 +334,7 @@ void BinController::duplicateFilters(Mlt::Producer original, Mlt::Producer clone
if (filter->is_valid()/* && strcmp(filter->get("kdenlive_id"), "") && strcmp(filter->get("kdenlive_id"), "fadein") && strcmp(filter->get("kdenlive_id"), "fade_from_black")*/) {
// looks like there is no easy way to duplicate a filter,
// so we will create a new one and duplicate its properties
Mlt::Filter *dup = new Mlt::Filter(*m_mltProfile, filter->get("mlt_service"));
Mlt::Filter *dup = new Mlt::Filter(*original.profile(), filter->get("mlt_service"));
if (dup && dup->is_valid()) {
Mlt::Properties entries(filter->get_properties());
for (int i = 0; i < entries.count(); ++i) {
......@@ -394,7 +371,7 @@ QString BinController::xmlFromId(const QString & id)
QString BinController::getProducerXML(Mlt::Producer &producer)
{
QString filename = "string";
Mlt::Consumer c(*m_mltProfile, "xml", filename.toUtf8().constData());
Mlt::Consumer c(*producer.profile(), "xml", filename.toUtf8().constData());
Mlt::Service s(producer.get_service());
if (!s.is_valid())
return "";
......
......@@ -61,11 +61,6 @@ public:
/** @brief Returns the project's dar. */
double dar() const;
/** @brief Reset the profile to a new one, for example when loading a document with another profile.
* @param newProfile The file name for the new MLT profile
* */
void resetProfile(const QString &newProfile);
/** @brief Returns the service for the Bin's playlist, used to make sure MLT will save it correctly in its XML. */
mlt_service service();
......@@ -93,7 +88,7 @@ public:
void initializeBin(Mlt::Playlist playlist);
/** @brief If our bin's playlist does not exist, create a new one */
void createIfNeeded();
void createIfNeeded(Mlt::Profile *profile);
/** @brief Returns true if a clip with that id is in our bin's playlist
* @param id The clip's id as stored in DocClipBase
......@@ -174,9 +169,6 @@ private:
/** @brief The current MLT profile's filename */
QString m_activeProfile;
/** @brief The MLT profile */
Mlt::Profile *m_mltProfile;
/** @brief The MLT repository, useful for filter/producer requests */
Mlt::Repository *m_repository;
......
......@@ -88,9 +88,10 @@ GLWidget::GLWidget()
importPath.cd("modules");
engine()->addImportPath(importPath.path());
QmlUtilities::setCommonProperties((QQuickView*)this);*/
m_monitorProfile = new Mlt::Profile();
if (KdenliveSettings::gpu_accel())
m_glslManager = new Mlt::Filter(*pCore->binController()->profile(), "glsl.manager");
m_glslManager = new Mlt::Filter(*m_monitorProfile, "glsl.manager");
if ((m_glslManager && !m_glslManager->is_valid())) {
delete m_glslManager;
m_glslManager = 0;
......@@ -172,7 +173,7 @@ void GLWidget::resizeGL(int width, int height)
{
int x, y, w, h;
double this_aspect = (double) width / height;
double video_aspect = m_consumer->profile()->dar();
double video_aspect = m_monitorProfile->dar();
// Special case optimisation to negate odd effect of sample aspect ratio
// not corresponding exactly with image resolution.
......@@ -195,7 +196,7 @@ void GLWidget::resizeGL(int width, int height)
x = (width - w) / 2;
y = (height - h) / 2;
m_rect.setRect(x, y, w, h);
double scale = (double) m_rect.width() / m_consumer->profile()->width() * m_zoom;
double scale = (double) m_rect.width() / m_monitorProfile->width() * m_zoom;
QPoint center = m_rect.center();
QQuickItem* rootQml = rootObject();
if (rootQml) {
......@@ -307,7 +308,7 @@ void GLWidget::paintGL()
m_shader->setUniformValue(m_textureLocation[0], 0);
m_shader->setUniformValue(m_textureLocation[1], 1);
m_shader->setUniformValue(m_textureLocation[2], 2);
m_shader->setUniformValue(m_colorspaceLocation, pCore->binController()->profile()->colorspace());
m_shader->setUniformValue(m_colorspaceLocation, m_monitorProfile->colorspace());
}
check_error();
......@@ -612,7 +613,7 @@ void GLWidget::createAudioOverlay(bool isAudio)
// Audiowaveform filter crashes on Movit + audio clips)
return;
}
Mlt::Filter f(*pCore->binController()->profile(), "audiowaveform");
Mlt::Filter f(*m_monitorProfile, "audiowaveform");
if (f.is_valid()) {
//f.set("show_channel", 1);
f.set("color.1", "0xffff0099");
......@@ -676,7 +677,7 @@ int GLWidget::reconfigure(bool isMulti)
QString serviceName = property("mlt_service").toString();
if (!m_consumer || !m_consumer->is_valid()) {
if (serviceName.isEmpty()) {
m_consumer = new Mlt::FilteredConsumer(*pCore->binController()->profile(), "sdl_audio");
m_consumer = new Mlt::FilteredConsumer(*m_monitorProfile, "sdl_audio");
if (m_consumer->is_valid())
serviceName = "sdl_audio";
else {
......@@ -687,9 +688,9 @@ int GLWidget::reconfigure(bool isMulti)
setProperty("mlt_service", serviceName);
}
if (isMulti)
m_consumer = new Mlt::FilteredConsumer(*pCore->binController()->profile(), "multi");
m_consumer = new Mlt::FilteredConsumer(*m_monitorProfile, "multi");
else if (!m_consumer)
m_consumer = new Mlt::FilteredConsumer(*pCore->binController()->profile(), serviceName.toLatin1().constData());
m_consumer = new Mlt::FilteredConsumer(*m_monitorProfile, serviceName.toLatin1().constData());
delete m_threadStartEvent;
m_threadStartEvent = 0;
......@@ -727,7 +728,7 @@ int GLWidget::reconfigure(bool isMulti)
#else
m_consumer->set("0.audio_buffer", 512);
#endif
/*if (!m_consumer->profile()->progressive())
/*if (!m_monitorProfile->progressive())
m_consumer->set("0.progressive", property("progressive").toBool());*/
m_consumer->set("0.deinterlace_method", KdenliveSettings::mltdeinterlacer().toUtf8().constData());
......@@ -744,7 +745,7 @@ int GLWidget::reconfigure(bool isMulti)
#else
m_consumer->set("audio_buffer", 512);
#endif
/*if (!m_consumer->profile()->progressive())
/*if (!m_monitorProfile->progressive())
m_consumer->set("progressive", property("progressive").toBool());*/
m_consumer->set("progressive", 1);
m_consumer->set("rescale", KdenliveSettings::mltinterpolation().toUtf8().constData());
......@@ -789,9 +790,9 @@ void GLWidget::slotShowEffectScene()
QObject *item = rootObject();
if (!item) return;
QObject::connect(item, SIGNAL(effectChanged()), this, SLOT(effectRectChanged()), Qt::UniqueConnection);
item->setProperty("profile", QPoint(m_consumer->profile()->width(), m_consumer->profile()->height()));
item->setProperty("framesize", QRect(0, 0, m_consumer->profile()->width(), m_consumer->profile()->height()));
item->setProperty("scale", (double) m_rect.width() / m_consumer->profile()->width() * m_zoom);
item->setProperty("profile", QPoint(m_monitorProfile->width(), m_monitorProfile->height()));
item->setProperty("framesize", QRect(0, 0, m_monitorProfile->width(), m_monitorProfile->height()));
item->setProperty("scale", (double) m_rect.width() / m_monitorProfile->width() * m_zoom);
item->setProperty("center", m_rect.center());
}
......@@ -799,24 +800,46 @@ void GLWidget::slotShowRootScene()
{
QObject *item = rootObject();
if (!item) return;
item->setProperty("scale", (double) m_rect.width() / m_consumer->profile()->width() * m_zoom);
item->setProperty("scale", (double) m_rect.width() / m_monitorProfile->width() * m_zoom);
item->setProperty("center", m_rect.center());
}
float GLWidget::zoom() const
{
return m_zoom;// * m_consumer->profile()->width() / m_rect.width();
return m_zoom;// * m_monitorProfile->width() / m_rect.width();
}
Mlt::Profile *GLWidget::profile()
{
return m_monitorProfile;
}
void GLWidget::resetProfile(MltVideoProfile profile)
{
if (m_consumer && !m_consumer->is_stopped()) {
m_consumer->stop();
m_consumer->purge();
}
//m_monitorProfile->get_profile()->description = profile.description.toUtf8().data();
m_monitorProfile->set_colorspace(profile.colorspace);
m_monitorProfile->set_frame_rate(profile.frame_rate_num, profile.frame_rate_den);
m_monitorProfile->set_height(profile.height);
m_monitorProfile->set_width(profile.width);
m_monitorProfile->set_progressive(profile.progressive);
m_monitorProfile->set_sample_aspect(profile.sample_aspect_num, profile.sample_aspect_den);
m_monitorProfile->set_display_aspect(profile.display_aspect_num, profile.display_aspect_den);
m_monitorProfile->set_explicit(true);
}
QSize GLWidget::profileSize() const
{
return QSize(m_consumer->profile()->width(), m_consumer->profile()->height());
return QSize(m_monitorProfile->width(), m_monitorProfile->height());
}
QPoint GLWidget::offset() const
{
return QPoint(m_offset.x() - (m_consumer->profile()->width() * m_zoom - width()) / 2,
m_offset.y() - (m_consumer->profile()->height() * m_zoom - height()) / 2);
return QPoint(m_offset.x() - (m_monitorProfile->width() * m_zoom - width()) / 2,
m_offset.y() - (m_monitorProfile->height() * m_zoom - height()) / 2);
}
void GLWidget::setZoom(float zoom)
......
......@@ -28,7 +28,9 @@
#include <QMutex>
#include <QThread>
#include <QRect>