[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdenlive] src: Rewrote DVD creation, should now support correctly 4:3 and 16:9 menus,
From:       Jean-Baptiste Mardelle <jb () kdenlive ! org>
Date:       2012-10-31 22:39:09
Message-ID: 20121031223909.0CCEBA60C4 () git ! kde ! org
[Download RAW message or body]

Git commit 9ad93a6f43ea95f4f43acd9bdd226ec2253621e1 by Jean-Baptiste Mardelle.
Committed on 31/10/2012 at 23:38.
Pushed by mardelle into branch 'master'.

Rewrote DVD creation, should now support correctly 4:3 and 16:9 menus, letterbox is \
still untested (playing 16:9 on 4:3 monitor)

M  +135  -35   src/dvdwizard.cpp
M  +2    -1    src/dvdwizard.h
M  +7    -10   src/dvdwizardchapters.cpp
M  +5    -4    src/dvdwizardchapters.h
M  +50   -30   src/dvdwizardmenu.cpp
M  +6    -6    src/dvdwizardmenu.h
M  +45   -14   src/dvdwizardvob.cpp
M  +6    -3    src/dvdwizardvob.h
M  +3    -3    src/mainwindow.cpp
M  +1    -1    src/mainwindow.h
M  +3    -1    src/projectlist.cpp
M  +1    -1    src/renderwidget.cpp
M  +1    -1    src/renderwidget.h

http://commits.kde.org/kdenlive/9ad93a6f43ea95f4f43acd9bdd226ec2253621e1

diff --git a/src/dvdwizard.cpp b/src/dvdwizard.cpp
index 0a411e6..028b18f 100644
--- a/src/dvdwizard.cpp
+++ b/src/dvdwizard.cpp
@@ -19,6 +19,7 @@
 
 
 #include "dvdwizard.h"
+#include "dvdwizardvob.h"
 #include "kdenlivesettings.h"
 #include "profilesdialog.h"
 #include "timecode.h"
@@ -39,7 +40,7 @@
 #include <QGridLayout>
 
 
-DvdWizard::DvdWizard(const QString &url, const QString &profile, QWidget *parent) :
+DvdWizard::DvdWizard(const QString &url, QWidget *parent) :
         QWizard(parent),
         m_dvdauthor(NULL),
         m_mkiso(NULL),
@@ -47,19 +48,19 @@ DvdWizard::DvdWizard(const QString &url, const QString &profile, \
QWidget *parent  {
     setWindowTitle(i18n("DVD Wizard"));
     //setPixmap(QWizard::WatermarkPixmap, QPixmap(KStandardDirs::locate("appdata", \
                "banner.png")));
-    m_pageVob = new DvdWizardVob(profile, this);
+    m_pageVob = new DvdWizardVob(this);
     m_pageVob->setTitle(i18n("Select Files For Your DVD"));
     addPage(m_pageVob);
     if (!url.isEmpty()) m_pageVob->setUrl(url);
 
 
-    m_pageChapters = new DvdWizardChapters(m_pageVob->isPal(), this);
+    m_pageChapters = new DvdWizardChapters(m_pageVob->dvdFormat(), this);
     m_pageChapters->setTitle(i18n("DVD Chapters"));
     addPage(m_pageChapters);
 
 
 
-    m_pageMenu = new DvdWizardMenu(profile, this);
+    m_pageMenu = new DvdWizardMenu(m_pageVob->dvdFormat(), this);
     m_pageMenu->setTitle(i18n("Create DVD Menu"));
     addPage(m_pageMenu);
 
@@ -127,6 +128,7 @@ DvdWizard::~DvdWizard()
     m_authorFile.remove();
     m_menuFile.remove();
     m_menuVobFile.remove();
+    m_letterboxMovie.remove();
     blockSignals(true);
     delete m_burnMenu;
     if (m_dvdauthor) {
@@ -150,12 +152,12 @@ void DvdWizard::slotPageChanged(int page)
         m_pageChapters->stopMonitor();
         m_pageVob->updateChapters(m_pageChapters->chaptersData());
     } else if (page == 1) {
-        m_pageChapters->setVobFiles(m_pageVob->isPal(), m_pageVob->isWide(), \
m_pageVob->selectedUrls(), m_pageVob->durations(), m_pageVob->chapters()); +        \
m_pageChapters->setVobFiles(m_pageVob->dvdFormat(), m_pageVob->selectedUrls(), \
m_pageVob->durations(), m_pageVob->chapters());  } else if (page == 2) {
         m_pageChapters->stopMonitor();
         m_pageVob->updateChapters(m_pageChapters->chaptersData());
         m_pageMenu->setTargets(m_pageChapters->selectedTitles(), \
                m_pageChapters->selectedTargets());
-        m_pageMenu->changeProfile(m_pageVob->isPal());
+        m_pageMenu->changeProfile(m_pageVob->dvdFormat());
     }
 }
 
@@ -201,6 +203,12 @@ void DvdWizard::generateDvd()
     //temp6.setAutoRemove(false);
     temp6.open();
 
+    m_letterboxMovie.close();
+    m_letterboxMovie.setSuffix(".mpg");
+    m_letterboxMovie.setAutoRemove(false);
+    m_letterboxMovie.open();
+    
+
     m_menuFile.close();
     m_menuFile.setSuffix(".xml");
     m_menuFile.setAutoRemove(false);
@@ -225,6 +233,7 @@ void DvdWizard::generateDvd()
     m_status.error_log->clear();
     // initialize html content
     m_status.error_log->setText("<html></html>");
