Start using mlt profiles

svn path=/branches/KDE4/; revision=1997
parent 43347839
......@@ -27,11 +27,18 @@
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
......@@ -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() {
......
......@@ -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);
}
......
......@@ -34,11 +34,12 @@
#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:
......
......@@ -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();
......
......@@ -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"
......@@ -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);
......
......@@ -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"
......@@ -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);
......
......@@ -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) {
......
......@@ -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();
......
......@@ -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;
}
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment