]> git.sesse.net Git - kdenlive/commitdiff
Start using mlt profiles
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 4 Mar 2008 10:38:16 +0000 (10:38 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 4 Mar 2008 10:38:16 +0000 (10:38 +0000)
svn path=/branches/KDE4/; revision=1997

13 files changed:
src/definitions.h
src/docclipbase.cpp
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/monitor.cpp
src/monitor.h
src/monitormanager.cpp
src/monitormanager.h
src/profilesdialog.cpp
src/profilesdialog.h
src/renderer.cpp
src/renderer.h

index 56733d6534d0e2af4b1a7e2f373fc2c750216fa4..ad87e9fc8f0d6db83960912642cd4f4892a5ce12 100644 (file)
 enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5};
 enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9};
 
-struct TrackViewClip {
-    int startTime;
-    int duration;
-    int cropTime;
-    QString producer;
+struct MltVideoProfile {
+    QString path;
+    QString description;
+    int frame_rate_num;
+    int frame_rate_den;
+    int width;
+    int height;
+    bool progressive;
+    int sample_aspect_num;
+    int sample_aspect_den;
+    int display_aspect_num;
+    int display_aspect_den;
 };
 
 #endif
index 47006dcfae1693a962818aa49d81707ba9132621..dc4ab3090a13700e0d68705af6bc8d5d4738c6c1 100644 (file)
@@ -67,7 +67,7 @@ DocClipBase & DocClipBase::operator=(const DocClipBase & clip) {
 }
 
 DocClipBase::~DocClipBase() {
-    //if (m_thumbProd) delete m_thumbProd;
+    if (m_thumbProd) delete m_thumbProd;
 }
 
 void DocClipBase::slotRequestAudioThumbs() {
index 72da064542b79dd9dcff56a9135798d75ebd37c4..35e50d319e7a2c278032ceb27ba8a83a9d25a34a 100644 (file)
@@ -28,7 +28,7 @@
 #include "kdenlivedoc.h"
 #include "docclipbase.h"
 
-KdenliveDoc::KdenliveDoc(const KUrl &url, double fps, int width, int height, QWidget *parent): QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL), m_commandStack(new KUndoStack()) {
+KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QWidget *parent): QObject(parent), m_render(NULL), m_url(url), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_projectName(NULL), m_commandStack(new KUndoStack()) {
     m_clipManager = new ClipManager(this);
     if (!url.isEmpty()) {
         QString tmpFile;
@@ -101,8 +101,8 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, double fps, int width, int height, QWi
         doc.appendChild(tractor);
 
     }
-    if (fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
-    else m_timecode.setFormat((int) fps);
+    if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
+    else m_timecode.setFormat((int) m_fps);
 }
 
 KdenliveDoc::~KdenliveDoc() {
@@ -114,6 +114,10 @@ ClipManager *KdenliveDoc::clipManager() {
     return m_clipManager;
 }
 
+QString KdenliveDoc::profilePath() {
+    return m_profile.path;
+}
+
 void KdenliveDoc::setThumbsProgress(KUrl url, int progress) {
     emit thumbsProgress(url, progress);
 }
index 4eb8f5eda76fc1fb3a198132241b1f584b21049e..78839441f31476406ead4ec2ba4712bfa9cfdb9c 100644 (file)
 #include "timecode.h"
 #include "renderer.h"
 #include "clipmanager.h"
+#include "definitions.h"
 
 class KdenliveDoc: public QObject {
 Q_OBJECT public:
 
-    KdenliveDoc(const KUrl &url, double fps, int width, int height, QWidget *parent = 0);
+    KdenliveDoc(const KUrl &url, MltVideoProfile profile, QWidget *parent = 0);
     ~KdenliveDoc();
     QString documentName();
     QDomNodeList producersList();
@@ -66,6 +67,7 @@ Q_OBJECT public:
     void deleteProjectClip(const uint clipId);
     /** Inform application of the audio thumbnails generation progress */
     void setThumbsProgress(KUrl url, int progress);
+    QString profilePath();
 
 private:
     KUrl m_url;
@@ -79,6 +81,7 @@ private:
     KUndoStack *m_commandStack;
     QDomDocument generateSceneList();
     ClipManager *m_clipManager;
+    MltVideoProfile m_profile;
 
 public slots:
 
index 5710622ef7312be31814a799cc4e7ecfa50b2e3d..322324e0e56c2e66293a490d0d2a42eb4f5d7fb4 100644 (file)
@@ -295,9 +295,11 @@ void MainWindow::readOptions() {
 }
 
 void MainWindow::newFile() {
-    KdenliveDoc *doc = new KdenliveDoc(KUrl(), 25, 720, 576);
+    MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
+    if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
+    KdenliveDoc *doc = new KdenliveDoc(KUrl(), prof);
     TrackView *trackView = new TrackView(doc);
-    m_timelineArea->addTab(trackView, i18n("Untitled") + " / " + ProfilesDialog::getProfileDescription(KdenliveSettings::default_profile()));
+    m_timelineArea->addTab(trackView, i18n("Untitled") + " / " + prof.description);
     if (m_timelineArea->count() == 1)
         connectDocument(trackView, doc);
     else m_timelineArea->setTabBarHidden(false);
@@ -342,9 +344,12 @@ void MainWindow::openFile() { //changed
 }
 
 void MainWindow::openFile(const KUrl &url) { //new
-    KdenliveDoc *doc = new KdenliveDoc(url, 25, 720, 576);
+    //TODO: get video profile from url before opening it
+    MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
+    if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
+    KdenliveDoc *doc = new KdenliveDoc(url, prof);
     TrackView *trackView = new TrackView(doc);
-    m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName()));
+    m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName() + " / " + prof.description));
     m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
     if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
     //connectDocument(trackView, doc);
@@ -452,6 +457,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
 
     m_projectList->setDocument(doc);
     m_monitorManager->setTimecode(doc->timecode());
+    m_monitorManager->resetProfiles(doc->profilePath());
     doc->setRenderer(m_projectMonitor->render);
     //m_undoView->setStack(0);
     m_commandStack = doc->commandStack();
index 7a888242553af9aee4bf35ee0815b2a327f30ffc..3d78f08bb4679e086b902e7a75f31a653dc82753 100644 (file)
@@ -220,6 +220,10 @@ void Monitor::slotOpenFile(const QString &file) {
     render->setSceneList(doc, 0);
 }
 
+void Monitor::resetProfile(QString prof) {
+    if (render == NULL) return;
+    render->resetProfile(prof);
+}
 
 
 #include "monitor.moc"
index 4e4f4c100b047a9244119d9df33fb98cc0d8ef99..bea893e05df5cf73ea25d50c7e08ed64ed3c858b 100644 (file)
@@ -36,6 +36,8 @@ class Monitor : public QWidget {
 public:
     Monitor(QString name, MonitorManager *manager, QWidget *parent = 0);
     Render *render;
+    void resetProfile(QString prof);
+
     virtual void resizeEvent(QResizeEvent * event);
 protected:
     virtual void mousePressEvent(QMouseEvent * event);
index 0d6ff685e0f8159cace4296e5d691cd93532781e..28e5825ca1f6df25bb13e2c0a64c9191a921eead 100644 (file)
@@ -80,4 +80,9 @@ void MonitorManager::slotPlay() {
     else m_projectMonitor->slotPlay();
 }
 
+void MonitorManager::resetProfiles(QString prof) {
+    m_clipMonitor->resetProfile(prof);
+    m_projectMonitor->resetProfile(prof);
+}
+
 #include "monitormanager.moc"
index 7de762067d6defff04e93f600f02183d843de707..6466002a2d1519811c5eda67d86522e3b39c4f08 100644 (file)
@@ -34,6 +34,7 @@ public:
     void initMonitors(Monitor *clipMonitor, Monitor *projectMonitor);
     Timecode timecode();
     void setTimecode(Timecode tc);
+    void resetProfiles(QString prof);
 
 public slots:
     void activateMonitor(QString name = QString::null);
index 497bfacfad766b753f636ce1286e5b612a6ef319..0f338a0de2560d0f9c307445611dde5c17e465ed 100644 (file)
@@ -49,6 +49,46 @@ ProfilesDialog::ProfilesDialog(QWidget * parent): QDialog(parent), m_isCustomPro
     connect(m_view.profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
 }
 
+// static
+MltVideoProfile ProfilesDialog::getVideoProfile(QString name) {
+    MltVideoProfile result;
+    QStringList profilesNames;
+    QStringList profilesFiles;
+    QStringList profilesFilter;
+    profilesFilter << "*";
+    QString path;
+
+    // List the Mlt profiles
+    profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
+    if (profilesFiles.contains(name)) path = KdenliveSettings::mltpath() + "/" + name;
+
+    if (path.isEmpty()) {
+        // List custom profiles
+        QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
+        for (int i = 0; i < customProfiles.size(); ++i) {
+            profilesFiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
+            if (profilesFiles.contains(name)) {
+                path = customProfiles.at(i) + "/" + name;
+                break;
+            }
+        }
+    }
+
+    if (path.isEmpty()) return result;
+    KConfig confFile(path);
+    result.path = path;
+    result.description = confFile.entryMap().value("description");
+    result.frame_rate_num = confFile.entryMap().value("frame_rate_num").toInt();
+    result.frame_rate_den = confFile.entryMap().value("frame_rate_den").toInt();
+    result.width = confFile.entryMap().value("width").toInt();
+    result.height = confFile.entryMap().value("height").toInt();
+    result.progressive = confFile.entryMap().value("progressive").toInt();
+    result.sample_aspect_num = confFile.entryMap().value("sample_aspect_num").toInt();
+    result.sample_aspect_den = confFile.entryMap().value("sample_aspect_den").toInt();
+    result.display_aspect_num = confFile.entryMap().value("display_aspect_num").toInt();
+    result.display_aspect_den = confFile.entryMap().value("display_aspect_den").toInt();
+    return result;
+}
 
 // static
 QString ProfilesDialog::getProfileDescription(QString name) {
index a4f4d5744a33d444e295afdac0bffc95eba741f5..0046104e01fb628e91c0adbcf5813a7295809f96 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <QDialog>
 
+#include "definitions.h"
 #include "ui_profiledialog_ui.h"
 
 class ProfilesDialog : public QDialog {
@@ -35,6 +36,7 @@ public:
     static QString getProfileDescription(QString name);
     static QMap< QString, QString > getSettingsForProfile(const QString profileName);
     static QMap< QString, QString > getSettingsFromFile(const QString path);
+    static MltVideoProfile getVideoProfile(QString name);
 
 private slots:
     void slotUpdateDisplay();
index b890f0eb52a9e100808a2dd9082f6c34bb0b5dec..597235d2cc3991054736cfd654e9722d0701ee0e 100644 (file)
@@ -114,14 +114,16 @@ void Render::closeMlt() {
 
 
 
-int Render::resetRendererProfile(char * profile) {
+int Render::resetProfile(QString profile) {
     if (!m_mltConsumer) return 0;
     if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
     m_mltConsumer->set("refresh", 0);
-    //m_mltConsumer->set("profile", profile);
+    //TODO: we should also rebuild filters and delete existing m_mltProfile
+    m_mltProfile = new Mlt::Profile((char*) qstrdup(profile.toUtf8()));
     kDebug() << " + + RESET CONSUMER WITH PROFILE: " << profile;
     mlt_properties properties = MLT_CONSUMER_PROPERTIES(m_mltConsumer->get_consumer());
-//    apply_profile_properties( m_profile, m_mltConsumer->get_consumer(), properties );
+    mlt_properties_set_data(properties, "profile", m_mltProfile->get_profile(), 0, 0, NULL);
+    //apply_profile_properties( m_mltProfile, m_mltConsumer->get_consumer(), properties );
     refresh();
     return 1;
 }
index fadc295fae5060f6e78d25749e1b3e546b577683..082dda9e91fd0ff34efa6c2725a6e3a7d9fc5275 100644 (file)
@@ -145,7 +145,7 @@ Q_OBJECT public:
     void refreshDisplay();
     /** returns the current scenelist */
     QDomDocument sceneList() const;
-    int resetRendererProfile(char * profile);
+    int resetProfile(QString profile);
     const double fps() const;
 
     /** Playlist manipulation */