* Add separate X11 and XVideo drivers for SDL, where X11 disables hardware accel
svn path=/branches/KDE4/; revision=2364
#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)) {
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 {
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();
}
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);
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;
// 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");
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);
}
//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()));
if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
slotGotProgressInfo(QString(), -1);
m_projectMonitor->refreshMonitor(true);
- //connectDocument(trackView, doc);
}
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());
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()));
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);
// 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);
}
}
-void MainWindow::resetProfiles() {
- m_monitorManager->resetProfiles(m_activeDocument->profilePath());
-}
-
void MainWindow::slotSwitchVideoThumbs() {
KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
if (m_activeTimeline) {
void slotPasteEffects();
void slotReloadEffects();
void slotChangeClipSpeed();
- void resetProfiles();
};
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) {
public:
Monitor(QString name, MonitorManager *manager, QWidget *parent = 0);
Render *render;
- void resetProfile(QString prof);
+ void resetProfile();
QString name() const;
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);
}
void initMonitors(Monitor *clipMonitor, Monitor *projectMonitor);
Timecode timecode();
void setTimecode(Timecode tc);
- void resetProfiles(QString prof);
void switchMonitors();
bool projectMonitorFocused();
void slotForwardOneFrame();
void slotStart();
void slotEnd();
+ void resetProfiles();
private:
Monitor *m_clipMonitor;
#include <avformat.h>
}
+#include <stdlib.h>
+
#include <QTimer>
#include <QDir>
#include <QApplication>
}
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()));
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() {
}
-
-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);
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();
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;
//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();
/** 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;
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 */