+    QString menuMovieUrl;
 
     if (m_pageMenu->createMenu()) {
         m_pageMenu->createButtonImages(temp1.fileName(), temp2.fileName(), \
temp3.fileName()); @@ -242,9 +251,7 @@ void DvdWizard::generateDvd()
             qApp->processEvents();
 
             QStringList args;
-            args.append("-profile");
-            if (m_pageMenu->isPalMenu()) args.append("dv_pal");
-            else args.append("dv_ntsc");
+            args << "-profile" << m_pageVob->dvdProfile();
             args.append(temp4.fileName());
             args.append("in=0");
             args.append("out=100");
@@ -282,9 +289,6 @@ void DvdWizard::generateDvd()
             vobitem->setIcon(KIcon("system-run"));
             qApp->processEvents();
 
-	    QString std;
-	    if (m_pageMenu->isPalMenu()) std = "dv_pal";
-	    else std = "dv_ntsc";
 	    int menuLength = m_pageMenu->menuMovieLength();
 	    if (menuLength == -1) {
 		// menu movie is invalid
@@ -293,10 +297,9 @@ void DvdWizard::generateDvd()
                 m_status.button_abort->setEnabled(false);
                 return;
 	    }
-
             QStringList args;
             args.append("-profile");
-            args.append(std);
+            args.append(m_pageVob->dvdProfile());
             args.append(m_pageMenu->menuMoviePath());
 	    args << "-track" << temp4.fileName();
 	    args << "out=" + QString::number(menuLength);
@@ -386,21 +389,21 @@ void DvdWizard::generateDvd()
         }
         data.close();
 
-        kDebug() << " SPUMUX DATA: " << doc.toString();
+        //kDebug() << " SPUMUX DATA: " << doc.toString();
 
         QStringList args;
-        args.append(m_menuFile.fileName());
-        kDebug() << "SPM ARGS: " << args << temp5.fileName() << \
m_menuVobFile.fileName(); +	args << "-s" << "0" << m_menuFile.fileName();
+        //kDebug() << "SPM ARGS: " << args << temp5.fileName() << \
m_menuVobFile.fileName();  
         QProcess spumux;
 
 #if QT_VERSION >= 0x040600
         QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
-        env.insert("VIDEO_FORMAT", m_pageVob->isPal() ? "PAL" : "NTSC");
+        env.insert("VIDEO_FORMAT", m_pageVob->dvdFormat() == PAL || \
m_pageVob->dvdFormat() == PAL_WIDE ? "PAL" : "NTSC");  \
spumux.setProcessEnvironment(env);  #else
         QStringList env = QProcess::systemEnvironment();
-        env << QString("VIDEO_FORMAT=") + QString(m_pageVob->isPal() ? "PAL" : \
"NTSC"); +        env << QString("VIDEO_FORMAT=") + QString(m_pageVob->dvdFormat() == \
PAL || m_pageVob->dvdFormat() == PAL_WIDE ? "PAL" : "NTSC");  \
spumux.setEnvironment(env);  #endif
     
@@ -436,9 +439,87 @@ void DvdWizard::generateDvd()
             m_status.button_start->setEnabled(true);
             return;
         }
+        if (m_pageVob->dvdFormat() == PAL_WIDE || m_pageVob->dvdFormat() == \
NTSC_WIDE) { +	    // Second step processing for 16:9 DVD, add letterbox stream
+	    m_pageMenu->createButtonImages(temp1.fileName(), temp2.fileName(), \
temp3.fileName(), true); +	    buttons = m_pageMenu->buttonsInfo(true);
+	    // Remove previous button info
+	    while(!spu.firstChild().isNull()) {
+		spu.removeChild(spu.firstChild());
+	    }
+
+	    max = buttons.count() - 1;
+	    i = 0;
+	    QMapIterator<QString, QRect> it2(buttons);
+	    while (it2.hasNext()) {
+		it2.next();
+		QDomElement but = doc.createElement("button");
+		but.setAttribute("name", 'b' + QString::number(i));
+		if (i < max) but.setAttribute("down", 'b' + QString::number(i + 1));
+		else but.setAttribute("down", "b0");
+		if (i > 0) but.setAttribute("up", 'b' + QString::number(i - 1));
+		else but.setAttribute("up", 'b' + QString::number(max));
+		QRect r = it2.value();
+		// We need to make sure that the y coordinate is a multiple of 2, otherwise button \
may not be displayed +		buttonsTarget.append(it2.key());
+		int y0 = r.y() - 2;
+		if (y0 % 2 == 1) y0++;
+		int y1 = r.bottom() + 2;
+		if (y1 % 2 == 1) y1++;
+		but.setAttribute("x0", QString::number(r.x()));
+		but.setAttribute("y0", QString::number(y0));
+		but.setAttribute("x1", QString::number(r.right()));
+		but.setAttribute("y1", QString::number(y1));
+		spu.appendChild(but);
+		i++;
+	    }
+
+	    //kDebug() << " SPUMUX DATA: " << doc.toString();
+	    
+	    if (data.open(QFile::WriteOnly)) {
+		data.write(doc.toString().toUtf8());
+	    }
+	    data.close();
+	    spumux.setStandardInputFile(m_menuVobFile.fileName());
+	    spumux.setStandardOutputFile(m_letterboxMovie.fileName());
+	    args.clear();
+	    args << "-s" << "1" << m_menuFile.fileName();
+	    spumux.start("spumux", args);
+	    //kDebug() << "SPM ARGS LETTERBOX: " << args << temp5.fileName() << \
m_letterboxMovie.fileName(); +	    if (spumux.waitForFinished()) {
+		m_status.error_log->append(spumux.readAllStandardError());
+		if (spumux.exitStatus() == QProcess::CrashExit) {
+		    //TODO: inform user via messagewidget after string freeze
+		    QByteArray result = spumux.readAllStandardError();
+		    spuitem->setIcon(KIcon("dialog-close"));
+		    m_status.error_log->append(result);
+		    m_status.error_box->setHidden(false);
+		    m_status.error_box->setTabBarHidden(false);
+		    m_status.menu_file->setPlainText(m_menuFile.readAll());
+		    m_status.dvd_file->setPlainText(m_authorFile.readAll());
+		    m_status.button_start->setEnabled(true);
+		    kDebug() << "/// RENDERING SPUMUX MENU crashed";
+		    return;
+		}
+	    } else {
+		kDebug() << "/// RENDERING SPUMUX MENU timed out";
+		errorMessage(i18n("Rendering job timed out"));
+		spuitem->setIcon(KIcon("dialog-close"));
+		m_status.error_log->append("<a name=\"result\" /><br /><strong>" + i18n("Menu job \
timed out")); +		m_status.error_log->scrollToAnchor("result");
+		m_status.error_box->setHidden(false);
+		m_status.error_box->setTabBarHidden(false);
+		m_status.menu_file->setPlainText(m_menuFile.readAll());
+		m_status.dvd_file->setPlainText(m_authorFile.readAll());
+		m_status.button_start->setEnabled(true);
+		return;
+	    }
+	    menuMovieUrl = m_letterboxMovie.fileName();
+	}
+	else menuMovieUrl = m_menuVobFile.fileName();
 
         spuitem->setIcon(KIcon("dialog-ok"));
-        kDebug() << "/// DONE: " << m_menuVobFile.fileName();
+        kDebug() << "/// DONE: " << menuMovieUrl;
     }
 
     // create dvdauthor xml
@@ -478,6 +559,19 @@ void DvdWizard::generateDvd()
         // DVD main menu
         QDomElement menus = dvddoc.createElement("menus");
         titleset.appendChild(menus);
+	if (m_pageVob->dvdFormat() == PAL_WIDE || m_pageVob->dvdFormat() == NTSC_WIDE) {
+	    // Add letterbox stream info
+	    QDomElement subpict = dvddoc.createElement("subpicture");
+	    QDomElement stream = dvddoc.createElement("stream");
+	    stream.setAttribute("id", "0");
+	    stream.setAttribute("mode", "widescreen");
+	    subpict.appendChild(stream);
+	    QDomElement stream2 = dvddoc.createElement("stream");
+	    stream2.setAttribute("id", "1");
+	    stream2.setAttribute("mode", "letterbox");
+	    subpict.appendChild(stream2);
+	    menus.appendChild(subpict);
+	}
         QDomElement pgc = dvddoc.createElement("pgc");
         pgc.setAttribute("entry", "root");
         menus.appendChild(pgc);
@@ -486,7 +580,7 @@ void DvdWizard::generateDvd()
         QDomText nametext = dvddoc.createTextNode("{g1 = 0;}");
         pre.appendChild(nametext);
 	QDomElement menuvob = dvddoc.createElement("vob");
