]> git.sesse.net Git - kdenlive/commitdiff
* Clean up profiles handling
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 5 Aug 2008 23:48:35 +0000 (23:48 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 5 Aug 2008 23:48:35 +0000 (23:48 +0000)
* Add separate X11 and XVideo drivers for SDL, where X11 disables hardware accel

svn path=/branches/KDE4/; revision=2364

src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/kdenlivesettingsdialog.cpp
src/mainwindow.cpp
src/mainwindow.h
src/monitor.cpp
src/monitor.h
src/monitormanager.cpp
src/monitormanager.h
src/renderer.cpp
src/renderer.h

index 9e1769f16c1075368dbf62c575f4776733cebda5..561f411fe89983786f23287fc6a8d0380d36b86d 100644 (file)
 #include "mainwindow.h"
 
 
-KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new QUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0), m_zoom(7) {
-    kDebug() << "// init profile, ratnum: " << profile.frame_rate_num << ", " << profile.frame_rate_num << ", width: " << profile.width;
+KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), m_commandStack(new QUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0), m_zoom(7) {
     m_clipManager = new ClipManager(this);
-    KdenliveSettings::setProject_fps(m_fps);
     if (!url.isEmpty()) {
         QString tmpFile;
         if (KIO::NetAccess::download(url.path(), tmpFile, parent)) {
@@ -54,7 +52,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoPro
                 QString profilePath = infoXml.attribute("profile");
                 m_startPos = infoXml.attribute("position").toInt();
                 m_zoom = infoXml.attribute("zoom", "7").toInt();
-                if (!profilePath.isEmpty()) setProfilePath(profilePath);
+                setProfilePath(profilePath);
                 double version = infoXml.attribute("version").toDouble();
                 if (version < 0.7) convertDocument(version);
                 else {
@@ -263,9 +261,7 @@ void KdenliveDoc::convertDocument(double version) {
     QDomNode props = m_document.elementsByTagName("properties").at(0).toElement();
     QString profile = props.toElement().attribute("videoprofile");
     if (profile == "dv_wide") profile = "dv_pal_wide";
-    if (!profile.isEmpty()) {
-        setProfilePath(profile);
-    } else setProfilePath("dv_pal");
+    setProfilePath(profile);
 
     // move playlists outside of tractor and add the tracks instead
     int max = playlists.count();
@@ -409,12 +405,12 @@ QString KdenliveDoc::profilePath() const {
 }
 
 void KdenliveDoc::setProfilePath(QString path) {
-    KdenliveSettings::setCurrent_profile(path);
+    if (path.isEmpty()) path = KdenliveSettings::default_profile();
+    if (path.isEmpty()) path = "dv_pal";
     m_profile = ProfilesDialog::getVideoProfile(path);
     m_fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
     m_width = m_profile.width;
     m_height = m_profile.height;
-    KdenliveSettings::setProject_fps(m_fps);
     kDebug() << "KDEnnlive document, init timecode from path: " << path << ",  " << m_fps;
     if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
     else m_timecode.setFormat((int) m_fps);
index 391fe90ba1f8e2d96c6d7008ddefb46d49840f03..8dbdae19f3596885e7258d54cdf2a29fce0ae76a 100644 (file)
@@ -45,7 +45,7 @@ class MainWindow;
 class KdenliveDoc: public QObject {
 Q_OBJECT public:
 
-    KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, MainWindow *parent = 0);
+    KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, MainWindow *parent = 0);
     ~KdenliveDoc();
     QDomNodeList producersList();
     double fps() const;
index c2b5736df5d7234096b6f21306e4c8129c316b83..8c23010801e8cbddb0dd294d160ee494cfc49090 100644 (file)
@@ -127,7 +127,8 @@ void KdenliveSettingsDialog::initDevices() {
 
     // Fill video drivers
     m_configSdl.kcfg_video_driver->addItem(i18n("Automatic"), QString());
-    m_configSdl.kcfg_video_driver->addItem(i18n("X11"), "x11");
+    m_configSdl.kcfg_video_driver->addItem(i18n("XVideo"), "x11");
+    m_configSdl.kcfg_video_driver->addItem(i18n("X11"), "x11_noaccel");
     m_configSdl.kcfg_video_driver->addItem(i18n("XFREE86 DGA 2.0"), "dga");
     m_configSdl.kcfg_video_driver->addItem(i18n("Nano X"), "nanox");
     m_configSdl.kcfg_video_driver->addItem(i18n("Framebuffer console"), "fbcon");
index 106fb0e092e7e688e33e8c9ff7d494a9361aaaf4..99b255219cf8ae09d34f13fe10d95bd393d118ac 100644 (file)
@@ -747,13 +747,10 @@ void MainWindow::newFile() {
         projectFolder = w->selectedFolder();
         delete w;
     }
-    MltVideoProfile prof;
-    if (!profileName.isEmpty()) prof = ProfilesDialog::getVideoProfile(profileName);
-    else prof = ProfilesDialog::getVideoProfile("dv_pal");
-    if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
-    KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, prof, m_commandStack, this);
+    KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, this);
+    doc->setProfilePath(profileName);
     TrackView *trackView = new TrackView(doc, this);
-    m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description);
+    m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
     if (m_timelineArea->count() == 1) {
         connectDocumentInfo(doc);
         connectDocument(trackView, doc);
@@ -840,14 +837,16 @@ void MainWindow::openFile(const KUrl &url) {
     }
 
     //TODO: get video profile from url before opening it
-    MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
+    /*MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
     if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
+
+    KdenliveSettings::setCurrent_profile(prof.path);*/
     KdenliveDoc *doc;
     if (recovery) {
-        doc = new KdenliveDoc(recoveryUrl, KUrl(), prof, m_commandStack, this);
+        doc = new KdenliveDoc(recoveryUrl, KUrl(), m_commandStack, this);
         doc->setUrl(url);
         doc->setModified(true);
-    } else doc = new KdenliveDoc(url, KUrl(), prof, m_commandStack, this);
+    } else doc = new KdenliveDoc(url, KUrl(), m_commandStack, this);
     connectDocumentInfo(doc);
     TrackView *trackView = new TrackView(doc, this);
     m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
@@ -855,7 +854,6 @@ void MainWindow::openFile(const KUrl &url) {
     if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
     slotGotProgressInfo(QString(), -1);
     m_projectMonitor->refreshMonitor(true);
-    //connectDocument(trackView, doc);
 }
 
 
@@ -923,9 +921,10 @@ void MainWindow::slotEditProjectSettings() {
     if (w->exec() == QDialog::Accepted) {
         QString profile = w->selectedProfile();
         m_activeDocument->setProfilePath(profile);
-        m_monitorManager->resetProfiles(profile);
+        KdenliveSettings::setCurrent_profile(profile);
+        KdenliveSettings::setProject_fps(m_activeDocument->fps());
         setCaption(m_activeDocument->description());
-        KdenliveSettings::setCurrent_profile(m_activeDocument->profilePath());
+        m_monitorManager->resetProfiles();
         if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
         m_monitorManager->setTimecode(m_activeDocument->timecode());
         m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
@@ -1041,8 +1040,9 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
         disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
         m_clipMonitor->stop();
     }
+    KdenliveSettings::setCurrent_profile(doc->profilePath());
     KdenliveSettings::setProject_fps(doc->fps());
-    m_monitorManager->resetProfiles(doc->profilePath());
+    m_monitorManager->resetProfiles();
     m_projectList->setDocument(doc);
     connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
     connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
@@ -1084,7 +1084,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
     trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
     m_activeTimeline = trackView;
-    KdenliveSettings::setCurrent_profile(doc->profilePath());
     if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
     m_monitorManager->setTimecode(doc->timecode());
     doc->setRenderer(m_projectMonitor->render);
@@ -1116,7 +1115,7 @@ void MainWindow::slotPreferences(int page, int option) {
     // create it :
     KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
-    connect(dialog, SIGNAL(doResetProfile()), this, SLOT(resetProfiles()));
+    connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(resetProfiles()));
     dialog->show();
     if (page != -1) dialog->showPage(page, option);
 }
@@ -1135,10 +1134,6 @@ void MainWindow::updateConfiguration() {
 
 }
 
-void MainWindow::resetProfiles() {
-    m_monitorManager->resetProfiles(m_activeDocument->profilePath());
-}
-
 void MainWindow::slotSwitchVideoThumbs() {
     KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
     if (m_activeTimeline) {
index a0bd27e3d33c3f524a2bd4d7066e032915982fd0..640d8032781dae9c2453e557429f404e1895d68e 100644 (file)
@@ -230,7 +230,6 @@ private slots:
     void slotPasteEffects();
     void slotReloadEffects();
     void slotChangeClipSpeed();
-    void resetProfiles();
 };
 
 
index 0048c04ac346a0e06e07507cc90d731240d2df02..83572f93dc0cf17009b0b038eb3cf4e94bedf269 100644 (file)
@@ -325,9 +325,9 @@ void Monitor::slotOpenFile(const QString &file) {
     render->setSceneList(doc, 0);
 }
 
-void Monitor::resetProfile(QString prof) {
+void Monitor::resetProfile() {
     if (render == NULL) return;
-    render->resetProfile(prof);
+    render->resetProfile();
 }
 
 void Monitor::saveSceneList(QString path, QDomElement info) {
index 579e3fa0e1cdf058fb343ef29d411f9ca1f28fc3..d0814a7162fa113aa1b06e323c645121471a4dc5 100644 (file)
@@ -49,7 +49,7 @@ class Monitor : public QWidget {
 public:
     Monitor(QString name, MonitorManager *manager, QWidget *parent = 0);
     Render *render;
-    void resetProfile(QString prof);
+    void resetProfile();
     QString name() const;
 
 
index a8045c1d0543acbe0b217969b4f20e978923d072..62b1773d0cd1fa0cd9de42bc4371496932d54c94 100644 (file)
@@ -111,11 +111,11 @@ void MonitorManager::slotEnd() {
     else m_projectMonitor->slotEnd();
 }
 
-void MonitorManager::resetProfiles(QString prof) {
+void MonitorManager::resetProfiles() {
     activateMonitor("clip");
-    m_clipMonitor->resetProfile(prof);
+    m_clipMonitor->resetProfile();
     activateMonitor("project");
-    m_projectMonitor->resetProfile(prof);
+    m_projectMonitor->resetProfile();
     //m_projectMonitor->refreshMonitor(true);
 }
 
index 972dfdb9eaaf4843960d9b1550f792c190728c1e..d0470d08056c3a7548151afcb78053fb28c2669a 100644 (file)
@@ -34,7 +34,6 @@ public:
     void initMonitors(Monitor *clipMonitor, Monitor *projectMonitor);
     Timecode timecode();
     void setTimecode(Timecode tc);
-    void resetProfiles(QString prof);
     void switchMonitors();
     bool projectMonitorFocused();
 
@@ -47,6 +46,7 @@ public slots:
     void slotForwardOneFrame();
     void slotStart();
     void slotEnd();
+    void resetProfiles();
 
 private:
     Monitor *m_clipMonitor;
index 12312dde1ac1eeac527b3a9eaa398a77121b83c2..c413b93199072452055038f065fdce58f30b15a8 100644 (file)
@@ -28,6 +28,8 @@ extern "C" {
 #include <avformat.h>
 }
 
+#include <stdlib.h>
+
 #include <QTimer>
 #include <QDir>
 #include <QApplication>
@@ -64,8 +66,7 @@ static void consumer_frame_show(mlt_consumer, Render * self, mlt_frame frame_ptr
 }
 
 Render::Render(const QString & rendererName, int winid, int extid, QWidget *parent): QObject(parent), m_name(rendererName), m_mltConsumer(NULL), m_mltProducer(NULL), m_mltTextProducer(NULL), m_winid(-1), m_framePosition(0), m_generateScenelist(false), m_isBlocked(true), m_blackClip(NULL), m_isSplitView(false) {
-    kDebug() << "//////////  USING PROFILE: " << (char *)KdenliveSettings::current_profile().toUtf8().data();
-    m_mltProfile = new Mlt::Profile((char*) KdenliveSettings::current_profile().data());
+    kDebug() << "//////////  USING PROFILE: " << (char*)KdenliveSettings::current_profile().toUtf8().data();
     refreshTimer = new QTimer(this);
     connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
 
@@ -75,66 +76,18 @@ Render::Render(const QString & rendererName, int winid, int extid, QWidget *pare
     connect(osdTimer, SIGNAL(timeout()), this, SLOT(slotOsdTimeout()));
 
     m_osdProfile =   KStandardDirs::locate("data", "kdenlive/profiles/metadata.properties");
-    //if (rendererName == "clip")
-    {
-        //Mlt::Consumer *consumer = new Mlt::Consumer( profile , "sdl_preview");
-        m_mltConsumer = new Mlt::Consumer(*m_mltProfile , "sdl_preview"); //consumer;
-        m_mltConsumer->set("resize", 1);
-        m_mltConsumer->set("window_id", winid);
-        m_mltConsumer->set("terminate_on_pause", 1);
-        m_mltConsumer->set("rescale", "nearest");
-        m_mltConsumer->set("progressive", 1);
-        char *tmp;
-
-        QString audioDevice = KdenliveSettings::audiodevicename();
-        if (!audioDevice.isEmpty()) {
-            tmp = decodedString(audioDevice);
-            m_mltConsumer->set("audio_device", tmp);
-            delete[] tmp;
-        }
-
-        QString videoDriver = KdenliveSettings::videodrivername();
-        if (!videoDriver.isEmpty()) {
-            tmp = decodedString(videoDriver);
-            m_mltConsumer->set("video_driver", tmp);
-            delete[] tmp;
-        }
-
-        QString audioDriver = KdenliveSettings::audiodrivername();
-        if (!audioDriver.isEmpty()) {
-            tmp = decodedString(audioDriver);
-            m_mltConsumer->set("audio_driver", tmp);
-            delete[] tmp;
-        }
-
-        m_mltConsumer->set("audio_buffer", 1024);
-        m_mltConsumer->set("frequency", 48000);
-        m_externalwinid = extid;
-        m_winid = winid;
-        m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
-        Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "colour", "black");
-        m_mltProducer = producer;
-        if (m_blackClip) delete m_blackClip;
-        m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black");
-        m_blackClip->set("id", "black");
-        m_mltConsumer->connect(*m_mltProducer);
-        m_mltProducer->set_speed(0.0);
-
-        //m_mltConsumer->start();
-        //refresh();
-        //initSceneList();
-    }
-    /*m_osdInfo = new Mlt::Filter("data_show");
-    char *tmp = decodedString(m_osdProfile);
-    m_osdInfo->set("resource", tmp);
-    delete[] tmp;*/
-    //      Does it do anything usefull? I mean, RenderThread doesn't do anything useful at the moment
-    //      (except being cpu hungry :)
+    buildConsumer();
 
-    /*      if(!s_renderThread) {
-    s_renderThread = new RenderThread;
-    s_renderThread->start();
-    } */
+    m_externalwinid = extid;
+    m_winid = winid;
+    m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
+    Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "colour", "black");
+    m_mltProducer = producer;
+    if (m_blackClip) delete m_blackClip;
+    m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black");
+    m_blackClip->set("id", "black");
+    m_mltConsumer->connect(*m_mltProducer);
+    m_mltProducer->set_speed(0.0);
 }
 
 Render::~Render() {
@@ -154,32 +107,17 @@ void Render::closeMlt() {
 }
 
 
-
-int Render::resetProfile(QString profile) {
-
-    if (!m_mltConsumer) return 0;
-    if (m_isSplitView) slotSplitView(false);
-    if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
-    m_mltConsumer->purge();
-    delete m_mltConsumer;
-
-    m_mltConsumer = NULL;
-    QString scene = sceneList();
-    if (m_mltProducer) delete m_mltProducer;
-    m_mltProducer = NULL;
-    if (m_mltProfile) delete m_mltProfile;
-    m_mltProfile = NULL;
-
-    char *tmp = decodedString(profile);
+void Render::buildConsumer() {
+    char *tmp;
+    tmp = decodedString(KdenliveSettings::current_profile());
     m_mltProfile = new Mlt::Profile(tmp);
     delete[] tmp;
-    m_mltConsumer = new Mlt::Consumer(*m_mltProfile , "sdl_preview"); //consumer;
+    m_mltConsumer = new Mlt::Consumer(*m_mltProfile , "sdl_preview");
     m_mltConsumer->set("resize", 1);
     m_mltConsumer->set("window_id", m_winid);
     m_mltConsumer->set("terminate_on_pause", 1);
     m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
     m_mltConsumer->set("rescale", "nearest");
-
     QString audioDevice = KdenliveSettings::audiodevicename();
     if (!audioDevice.isEmpty()) {
         tmp = decodedString(audioDevice);
@@ -189,9 +127,15 @@ int Render::resetProfile(QString profile) {
 
     QString videoDriver = KdenliveSettings::videodrivername();
     if (!videoDriver.isEmpty()) {
-        tmp = decodedString(videoDriver);
-        m_mltConsumer->set("video_driver", tmp);
-        delete[] tmp;
+        if (videoDriver == "x11_noaccel") {
+            setenv("SDL_VIDEO_YUV_HWACCEL", "0", 1);
+            m_mltConsumer->set("video_driver", "x11");
+        } else {
+            unsetenv("SDL_VIDEO_YUV_HWACCEL");
+            tmp = decodedString(videoDriver);
+            m_mltConsumer->set("video_driver", tmp);
+            delete[] tmp;
+        }
     }
 
     QString audioDriver = KdenliveSettings::audiodrivername();
@@ -205,11 +149,26 @@ int Render::resetProfile(QString profile) {
     m_mltConsumer->set("progressive", 1);
     m_mltConsumer->set("audio_buffer", 1024);
     m_mltConsumer->set("frequency", 48000);
+}
+
+int Render::resetProfile() {
+    if (!m_mltConsumer) return 0;
+    if (m_isSplitView) slotSplitView(false);
+    if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
+    m_mltConsumer->purge();
+    delete m_mltConsumer;
+    m_mltConsumer = NULL;
+    QString scene = sceneList();
+    if (m_mltProducer) delete m_mltProducer;
+    m_mltProducer = NULL;
+    if (m_mltProfile) delete m_mltProfile;
+    m_mltProfile = NULL;
+    buildConsumer();
 
     kDebug() << "//RESET WITHSCENE: " << scene;
     setSceneList(scene);
 
-    tmp = decodedString(scene);
+    char *tmp = decodedString(scene);
     Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "westley-xml", tmp);
     delete[] tmp;
     m_mltProducer = producer;
@@ -226,7 +185,6 @@ int Render::resetProfile(QString profile) {
     //mlt_properties_set(properties, "profile", "hdv_1080_50i");
     //m_mltConsumer->set("profile", (char *) profile.toUtf8().data());
     //m_mltProfile = new Mlt::Profile((char*) profile.toUtf8().data());
-    kDebug() << " ++++++++++ RESET CONSUMER WITH PROFILE: " << profile << ", WIDTH: " << m_mltProfile->width();
 
     //apply_profile_properties( m_mltProfile, m_mltConsumer->get_consumer(), properties );
     //refresh();
index b0a1cc382a6c98924762620bcc90a146cc3f2fec..b2b57881ab05140e111bb9952815cde3c4fb2812 100644 (file)
@@ -140,7 +140,7 @@ Q_OBJECT public:
 
     /** Turn on or off on screen display */
     void refreshDisplay();
-    int resetProfile(QString profile);
+    int resetProfile();
     const double fps() const;
     const int renderWidth() const;
     const int renderHeight() const;
@@ -215,6 +215,7 @@ private:   // Private attributes & methods
     void mltCheckLength(bool reload = true);
     QMap<QString, QString> mltGetTransitionParamsFromXml(QDomElement xml);
     QMap<QString, Mlt::Producer *> m_slowmotionProducers;
+    void buildConsumer();
 
 private slots:  // Private slots
     /** refresh monitor display */