-        menuvob.setAttribute("file", m_menuVobFile.fileName());
+        menuvob.setAttribute("file", menuMovieUrl);
         pgc.appendChild(menuvob);
         for (int i = 0; i < buttons.count(); i++) {
             QDomElement button = dvddoc.createElement("button");
@@ -509,11 +603,22 @@ void DvdWizard::generateDvd()
     titleset.appendChild(titles);
     QDomElement video = dvddoc.createElement("video");
     titles.appendChild(video);
-    if (m_pageVob->isPal()) video.setAttribute("format", "pal");
-    else video.setAttribute("format", "ntsc");
-
-    if (m_pageVob->isWide()) video.setAttribute("aspect", "16:9");
-    else video.setAttribute("aspect", "4:3");
+    switch (m_pageVob->dvdFormat()) {
+	case PAL_WIDE:
+	    video.setAttribute("format", "pal");
+	    video.setAttribute("aspect", "16:9");
+	    break;
+	case NTSC_WIDE:
+	    video.setAttribute("format", "ntsc");
+	    video.setAttribute("aspect", "16:9");
+	    break;
+	case NTSC:
+	    video.setAttribute("format", "ntsc");
+	    break;
+	default:
+	    video.setAttribute("format", "pal");
+	    break;
+    }
 
     QStringList voburls = m_pageVob->selectedUrls();
 
@@ -570,11 +675,11 @@ void DvdWizard::generateDvd()
     // Set VIDEO_FORMAT variable (required by dvdauthor 0.7)
 #if QT_VERSION >= 0x040600
     QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
-    env.insert("VIDEO_FORMAT", m_pageVob->isPal() ? "PAL" : "NTSC"); 
+    env.insert("VIDEO_FORMAT", m_pageVob->dvdFormat() == PAL || \
m_pageVob->dvdFormat() == PAL_WIDE ? "PAL" : "NTSC");   \
m_dvdauthor->setProcessEnvironment(env);  #else
     QStringList env = QProcess::systemEnvironment();
-    env << QString("VIDEO_FORMAT=") + QString(m_pageVob->isPal() ? "PAL" : "NTSC");
+    env << QString("VIDEO_FORMAT=") + QString(m_pageVob->dvdFormat() == PAL || \
m_pageVob->dvdFormat() == PAL_WIDE ? "PAL" : "NTSC");  \
m_dvdauthor->setEnvironment(env);  #endif
     connect(m_dvdauthor, SIGNAL(finished(int , QProcess::ExitStatus)), this, \
SLOT(slotRenderFinished(int, QProcess::ExitStatus))); @@ -819,16 +924,11 @@ void \
                DvdWizard::slotSave()
     KUrl url = KFileDialog::getSaveUrl(KUrl("kfiledialog:///projectfolder"), \
"*.kdvd", this, i18n("Save DVD Project"));  if (url.isEmpty()) return;
 
-    if (currentId() == 0) m_pageChapters->setVobFiles(m_pageVob->isPal(), \
m_pageVob->isWide(), m_pageVob->selectedUrls(), m_pageVob->durations(), \
m_pageVob->chapters()); +    if (currentId() == 0) \
m_pageChapters->setVobFiles(m_pageVob->dvdFormat(), m_pageVob->selectedUrls(), \
m_pageVob->durations(), m_pageVob->chapters());  
     QDomDocument doc;
     QDomElement dvdproject = doc.createElement("dvdproject");
-    QString profile;
-    if (m_pageVob->isPal()) profile = "dv_pal";
-    else profile = "dv_ntsc";
-    if (m_pageVob->isWide()) profile.append("_wide");
-    dvdproject.setAttribute("profile", profile);
-
+    dvdproject.setAttribute("profile", m_pageVob->dvdProfile());
     dvdproject.setAttribute("tmp_folder", m_status.tmp_folder->url().path());
     dvdproject.setAttribute("iso_image", m_status.iso_image->url().path());
 
diff --git a/src/dvdwizard.h b/src/dvdwizard.h
index 4f045be..cff0e0e 100644
--- a/src/dvdwizard.h
+++ b/src/dvdwizard.h
@@ -41,7 +41,7 @@ class DvdWizard : public QWizard
 {
     Q_OBJECT
 public:
-    explicit DvdWizard(const QString &url = QString(), const QString &profile = \
"dv_pal", QWidget * parent = 0); +    explicit DvdWizard(const QString &url = \
QString(), QWidget * parent = 0);  virtual ~DvdWizard();
 
 private:
@@ -57,6 +57,7 @@ private:
     KTemporaryFile m_authorFile;
     KTemporaryFile m_menuFile;
     KTemporaryFile m_menuVobFile;
+    KTemporaryFile m_letterboxMovie;
     QProcess *m_dvdauthor;
     QProcess *m_mkiso;
     QString m_creationLog;
diff --git a/src/dvdwizardchapters.cpp b/src/dvdwizardchapters.cpp
index 52464b3..7835c43 100644
--- a/src/dvdwizardchapters.cpp
+++ b/src/dvdwizardchapters.cpp
@@ -23,9 +23,9 @@
 
 #include <QFile>
 
-DvdWizardChapters::DvdWizardChapters(bool isPal, QWidget *parent) :
+DvdWizardChapters::DvdWizardChapters(DVDFORMAT format, QWidget *parent) :
         QWizardPage(parent),
-        m_isPal(isPal),
+        m_format(format),
         m_monitor(NULL)
 
 {
@@ -37,7 +37,7 @@ DvdWizardChapters::DvdWizardChapters(bool isPal, QWidget *parent) :
 
     // Build monitor for chapters
 
-    if (m_isPal) m_tc.setFormat(25);
+    if (m_format == PAL || m_format == PAL_WIDE) m_tc.setFormat(25);
     else m_tc.setFormat(30000.0 / 1001);
 
     m_manager = new MonitorManager(this);
@@ -134,18 +134,15 @@ void DvdWizardChapters::slotGoToChapter()
     if (m_view.chapters_list->currentItem()) \
m_monitor->setTimePos(m_tc.reformatSeparators(m_view.chapters_list->currentItem()->text() \
+ ":00"));  }
 
-void DvdWizardChapters::setVobFiles(bool isPal, bool isWide, const QStringList \
&movies, const QStringList &durations, const QStringList &chapters) +void \
DvdWizardChapters::setVobFiles(DVDFORMAT format, const QStringList &movies, const \
QStringList &durations, const QStringList &chapters)  {
-    m_isPal = isPal;
-    QString profile;
-    if (m_isPal) {
+    m_format = format;
+    QString profile = DvdWizardVob::getDvdProfile(format);
+    if (m_format == PAL || m_format == PAL_WIDE) {
         m_tc.setFormat(25);
-        profile = "dv_pal";
     } else {
         m_tc.setFormat(30000.0 / 1001);
-        profile = "dv_ntsc";
     }
-    if (isWide) profile.append("_wide");
     m_manager->resetProfiles(m_tc);
     if (m_monitor == NULL) {
         m_monitor = new Monitor(Kdenlive::dvdMonitor, m_manager, profile, this);
diff --git a/src/dvdwizardchapters.h b/src/dvdwizardchapters.h
index 515d942..d8afa4e 100644
--- a/src/dvdwizardchapters.h
+++ b/src/dvdwizardchapters.h
@@ -27,6 +27,7 @@
 
 #include "ui_dvdwizardchapters_ui.h"
 #include "monitor.h"
+#include "dvdwizardvob.h"
 #include "monitormanager.h"
 
 class DvdWizardChapters : public QWizardPage
@@ -34,12 +35,12 @@ class DvdWizardChapters : public QWizardPage
     Q_OBJECT
 
 public:
-    explicit DvdWizardChapters(bool isPal, QWidget * parent = 0);
+    explicit DvdWizardChapters(DVDFORMAT format, QWidget * parent = 0);
     virtual ~DvdWizardChapters();
     virtual bool isComplete() const;
-    void changeProfile(bool isPal);
+    void changeProfile(DVDFORMAT format);
     void setPal(bool isPal);
-    void setVobFiles(bool isPal, bool isWide, const QStringList &movies, const \
QStringList &durations, const QStringList &chapters); +    void setVobFiles(DVDFORMAT \
format, const QStringList &movies, const QStringList &durations, const QStringList \
&chapters);  QStringList selectedTitles() const;
     QStringList selectedTargets() const;
     QStringList chapters(int ix) const;
@@ -49,7 +50,7 @@ public:
 
 private:
     Ui::DvdWizardChapters_UI m_view;
-    bool m_isPal;
+    DVDFORMAT m_format;
     MonitorManager *m_manager;
     Monitor *m_monitor;
     Timecode m_tc;
diff --git a/src/dvdwizardmenu.cpp b/src/dvdwizardmenu.cpp
index fb162c8..ca8af2a 100644
--- a/src/dvdwizardmenu.cpp
+++ b/src/dvdwizardmenu.cpp
@@ -30,7 +30,7 @@
 
 #include "kthumb.h"
 
-DvdWizardMenu::DvdWizardMenu(const QString &profile, QWidget *parent) :
+DvdWizardMenu::DvdWizardMenu(DVDFORMAT format, QWidget *parent) :
         QWizardPage(parent),
         m_color(NULL),
         m_safeRect(NULL),
@@ -61,9 +61,7 @@ DvdWizardMenu::DvdWizardMenu(const QString &profile, QWidget \
*parent) :  m_view.add_button->setToolTip(i18n("Add new button"));
     m_view.delete_button->setToolTip(i18n("Delete current button"));
 
-    if (profile == "dv_ntsc" || profile == "dv_ntsc_wide") {
-        changeProfile(false);
-    } else changeProfile(true);
+    changeProfile(format);
 
 
     // Create color background
@@ -349,17 +347,29 @@ void DvdWizardMenu::deleteButton()
     }
 }
 
-void DvdWizardMenu::changeProfile(bool isPal)
-{
-    m_isPal = isPal;
-    if (isPal == false) {
-	m_finalSize = QSize(720, 480);
-        m_width = 640;
-        m_height = 480;
-    } else {
-	m_finalSize = QSize(720, 576);
-        m_width = 768;
-        m_height = 576;
+void DvdWizardMenu::changeProfile(DVDFORMAT format)
+{
+    m_format = format;
+    switch (m_format) {
+	case PAL_WIDE:
+	    m_finalSize = QSize(720, 576);
+	    m_width = 1024;
+	    m_height = 576;
+	    break;
+	case NTSC_WIDE:
+	    m_finalSize = QSize(720, 480);
+	    m_width = 853;
+	    m_height = 480;
+	    break;
+	case NTSC:
+	    m_finalSize = QSize(720, 480);
+	    m_width = 640;
+	    m_height = 480;
+	    break;
+	default:
+	    m_finalSize = QSize(720, 576);
+	    m_width = 768;
+	    m_height = 576;
     }
     updatePreview();
 }
@@ -443,9 +453,8 @@ void DvdWizardMenu::buildImage()
     } else if (m_view.background_list->currentIndex() == 2) {
         // video background
         m_movieLength = -1;
-        QString standard = "dv_pal";
-        if (!m_isPal) standard = "dv_ntsc";
-	Mlt::Profile profile(standard.toUtf8().constData());
+	Mlt::Profile profile;
+	profile.set_explicit(false);
 	Mlt::Producer *producer = new Mlt::Producer(profile, \
m_view.background_image->url().path().toUtf8().data());  if (producer && \
                producer->is_valid()) {
 	    pix = QPixmap::fromImage(KThumb::getFrame(producer, 0, m_finalSize.width(), \
m_width, m_height)); @@ -558,10 +567,19 @@ void DvdWizardMenu::updateColor(QColor c)
 }
 
 
-void DvdWizardMenu::createButtonImages(const QString &img1, const QString &img2, \
const QString &img3) +void DvdWizardMenu::createButtonImages(const QString &img1, \
const QString &img2, const QString &img3, bool letterbox)  {
     if (m_view.create_menu->isChecked()) {
         m_scene->clearSelection();
+	QRectF source(0, 0, m_width, m_height);
+	QRectF target;
+	if (!letterbox) target = QRectF(0, 0, m_finalSize.width(), m_finalSize.height());
+	else {
+	    // Scale the button images to fit a letterbox image
+	    double factor = (double) m_width / m_finalSize.width();
+	    int letterboxHeight = m_height / factor;
+	    target = QRectF(0, (m_finalSize.height() - letterboxHeight) / 2, \
m_finalSize.width(), letterboxHeight); +	}
         if (m_safeRect->scene() != 0) m_scene->removeItem(m_safeRect);
         if (m_color->scene() != 0) m_scene->removeItem(m_color);
         if (m_background->scene() != 0) m_scene->removeItem(m_background);
@@ -578,7 +596,7 @@ void DvdWizardMenu::createButtonImages(const QString &img1, const \
QString &img2,  QPainter p(&img);
         //p.setRenderHints(QPainter::Antialiasing, false);
         //p.setRenderHints(QPainter::TextAntialiasing, false);
-        m_scene->render(&p, QRectF(0, 0, m_finalSize.width(), m_finalSize.height()), \
QRectF(0, 0, m_width, m_height), Qt::IgnoreAspectRatio); +        m_scene->render(&p, \
target, source, Qt::IgnoreAspectRatio);  p.end();
 #if QT_VERSION >= 0x040800
 #elif QT_VERSION >= 0x040600 
@@ -598,7 +616,7 @@ void DvdWizardMenu::createButtonImages(const QString &img1, const \
QString &img2,  p.begin(&img);
         //p.setRenderHints(QPainter::Antialiasing, false);
         //p.setRenderHints(QPainter::TextAntialiasing, false);
-	m_scene->render(&p, QRectF(0, 0, m_finalSize.width(), m_finalSize.height()), \
QRectF(0, 0, m_width, m_height), Qt::IgnoreAspectRatio); +	m_scene->render(&p, \
target, source, Qt::IgnoreAspectRatio);  p.end();
 #if QT_VERSION >= 0x040800
 #elif QT_VERSION >= 0x040600
@@ -618,7 +636,7 @@ void DvdWizardMenu::createButtonImages(const QString &img1, const \
QString &img2,  p.begin(&img);
         //p.setRenderHints(QPainter::Antialiasing, false);
         //p.setRenderHints(QPainter::TextAntialiasing, false);
-        m_scene->render(&p, QRectF(0, 0, m_finalSize.width(), m_finalSize.height()), \
QRectF(0, 0, m_width, m_height), Qt::IgnoreAspectRatio); +        m_scene->render(&p, \
target, source, Qt::IgnoreAspectRatio);  p.end();
 #if QT_VERSION >= 0x040800
 #elif QT_VERSION >= 0x040600
@@ -718,16 +736,23 @@ int DvdWizardMenu::menuMovieLength() const
 }
 
 
-QMap <QString, QRect> DvdWizardMenu::buttonsInfo()
+QMap <QString, QRect> DvdWizardMenu::buttonsInfo(bool letterbox)
 {
     QMap <QString, QRect> info;
     QList<QGraphicsItem *> list = m_scene->items();
-    double ratio = (double) m_finalSize.width() / m_width;
+    double ratiox = (double) m_finalSize.width() / m_width;
+    double ratioy = 1;
+    int offset = 0;
+    if (letterbox) {
+	int letterboxHeight = m_height * ratiox;
+	ratioy = (double) letterboxHeight / m_finalSize.height();
+	offset = (m_finalSize.height() - letterboxHeight) / 2;
+    }
     for (int i = 0; i < list.count(); i++) {
         if (list.at(i)->type() == QGraphicsItem::UserType + 1) {
             DvdButton *button = static_cast < DvdButton* >(list.at(i));
 	    QRectF r = button->sceneBoundingRect();
-	    QRect adjustedRect(r.x() * ratio, r.y(), r.width() * ratio, r.height());
+	    QRect adjustedRect(r.x() * ratiox, offset + r.y() * ratioy, r.width() * ratiox, \
r.height() * ratioy);  // Make sure y1 is not odd (requested by spumux)
             if (adjustedRect.height() % 2 == 1) \
                adjustedRect.setHeight(adjustedRect.height() + 1);
             if (adjustedRect.y() % 2 == 1) adjustedRect.setY(adjustedRect.y() - 1);
@@ -739,11 +764,6 @@ QMap <QString, QRect> DvdWizardMenu::buttonsInfo()
     return info;
 }
 
-bool DvdWizardMenu::isPalMenu() const
-{
-    return m_isPal;
-}
-
 QDomElement DvdWizardMenu::toXml() const
 {
     QDomDocument doc;
diff --git a/src/dvdwizardmenu.h b/src/dvdwizardmenu.h
index 2ecdcae..3854d8b 100644
--- a/src/dvdwizardmenu.h
+++ b/src/dvdwizardmenu.h
@@ -35,6 +35,7 @@
 #include <KMessageWidget>
 #endif
 
+#include "dvdwizardvob.h"
 #include "ui_dvdwizardmenu_ui.h"
 
 class DvdScene : public QGraphicsScene
@@ -129,20 +130,19 @@ class DvdWizardMenu : public QWizardPage
     Q_OBJECT
 
 public:
-    explicit DvdWizardMenu(const QString &profile, QWidget * parent = 0);
+    explicit DvdWizardMenu(DVDFORMAT format, QWidget * parent = 0);
     virtual ~DvdWizardMenu();
     virtual bool isComplete() const;
     bool createMenu() const;
     void createBackgroundImage(const QString &overlayMenu, const QString &img1);
-    void createButtonImages(const QString &img1, const QString &img2, const QString \
&img3); +    void createButtonImages(const QString &img1, const QString &img2, const \
QString &img3, bool letterbox = false);  void setTargets(QStringList list, \
                QStringList targetlist);
-    QMap <QString, QRect> buttonsInfo();
+    QMap <QString, QRect> buttonsInfo(bool letterbox = false);
     bool loopMovie() const;
     bool menuMovie() const;
     QString menuMoviePath() const;
     int menuMovieLength() const;
-    bool isPalMenu() const;
-    void changeProfile(bool isPal);
+    void changeProfile(DVDFORMAT format);
     QDomElement toXml() const;
     void loadXml(QDomElement xml);
     void prepareUnderLines();
@@ -150,7 +150,7 @@ public:
 
 private:
     Ui::DvdWizardMenu_UI m_view;
-    bool m_isPal;
+    DVDFORMAT m_format;
     DvdScene *m_scene;
     QGraphicsPixmapItem *m_background;
     QGraphicsRectItem *m_color;
diff --git a/src/dvdwizardvob.cpp b/src/dvdwizardvob.cpp
index b16d45c..73d9a64 100644
--- a/src/dvdwizardvob.cpp
+++ b/src/dvdwizardvob.cpp
@@ -34,14 +34,14 @@
 #include <QTreeWidgetItem>
 #include <QHeaderView>
 
-DvdWizardVob::DvdWizardVob(const QString &profile, QWidget *parent) :
+DvdWizardVob::DvdWizardVob(QWidget *parent) :
         QWizardPage(parent)
 {
     m_view.setupUi(this);
     m_view.intro_vob->setEnabled(false);
     m_view.intro_vob->setFilter("video/mpeg");
-    m_view.button_add->setIcon(KIcon("document-new"));
-    m_view.button_delete->setIcon(KIcon("edit-delete"));
+    m_view.button_add->setIcon(KIcon("list-add"));
+    m_view.button_delete->setIcon(KIcon("list-remove"));
     m_view.button_up->setIcon(KIcon("go-up"));
     m_view.button_down->setIcon(KIcon("go-down"));
     connect(m_view.use_intro, SIGNAL(toggled(bool)), m_view.intro_vob, \
SLOT(setEnabled(bool))); @@ -59,9 +59,6 @@ DvdWizardVob::DvdWizardVob(const QString \
&profile, QWidget *parent) :  else m_view.error_message->setText(m_errorMessage);
 
     m_view.dvd_profile->addItems(QStringList() << i18n("PAL 4:3") << i18n("PAL \
                16:9") << i18n("NTSC 4:3") << i18n("NTSC 16:9"));
-    if (profile == "dv_pal_wide") m_view.dvd_profile->setCurrentIndex(1);
-    else if (profile == "dv_ntsc") m_view.dvd_profile->setCurrentIndex(2);
-    else if (profile == "dv_ntsc_wide") m_view.dvd_profile->setCurrentIndex(3);
 
     connect(m_view.dvd_profile, SIGNAL(activated(int)), this, SLOT(changeFormat()));
     connect(m_view.dvd_profile, SIGNAL(activated(int)), this, \
SLOT(slotCheckProfiles())); @@ -387,22 +384,56 @@ void DvdWizardVob::slotItemDown()
     m_view.vobs_list->insertTopLevelItem(index + 1, \
m_view.vobs_list->takeTopLevelItem(index));  }
 
-bool DvdWizardVob::isPal() const
+DVDFORMAT DvdWizardVob::dvdFormat() const
 {
-    return m_view.dvd_profile->currentIndex() < 2;
+    return (DVDFORMAT) m_view.dvd_profile->currentIndex();
 }
 
-bool DvdWizardVob::isWide() const
+const QString DvdWizardVob::dvdProfile() const
 {
-    return (m_view.dvd_profile->currentIndex() == 1 || \
m_view.dvd_profile->currentIndex() == 3); +    QString profile;
+    switch (m_view.dvd_profile->currentIndex()) {
+	case PAL_WIDE:
+	    profile = "dv_pal_wide";
+	    break;
+	case NTSC:
+	    profile = "dv_ntsc";
+	    break;
+	case NTSC_WIDE:
+	    profile = "dv_ntsc_wide";
+	    break;
+	default:
+	    profile = "dv_pal";
+    }
+    return profile;
+}
+
+//static
+QString DvdWizardVob::getDvdProfile(DVDFORMAT format)
+{
+    QString profile;
+    switch (format) {
+	case PAL_WIDE:
+	    profile = "dv_pal_wide";
+	    break;
+	case NTSC:
+	    profile = "dv_ntsc";
+	    break;
+	case NTSC_WIDE:
+	    profile = "dv_ntsc_wide";
+	    break;
+	default:
+	    profile = "dv_pal";
+    }
+    return profile;
 }
 
 void DvdWizardVob::setProfile(const QString& profile)
 {
-    if (profile == "dv_pal") m_view.dvd_profile->setCurrentIndex(0);
-    else if (profile == "dv_pal_wide") m_view.dvd_profile->setCurrentIndex(1);
-    else if (profile == "dv_ntsc") m_view.dvd_profile->setCurrentIndex(2);
-    else if (profile == "dv_ntsc_wide") m_view.dvd_profile->setCurrentIndex(3);
+    if (profile == "dv_pal") m_view.dvd_profile->setCurrentIndex(PAL);
+    else if (profile == "dv_pal_wide") \
m_view.dvd_profile->setCurrentIndex(PAL_WIDE); +    else if (profile == "dv_ntsc") \
m_view.dvd_profile->setCurrentIndex(NTSC); +    else if (profile == "dv_ntsc_wide") \
m_view.dvd_profile->setCurrentIndex(NTSC_WIDE);  }
 
 void DvdWizardVob::clear()
diff --git a/src/dvdwizardvob.h b/src/dvdwizardvob.h
index 0b634a7..1208ff3 100644
--- a/src/dvdwizardvob.h
+++ b/src/dvdwizardvob.h
@@ -35,6 +35,8 @@
 #include <QStyledItemDelegate>
 #include <QPainter>
 
+enum DVDFORMAT { PAL, PAL_WIDE, NTSC, NTSC_WIDE };
+
 class DvdViewDelegate : public QStyledItemDelegate
 {
     Q_OBJECT
@@ -80,14 +82,14 @@ class DvdWizardVob : public QWizardPage
     Q_OBJECT
 
 public:
-    explicit DvdWizardVob(const QString &profile, QWidget * parent = 0);
+    explicit DvdWizardVob(QWidget * parent = 0);
     virtual ~DvdWizardVob();
     virtual bool isComplete() const;
     QStringList selectedUrls() const;
     void setUrl(const QString &url);
     QString introMovie() const;
-    bool isPal() const;
-    bool isWide() const;
+    DVDFORMAT dvdFormat() const;
+    const QString dvdProfile() const;
     int duration(int ix) const;
     QStringList durations() const;
     QStringList chapters() const;
@@ -95,6 +97,7 @@ public:
     void clear();
     void updateChapters(QMap <QString, QString> chaptersdata);
     void setIntroMovie(const QString& path);
+    static QString getDvdProfile(DVDFORMAT format);
 
 private:
     Ui::DvdWizardVob_UI m_view;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 82490f7..d896068 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2416,7 +2416,7 @@ void MainWindow::slotRenderProject()
         connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, \
                QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, \
                QString>)));
         connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const \
                QString&)), this, SLOT(slotPrepareRendering(bool, bool, const \
                QString&)));
         connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, \
                SIGNAL(abortRenderJob(const QString &)));
-        connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString \
&)), this, SLOT(slotDvdWizard(const QString &, const QString &))); +        \
connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &)), this, \
SLOT(slotDvdWizard(const QString &)));  if (m_activeDocument) {
             m_renderWidget->setProfile(m_activeDocument->mltProfile());
             m_renderWidget->setGuides(m_activeDocument->guidesXml(), \
m_activeDocument->projectDuration()); @@ -3877,12 +3877,12 @@ void \
MainWindow::slotUpdateClipType(QAction *action)  }
 }
 
-void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
+void MainWindow::slotDvdWizard(const QString &url)
 {
     // We must stop the monitors since we create a new on in the dvd wizard
     m_clipMonitor->stop();
     m_projectMonitor->stop();
-    QPointer<DvdWizard> w = new DvdWizard(url, profile, this);
+    QPointer<DvdWizard> w = new DvdWizard(url, this);
     w->exec();
     m_projectMonitor->start();
     delete w;
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 9efa6e4..32298a7 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -486,7 +486,7 @@ private slots:
     /** @brief Lets the sampleplugin create a generator.  */
     void generateClip();
     void slotZoneMoved(int start, int end);
-    void slotDvdWizard(const QString &url = QString(), const QString &profile = \
"dv_pal"); +    void slotDvdWizard(const QString &url = QString());
     void slotGroupClips();
     void slotUnGroupClips();
     void slotEditItemDuration();
diff --git a/src/projectlist.cpp b/src/projectlist.cpp
index 3cb9cad..3a8f932 100644
--- a/src/projectlist.cpp
+++ b/src/projectlist.cpp
@@ -946,6 +946,7 @@ void ProjectList::slotPauseMonitor()
 void ProjectList::slotUpdateClipProperties(const QString &id, QMap <QString, \
QString> properties)  {
     ProjectItem *item = getItemById(id);
+    kDebug()<<"// PROPS: "<<properties;
     if (item) {
         slotUpdateClipProperties(item, properties);
         if (properties.contains("out") || properties.contains("force_fps") || \
properties.contains("resource") || properties.contains("video_index") || \
properties.contains("audio_index")) { @@ -954,10 +955,11 @@ void \
ProjectList::slotUpdateClipProperties(const QString &id, QMap <QString, QSt  \
properties.contains("xmldata") ||  properties.contains("force_aspect_num") ||
                    properties.contains("force_aspect_den") ||
+                   properties.contains("full_luma") ||
                    properties.contains("templatetext")) {
             slotRefreshClipThumbnail(item);
             emit refreshClip(id, true);
-        } else if (properties.contains("full_luma") || \
properties.contains("force_colorspace") || properties.contains("loop")) { +        } \
else if (properties.contains("force_colorspace") || properties.contains("loop")) {  \
emit refreshClip(id, false);  }
     }
diff --git a/src/renderwidget.cpp b/src/renderwidget.cpp
index 89887ea..78d1519 100644
--- a/src/renderwidget.cpp
+++ b/src/renderwidget.cpp
@@ -1801,7 +1801,7 @@ void RenderWidget::setRenderStatus(const QString &dest, int \
status, const QStrin  item->setData(1, Qt::UserRole, t);
         QString itemGroup = item->data(0, Qt::UserRole).toString();
         if (itemGroup == "dvd") {
-            emit openDvdWizard(item->text(1), item->metadata());
+            emit openDvdWizard(item->text(1));
         } else if (itemGroup == "websites") {
             QString url = item->metadata();
             if (!url.isEmpty()) new KRun(url, this);
diff --git a/src/renderwidget.h b/src/renderwidget.h
index 0fa647a..3b4b644 100644
--- a/src/renderwidget.h
+++ b/src/renderwidget.h
@@ -209,7 +209,7 @@ private:
 
 signals:
     void abortProcess(const QString &url);
-    void openDvdWizard(const QString &url, const QString &profile);
+    void openDvdWizard(const QString &url);
     /** Send the infos about rendering that will be saved in the document:
     (profile destination, profile name and url of rendered file */
     void selectedRenderProfile(QMap <QString, QString> renderProps);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic