From b01ea4492797423d21852d87ee942bb4b15783b6 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Fri, 31 May 2013 13:08:16 +0200 Subject: [PATCH] Const'ref --- src/clipstabilize.h | 1 - src/colorplaneexport.h | 1 - src/complexparameter.h | 1 - src/customtrackscene.cpp | 3 +- src/docclipbase.cpp | 4 +- src/docclipbase.h | 4 +- src/mainwindow.cpp | 16 +- src/mainwindow.h | 2 +- src/mltdevicecapture.cpp | 3 +- src/mltdevicecapture.h | 4 +- src/monitor.cpp | 3 +- src/monitor.h | 6 +- src/monitoreditwidget.cpp | 1 + src/monitoreditwidget.h | 3 +- src/monitorscene.h | 10 +- src/parameterplotter.cpp | 5 +- src/parameterplotter.h | 2 +- src/positionedit.h | 2 +- src/projectlist.h | 16 +- src/projectlistview.h | 27 +- src/recmonitor.h | 2 +- src/renderer.cpp | 982 +++++++++++++++++++------------------- src/renderer.h | 16 +- src/videoglwidget.h | 16 +- 24 files changed, 569 insertions(+), 561 deletions(-) diff --git a/src/clipstabilize.h b/src/clipstabilize.h index 86f4a230..f80a8450 100644 --- a/src/clipstabilize.h +++ b/src/clipstabilize.h @@ -26,7 +26,6 @@ #include "ui_clipstabilize_ui.h" #include -#include #include class QTimer; diff --git a/src/colorplaneexport.h b/src/colorplaneexport.h index aa17a66e..024e4c9a 100644 --- a/src/colorplaneexport.h +++ b/src/colorplaneexport.h @@ -38,7 +38,6 @@ private: void enableSliderColor(bool enable); void enableCbVariant(bool enable); - private slots: void slotValidate(); void slotExportPlane(); diff --git a/src/complexparameter.h b/src/complexparameter.h index b4fb4cfb..b5a7c177 100644 --- a/src/complexparameter.h +++ b/src/complexparameter.h @@ -27,7 +27,6 @@ class ClipItem; class ComplexParameter : public QWidget { Q_OBJECT - public: explicit ComplexParameter(QWidget *parent = 0); QDomElement getParamDesc() const; diff --git a/src/customtrackscene.cpp b/src/customtrackscene.cpp index 44e1a9bf..cf5dffde 100644 --- a/src/customtrackscene.cpp +++ b/src/customtrackscene.cpp @@ -44,7 +44,8 @@ double CustomTrackScene::getSnapPointForPos(double pos, bool doSnap) if (qAbs((int)(pos - m_snapPoints.at(i).frames(m_document->fps()))) < maximumOffset) { return m_snapPoints.at(i).frames(m_document->fps()); } - if (m_snapPoints.at(i).frames(m_document->fps()) > pos) break; + if (m_snapPoints.at(i).frames(m_document->fps()) > pos) + break; } } return GenTime(pos, m_document->fps()).frames(m_document->fps()); diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index f4a505c0..5065936d 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -1226,7 +1226,7 @@ QMap DocClipBase::properties() const return m_properties; } -QMap DocClipBase::currentProperties(QMap props) +QMap DocClipBase::currentProperties(const QMap &props) { QMap currentProps; QMap::const_iterator i = props.constBegin(); @@ -1285,7 +1285,7 @@ void DocClipBase::removeCutZone(int in, int out) } } -void DocClipBase::updateCutZone(int oldin, int oldout, int in, int out, QString desc) +void DocClipBase::updateCutZone(int oldin, int oldout, int in, int out, const QString &desc) { QPoint old(oldin, oldout); for (int i = 0; i < m_cutZones.size(); ++i) { diff --git a/src/docclipbase.h b/src/docclipbase.h index 46b5c03f..f59df01f 100644 --- a/src/docclipbase.h +++ b/src/docclipbase.h @@ -185,7 +185,7 @@ public: bool hasCutZone(const QPoint &p) const; void removeCutZone(int in, int out); QList cutZones() const; - void updateCutZone(int oldin, int oldout, int in, int out, QString desc = QString()); + void updateCutZone(int oldin, int oldout, int in, int out, const QString &desc = QString()); bool hasVideoCodec(const QString &codec) const; bool hasAudioCodec(const QString &codec) const; @@ -206,7 +206,7 @@ public: /** Returns all current properties for this clip */ QMap properties() const; /** Return the current values for a set of properties */ - QMap currentProperties(QMap props); + QMap currentProperties(const QMap &props); QMap metadata() const; /** @brief Returns a short info string about the clip to display in tooltip */ const QString shortInfo() const; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ddc55892..25642b33 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3443,9 +3443,10 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip) } -void MainWindow::slotApplyNewClipProperties(const QString id, QMap props, QMap newprops, bool refresh, bool reload) +void MainWindow::slotApplyNewClipProperties(const QString &id, const QMap &props, const QMap &newprops, bool refresh, bool reload) { - if (newprops.isEmpty()) return; + if (newprops.isEmpty()) + return; EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true); m_activeDocument->commandStack()->push(command); m_activeDocument->setModified(); @@ -3811,8 +3812,9 @@ void MainWindow::slotSaveZone(Render *render, const QPoint &zone, DocClipBase *b QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this); if (path.isEmpty()) { QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash); - if (baseClip == NULL) tmppath.append("untitled.mlt"); - else { + if (baseClip == NULL) { + tmppath.append("untitled.mlt"); + } else { tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + '-' + QString::number(zone.x()).rightJustified(4, '0') + ".mlt"); } path = KUrl(tmppath); @@ -4114,8 +4116,10 @@ void MainWindow::slotTranscode(const KUrl::List &urls) QAction *action = qobject_cast(sender()); QStringList data = action->data().toStringList(); params = data.at(0); - if (data.count() > 1) desc = data.at(1); - if (data.count() > 3) condition = data.at(3); + if (data.count() > 1) + desc = data.at(1); + if (data.count() > 3) + condition = data.at(3); m_projectList->slotTranscodeClipJob(condition, params, desc); return; } diff --git a/src/mainwindow.h b/src/mainwindow.h index ccd30fa8..4e0320ec 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -531,7 +531,7 @@ private slots: void slotUpdateCaptureFolder(); /** @brief Apply new properties to a clip */ - void slotApplyNewClipProperties(const QString id, QMap props, QMap newprops, bool refresh, bool reload); + void slotApplyNewClipProperties(const QString &id, const QMap &props, const QMap &newprops, bool refresh, bool reload); /** @brief Delete a clip from current project */ void slotDeleteClip(const QString &id); diff --git a/src/mltdevicecapture.cpp b/src/mltdevicecapture.cpp index 32b8529e..64edbd78 100644 --- a/src/mltdevicecapture.cpp +++ b/src/mltdevicecapture.cpp @@ -92,7 +92,8 @@ MltDeviceCapture::MltDeviceCapture(QString profile, VideoSurface *surface, QWidg { m_captureDisplayWidget = surface; analyseAudio = KdenliveSettings::monitor_audio(); - if (profile.isEmpty()) profile = KdenliveSettings::current_profile(); + if (profile.isEmpty()) + profile = KdenliveSettings::current_profile(); buildConsumer(profile); connect(this, SIGNAL(unblockPreview()), this, SLOT(slotPreparePreview())); m_droppedFramesTimer.setSingleShot(false); diff --git a/src/mltdevicecapture.h b/src/mltdevicecapture.h index 535728e2..ffba41df 100644 --- a/src/mltdevicecapture.h +++ b/src/mltdevicecapture.h @@ -137,14 +137,14 @@ signals: /** @brief A frame's image has to be shown. * * Used in Mac OS X. */ - void showImageSignal(QImage); + void showImageSignal(const QImage&); void frameSaved(const QString &); void droppedFrames(int); void unblockPreview(); - void imageReady(QImage); + void imageReady(const QImage &); public slots: diff --git a/src/monitor.cpp b/src/monitor.cpp index f9fac8d2..880279d5 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -148,7 +148,8 @@ Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profil setLayout(layout); setMinimumHeight(200); - if (profile.isEmpty()) profile = KdenliveSettings::current_profile(); + if (profile.isEmpty()) + profile = KdenliveSettings::current_profile(); bool monitorCreated = false; #ifdef Q_WS_MAC diff --git a/src/monitor.h b/src/monitor.h index c041bccb..293b34e2 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -57,9 +57,9 @@ public: void setOverlayText(const QString &, bool isZone = true); protected: - virtual void mouseDoubleClickEvent ( QMouseEvent * event ); - virtual void mousePressEvent ( QMouseEvent * event ); - virtual void mouseReleaseEvent ( QMouseEvent * event ); + void mouseDoubleClickEvent ( QMouseEvent * event ); + void mousePressEvent ( QMouseEvent * event ); + void mouseReleaseEvent ( QMouseEvent * event ); signals: void editMarker(); diff --git a/src/monitoreditwidget.cpp b/src/monitoreditwidget.cpp index 8ed40df2..0595477f 100644 --- a/src/monitoreditwidget.cpp +++ b/src/monitoreditwidget.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include diff --git a/src/monitoreditwidget.h b/src/monitoreditwidget.h index 4dc01f1f..30ce7b6a 100644 --- a/src/monitoreditwidget.h +++ b/src/monitoreditwidget.h @@ -22,7 +22,6 @@ #include "ui_monitoreditwidget_ui.h" #include -#include class QIcon; class MonitorScene; @@ -37,7 +36,7 @@ class MonitorEditWidget : public QWidget public: explicit MonitorEditWidget(Render *renderer, QWidget* parent = 0); - virtual ~MonitorEditWidget(); + ~MonitorEditWidget(); /** @brief Updates the necessary settings on a profile change. */ void resetProfile(Render *renderer); diff --git a/src/monitorscene.h b/src/monitorscene.h index a6eb27e9..f5efa8e9 100644 --- a/src/monitorscene.h +++ b/src/monitorscene.h @@ -50,13 +50,13 @@ public: void centerView(); protected: - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); /** @brief Adds a keyframe if scene is disabled. */ - virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); /** @brief Reimplemented to allow zooming using ctrl + mouse wheel. */ - virtual void wheelEvent(QGraphicsSceneWheelEvent *event); + void wheelEvent(QGraphicsSceneWheelEvent *event); public slots: /** @brief Sets the backgrounditem's pixmap to m_backgroundImage (only if a certain amount of time has passed since last update). */ diff --git a/src/parameterplotter.cpp b/src/parameterplotter.cpp index c7ebc8c0..5550ba65 100644 --- a/src/parameterplotter.cpp +++ b/src/parameterplotter.cpp @@ -77,11 +77,10 @@ void ParameterPlotter::setPointLists(const QDomElement& d, const QString& paramN int i = 0; while (!namenode.item(i).isNull() && namenode.item(i).toElement().attribute("name") != m_paramName) ++i; - if (namenode.count()) { - + if (namenode.count()) { QDomElement pa = namenode.item(i).toElement(); - QDomNode na = pa.firstChildElement("name"); + //QDomNode na = pa.firstChildElement("name"); m_parameterNameList << pa.attribute("namedesc").split(';'); emit parameterList(m_parameterNameList); diff --git a/src/parameterplotter.h b/src/parameterplotter.h index 358bed25..aea3575f 100644 --- a/src/parameterplotter.h +++ b/src/parameterplotter.h @@ -27,7 +27,7 @@ class ParameterPlotter : public KPlotWidget Q_OBJECT public: explicit ParameterPlotter(QWidget *parent = 0); - virtual ~ParameterPlotter() {} + ~ParameterPlotter() {} void setMoveX(bool); void setMoveY(bool); void setMoveTimeLine(bool); diff --git a/src/positionedit.h b/src/positionedit.h index 2666a310..ba6e4a5b 100644 --- a/src/positionedit.h +++ b/src/positionedit.h @@ -31,7 +31,7 @@ class PositionEdit : public QWidget Q_OBJECT public: explicit PositionEdit(const QString &name, int pos, int min, int max, const Timecode& tc, QWidget* parent = 0); - virtual ~PositionEdit(); + ~PositionEdit(); int getPosition() const; void setPosition(int pos); void updateTimecodeFormat(); diff --git a/src/projectlist.h b/src/projectlist.h index fa5175c4..f1313809 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -226,7 +226,7 @@ public: KRatingPainter::paintRating(painter, r1, Qt::AlignCenter, index.data().toInt()); #endif #ifdef NEPOMUKCORE - KRatingPainter::paintRating(painter, r1, Qt::AlignCenter, index.data().toInt()); + KRatingPainter::paintRating(painter, r1, Qt::AlignCenter, index.data().toInt()); #endif } else { @@ -514,7 +514,7 @@ signals: void clipSelected(DocClipBase *, const QPoint &zone = QPoint(), bool forceUpdate = false); void receivedClipDuration(const QString &); void showClipProperties(DocClipBase *); - void showClipProperties(QList , QMap commonproperties); + void showClipProperties(const QList &, const QMap &commonproperties); void projectModified(); void loadingIsOver(); void displayMessage(const QString&, int progress, MessageType type = DefaultMessage); @@ -534,17 +534,17 @@ signals: void raiseClipMonitor(bool forceRefresh); /** @brief Set number of running jobs. */ void jobCount(int); - void cancelRunningJob(const QString, stringMap); - void processLog(const QString, int , int, const QString = QString()); + void cancelRunningJob(const QString&, const stringMap&); + void processLog(const QString&, int , int, const QString & = QString()); void addClip(const QString, const QString &, const QString &); - void updateJobStatus(const QString, int, int, const QString label = QString(), const QString actionName = QString(), const QString details = QString()); - void gotProxy(const QString); + void updateJobStatus(const QString&, int, int, const QString &label = QString(), const QString &actionName = QString(), const QString &details = QString()); + void gotProxy(const QString&); void checkJobProcess(); /** @brief A Filter Job produced results, send them back to the clip. */ - void gotFilterJobResults(const QString &id, int startPos, int track, stringMap params, stringMap extra); + void gotFilterJobResults(const QString &id, int startPos, int track, const stringMap ¶ms, const stringMap &extra); void pauseMonitor(); void updateAnalysisData(DocClipBase *); - void addMarkers(const QString &, QList ); + void addMarkers(const QString &, const QList &); }; #endif diff --git a/src/projectlistview.h b/src/projectlistview.h index dd153de5..b43aa26c 100644 --- a/src/projectlistview.h +++ b/src/projectlistview.h @@ -34,26 +34,23 @@ class ProjectListView : public QTreeWidget public: ProjectListView(QWidget *parent = 0); - virtual ~ProjectListView(); + ~ProjectListView(); void processLayout(); void updateStyleSheet(); protected: - virtual void contextMenuEvent(QContextMenuEvent * event); - virtual void mouseDoubleClickEvent(QMouseEvent * event); - virtual void mousePressEvent(QMouseEvent *event); - virtual void mouseReleaseEvent(QMouseEvent *event); - virtual void mouseMoveEvent(QMouseEvent *event); - virtual void dropEvent(QDropEvent *event); - virtual QStringList mimeTypes() const; - virtual Qt::DropActions supportedDropActions() const; - virtual void dragLeaveEvent(QDragLeaveEvent *); + void contextMenuEvent(QContextMenuEvent * event); + void mouseDoubleClickEvent(QMouseEvent * event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void dropEvent(QDropEvent *event); + QStringList mimeTypes() const; + Qt::DropActions supportedDropActions() const; + void dragLeaveEvent(QDragLeaveEvent *); /** @brief Filters key events to make sure user can expand items with + / -. */ - virtual bool eventFilter(QObject *obj, QEvent *ev); - -public slots: - + bool eventFilter(QObject *obj, QEvent *ev); private: bool m_dragStarted; @@ -67,7 +64,7 @@ private slots: signals: void requestMenu(const QPoint &, QTreeWidgetItem *); void addClip(); - void addClip(const QList , const QString &, const QString &); + void addClip(const QList &, const QString &, const QString &); void showProperties(DocClipBase *); void focusMonitor(bool forceRefresh); void pauseMonitor(); diff --git a/src/recmonitor.h b/src/recmonitor.h index febfcca9..b5d767a5 100644 --- a/src/recmonitor.h +++ b/src/recmonitor.h @@ -57,7 +57,7 @@ class RecMonitor : public AbstractMonitor, public Ui::RecMonitor_UI public: explicit RecMonitor(Kdenlive::MONITORID name, MonitorManager *manager, QWidget *parent = 0); - virtual ~RecMonitor(); + ~RecMonitor(); AbstractRender *abstractRender(); void analyseFrames(bool analyse); diff --git a/src/renderer.cpp b/src/renderer.cpp index 301e2c34..4971ce0f 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -99,14 +99,14 @@ void Render::consumer_gl_frame_show(mlt_consumer consumer, Render * self, mlt_fr { // detect if the producer has finished playing. Is there a better way to do it? if (self->externalConsumer && !self->analyseAudio && !self->sendFrameForAnalysis) { - emit self->rendererPosition((int) mlt_consumer_position(consumer)); - return; + emit self->rendererPosition((int) mlt_consumer_position(consumer)); + return; } Mlt::Frame frame(frame_ptr); if (frame.get_double("_speed") == 0) self->emitConsumerStopped(); else if (frame.get_double("_speed") < 0.0 && mlt_frame_get_position(frame_ptr) <= 0) { - self->pause(); - self->emitConsumerStopped(true); + self->pause(); + self->emitConsumerStopped(true); } emit self->mltFrameReceived(new Mlt::Frame(frame_ptr)); } @@ -207,18 +207,18 @@ void Render::buildConsumer(const QString &profileName) m_activeProfile = profileName; if (m_mltProfile) { - Mlt::Profile tmpProfile(m_activeProfile.toUtf8().constData()); - m_mltProfile->set_colorspace(tmpProfile.colorspace()); - m_mltProfile->set_frame_rate(tmpProfile.frame_rate_num(), tmpProfile.frame_rate_den()); - m_mltProfile->set_height(tmpProfile.height()); - m_mltProfile->set_width(tmpProfile.width()); - m_mltProfile->set_progressive(tmpProfile.progressive()); - m_mltProfile->set_sample_aspect(tmpProfile.sample_aspect_num(), tmpProfile.sample_aspect_den()); - m_mltProfile->get_profile()->display_aspect_num = tmpProfile.display_aspect_num(); - m_mltProfile->get_profile()->display_aspect_den = tmpProfile.display_aspect_den(); + Mlt::Profile tmpProfile(m_activeProfile.toUtf8().constData()); + m_mltProfile->set_colorspace(tmpProfile.colorspace()); + m_mltProfile->set_frame_rate(tmpProfile.frame_rate_num(), tmpProfile.frame_rate_den()); + m_mltProfile->set_height(tmpProfile.height()); + m_mltProfile->set_width(tmpProfile.width()); + m_mltProfile->set_progressive(tmpProfile.progressive()); + m_mltProfile->set_sample_aspect(tmpProfile.sample_aspect_num(), tmpProfile.sample_aspect_den()); + m_mltProfile->get_profile()->display_aspect_num = tmpProfile.display_aspect_num(); + m_mltProfile->get_profile()->display_aspect_den = tmpProfile.display_aspect_den(); } else { - m_mltProfile = new Mlt::Profile(m_activeProfile.toUtf8().constData()); + m_mltProfile = new Mlt::Profile(m_activeProfile.toUtf8().constData()); } setenv("MLT_PROFILE", m_activeProfile.toUtf8().constData(), 1); m_mltProfile->set_explicit(true); @@ -232,21 +232,21 @@ void Render::buildConsumer(const QString &profileName) if (device >= 0) { QString decklink = "decklink:" + QString::number(KdenliveSettings::blackmagic_output_device()); if (!m_mltConsumer) { - m_mltConsumer = new Mlt::Consumer(*m_mltProfile, decklink.toUtf8().constData()); - m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show); - mlt_log_set_callback(kdenlive_callback); - } + m_mltConsumer = new Mlt::Consumer(*m_mltProfile, decklink.toUtf8().constData()); + m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show); + mlt_log_set_callback(kdenlive_callback); + } if (m_mltConsumer->is_valid()) { - externalConsumer = true; + externalConsumer = true; m_mltConsumer->set("terminate_on_pause", 0); m_mltConsumer->set("deinterlace_method", KdenliveSettings::mltdeinterlacer().toUtf8().constData()); - m_mltConsumer->set("rescale", KdenliveSettings::mltinterpolation().toUtf8().constData()); - m_mltConsumer->set("buffer", "1"); + m_mltConsumer->set("rescale", KdenliveSettings::mltinterpolation().toUtf8().constData()); + m_mltConsumer->set("buffer", "1"); m_mltConsumer->set("real_time", KdenliveSettings::mltthreads()); } if (m_mltConsumer && m_mltConsumer->is_valid()) { - return; - } + return; + } KMessageBox::information(qApp->activeWindow(), i18n("Your project's profile %1 is not compatible with the blackmagic output card. Please see supported profiles below. Switching to normal video display.", m_mltProfile->description())); } } @@ -266,37 +266,37 @@ void Render::buildConsumer(const QString &profileName) if (m_winid == 0) { // OpenGL monitor if (!m_mltConsumer) { - if (KdenliveSettings::external_display() && m_name != Kdenlive::clipMonitor) { - int device = KdenliveSettings::blackmagic_output_device(); - if (device >= 0) { - QString decklink = "decklink:" + QString::number(KdenliveSettings::blackmagic_output_device()); - m_mltConsumer = new Mlt::Consumer(*m_mltProfile, decklink.toUtf8().constData()); - // Set defaults for decklink consumer - if (m_mltConsumer) { - m_mltConsumer->set("terminate_on_pause", 0); - m_mltConsumer->set("deinterlace_method", KdenliveSettings::mltdeinterlacer().toUtf8().constData()); - externalConsumer = true; - } - } - } - if (!m_mltConsumer || !m_mltConsumer->is_valid()) { - m_mltConsumer = new Mlt::Consumer(*m_mltProfile, "sdl_audio"); - m_mltConsumer->set("scrub_audio", 1); - m_mltConsumer->set("preview_off", 1); - m_mltConsumer->set("audio_buffer", 512); - m_mltConsumer->set("preview_format", mlt_image_rgb24a); - } - m_mltConsumer->set("buffer", "1"); - m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_gl_frame_show); - } + if (KdenliveSettings::external_display() && m_name != Kdenlive::clipMonitor) { + int device = KdenliveSettings::blackmagic_output_device(); + if (device >= 0) { + QString decklink = "decklink:" + QString::number(KdenliveSettings::blackmagic_output_device()); + m_mltConsumer = new Mlt::Consumer(*m_mltProfile, decklink.toUtf8().constData()); + // Set defaults for decklink consumer + if (m_mltConsumer) { + m_mltConsumer->set("terminate_on_pause", 0); + m_mltConsumer->set("deinterlace_method", KdenliveSettings::mltdeinterlacer().toUtf8().constData()); + externalConsumer = true; + } + } + } + if (!m_mltConsumer || !m_mltConsumer->is_valid()) { + m_mltConsumer = new Mlt::Consumer(*m_mltProfile, "sdl_audio"); + m_mltConsumer->set("scrub_audio", 1); + m_mltConsumer->set("preview_off", 1); + m_mltConsumer->set("audio_buffer", 512); + m_mltConsumer->set("preview_format", mlt_image_rgb24a); + } + m_mltConsumer->set("buffer", "1"); + m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_gl_frame_show); + } } else { if (!m_mltConsumer) { - m_mltConsumer = new Mlt::Consumer(*m_mltProfile, "sdl_preview"); - m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show); - //m_pauseEvent = m_mltConsumer->listen("consumer-sdl-paused", this, (mlt_listener) consumer_paused); - m_mltConsumer->set("progressive", 1); - } - m_mltConsumer->set("window_id", m_winid); + m_mltConsumer = new Mlt::Consumer(*m_mltProfile, "sdl_preview"); + m_showFrameEvent = m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show); + //m_pauseEvent = m_mltConsumer->listen("consumer-sdl-paused", this, (mlt_listener) consumer_paused); + m_mltConsumer->set("progressive", 1); + } + m_mltConsumer->set("window_id", m_winid); } //m_mltConsumer->set("resize", 1); m_mltConsumer->set("window_background", KdenliveSettings::window_background().name().toUtf8().constData()); @@ -411,7 +411,7 @@ int Render::resetProfile(const QString &profileName, bool dropSceneList) return 1; } -void Render::seek(GenTime time) +void Render::seek(const GenTime &time) { if (!m_mltProducer || !m_isActive) return; @@ -425,19 +425,19 @@ void Render::seek(int time) time = qMax(0, time); time = qMin(m_mltProducer->get_playtime(), time); if (requestedSeekPosition == SEEK_INACTIVE) { - requestedSeekPosition = time; - m_mltConsumer->purge(); - m_mltProducer->seek(time); - if (m_paused && !externalConsumer) { - m_mltConsumer->set("refresh", 1); - m_paused = false; - } - else if (m_winid != 0 && m_mltProducer->get_speed() == 0) { - // workaround specific bug in MLT's SDL consumer - m_mltConsumer->stop(); - m_mltConsumer->start(); - m_mltConsumer->set("refresh", 1); - } + requestedSeekPosition = time; + m_mltConsumer->purge(); + m_mltProducer->seek(time); + if (m_paused && !externalConsumer) { + m_mltConsumer->set("refresh", 1); + m_paused = false; + } + else if (m_winid != 0 && m_mltProducer->get_speed() == 0) { + // workaround specific bug in MLT's SDL consumer + m_mltConsumer->stop(); + m_mltConsumer->start(); + m_mltConsumer->set("refresh", 1); + } } else requestedSeekPosition = time; } @@ -502,29 +502,30 @@ QImage Render::extractFrame(int frame_position, QString path, int width, int hei return KThumb::getFrame(m_mltProducer, frame_position, dwidth, width, height); } -QPixmap Render::getImageThumbnail(KUrl url, int /*width*/, int /*height*/) +QPixmap Render::getImageThumbnail(const KUrl &url, int /*width*/, int /*height*/) { QImage im; QPixmap pixmap; if (url.fileName().startsWith(".all.")) { // check for slideshow QString fileType = url.fileName().right(3); QStringList more; - QStringList::Iterator it; - QDir dir(url.directory()); QStringList filter; filter << "*." + fileType; filter << "*." + fileType.toUpper(); more = dir.entryList(filter, QDir::Files); im.load(url.directory() + '/' + more.at(0)); - } else im.load(url.path()); + } else { + im.load(url.path()); + } //pixmap = im.scaled(width, height); return pixmap; } double Render::consumerRatio() const { - if (!m_mltConsumer) return 1.0; + if (!m_mltConsumer) + return 1.0; return (m_mltConsumer->get_double("aspect_ratio_num") / m_mltConsumer->get_double("aspect_ratio_den")); } @@ -539,7 +540,7 @@ int Render::getLength() return 0; } -bool Render::isValid(KUrl url) +bool Render::isValid(const KUrl &url) { Mlt::Producer producer(*m_mltProfile, url.path().toUtf8().constData()); if (producer.is_blank()) @@ -576,7 +577,7 @@ void Render::slotSplitView(bool doit) transition->set("a_track", 0); transition->set("b_track", i); transition->set("distort", 0); - transition->set("aligned", 0); + transition->set("aligned", 0); transition->set("internal_added", "200"); QString geometry; switch (screen) { @@ -607,14 +608,14 @@ void Render::slotSplitView(bool doit) mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice); QString mlt_type = mlt_properties_get(properties, "mlt_type"); QString resource = mlt_properties_get(properties, "mlt_service"); - mlt_service nextservicetodisconnect; + mlt_service nextservicetodisconnect; while (mlt_type == "transition") { QString added = mlt_properties_get(MLT_SERVICE_PROPERTIES(nextservice), "internal_added"); if (added == "200") { - nextservicetodisconnect = nextservice; - nextservice = mlt_service_producer(nextservice); - mlt_field_disconnect_service(field->get_field(), nextservicetodisconnect); + nextservicetodisconnect = nextservice; + nextservice = mlt_service_producer(nextservice); + mlt_field_disconnect_service(field->get_field(), nextservicetodisconnect); } else nextservice = mlt_service_producer(nextservice); if (nextservice == NULL) break; @@ -631,15 +632,15 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId, in // Make sure we don't request the info for same clip twice m_infoMutex.lock(); if (m_processingClipId.contains(clipId)) { - m_infoMutex.unlock(); - return; + m_infoMutex.unlock(); + return; } for (int i = 0; i < m_requestList.count(); ++i) { - if (m_requestList.at(i).clipId == clipId) { - // Clip is already queued - m_infoMutex.unlock(); - return; - } + if (m_requestList.at(i).clipId == clipId) { + // Clip is already queued + m_infoMutex.unlock(); + return; + } } requestClipInfo info; info.xml = xml; @@ -660,8 +661,9 @@ void Render::forceProcessing(const QString &id) for (int i = 0; i < m_requestList.count(); ++i) { requestClipInfo info = m_requestList.at(i); if (info.clipId == id) { - if (i == 0) break; - else { + if (i == 0) { + break; + } else { m_requestList.removeAt(i); m_requestList.prepend(info); break; @@ -673,7 +675,7 @@ void Render::forceProcessing(const QString &id) int Render::processingItems() { QMutexLocker lock(&m_infoMutex); - int count = m_requestList.count() + m_processingClipId.count(); + const int count = m_requestList.count() + m_processingClipId.count(); return count; } @@ -732,23 +734,23 @@ void Render::processFileProperties() if (producer && producer->is_valid() && info.xml.hasAttribute("xmldata")) producer->set("xmldata", info.xml.attribute("xmldata").toUtf8().constData()); } else if (url.isEmpty()) { - //WARNING: when is this case used? Not sure it is working.. JBM/ + //WARNING: when is this case used? Not sure it is working.. JBM/ QDomDocument doc; QDomElement mlt = doc.createElement("mlt"); QDomElement play = doc.createElement("playlist"); - play.setAttribute("id", "playlist0"); + play.setAttribute("id", "playlist0"); doc.appendChild(mlt); mlt.appendChild(play); play.appendChild(doc.importNode(info.xml, true)); - QDomElement tractor = doc.createElement("tractor"); - tractor.setAttribute("id", "tractor0"); - QDomElement track = doc.createElement("track"); - track.setAttribute("producer", "playlist0"); - tractor.appendChild(track); - mlt.appendChild(tractor); + QDomElement tractor = doc.createElement("tractor"); + tractor.setAttribute("id", "tractor0"); + QDomElement track = doc.createElement("track"); + track.setAttribute("producer", "playlist0"); + tractor.appendChild(track); + mlt.appendChild(tractor); producer = new Mlt::Producer(*m_mltProfile, "xml-string", doc.toString().toUtf8().constData()); } else { - producer = new Mlt::Producer(*m_mltProfile, path.toUtf8().constData()); + producer = new Mlt::Producer(*m_mltProfile, path.toUtf8().constData()); } if (producer == NULL || producer->is_blank() || !producer->is_valid()) { @@ -837,16 +839,16 @@ void Render::processFileProperties() clipOut = length - 1; } else length = info.xml.attribute("out").toInt() - info.xml.attribute("in").toInt() + 1; - // Pass duration if it was forced - if (info.xml.hasAttribute("duration")) { - duration = info.xml.attribute("duration").toInt(); - if (length < duration) { - length = duration; - if (clipOut > 0) clipOut = length - 1; - } - } - if (duration == 0) duration = length; - producer->set("length", length); + // Pass duration if it was forced + if (info.xml.hasAttribute("duration")) { + duration = info.xml.attribute("duration").toInt(); + if (length < duration) { + length = duration; + if (clipOut > 0) clipOut = length - 1; + } + } + if (duration == 0) duration = length; + producer->set("length", length); } if (clipOut > 0) producer->set_in_and_out(info.xml.attribute("in").toInt(), clipOut); @@ -931,66 +933,66 @@ void Render::processFileProperties() } } - int vindex = -1; - const QString mltService = producer->get("mlt_service"); - if (mltService == "xml" || mltService == "consumer") { - // MLT playlist, create producer with blank profile to get real profile info - // TODO: is there an easier way to get this info (original source clip profile) from MLT? - Mlt::Profile *original_profile = new Mlt::Profile(); - Mlt::Producer *tmpProd = new Mlt::Producer(*original_profile, path.toUtf8().constData()); - filePropertyMap["progressive"] = QString::number(original_profile->progressive()); - filePropertyMap["colorspace"] = QString::number(original_profile->colorspace()); - filePropertyMap["fps"] = QString::number(original_profile->fps()); - filePropertyMap["aspect_ratio"] = QString::number(original_profile->sar()); - delete tmpProd; - delete original_profile; - } - else if (mltService == "avformat") { - // Get frame rate - vindex = producer->get_int("video_index"); - - // List streams - int streams = producer->get_int("meta.media.nb_streams"); - QList audio_list; - QList video_list; - for (int i = 0; i < streams; ++i) { - QByteArray propertyName = QString("meta.media.%1.stream.type").arg(i).toLocal8Bit(); - QString type = producer->get(propertyName.data()); - if (type == "audio") audio_list.append(i); - else if (type == "video") video_list.append(i); - } - - if (!info.xml.hasAttribute("video_index") && video_list.count() > 1) { - // Clip has more than one video stream, ask which one should be used - QMap data; - if (info.xml.hasAttribute("group")) data.insert("group", info.xml.attribute("group")); - if (info.xml.hasAttribute("groupId")) data.insert("groupId", info.xml.attribute("groupId")); - emit multiStreamFound(path, audio_list, video_list, data); - // Force video index so that when reloading the clip we don't ask again for other streams - filePropertyMap["video_index"] = QString::number(vindex); - } - - if (vindex > -1) { - snprintf(property, sizeof(property), "meta.media.%d.stream.frame_rate", vindex); - if (producer->get(property)) - filePropertyMap["fps"] = producer->get(property); - } - - if (!filePropertyMap.contains("fps")) { - if (producer->get_double("meta.media.frame_rate_den") > 0) { - filePropertyMap["fps"] = locale.toString(producer->get_double("meta.media.frame_rate_num") / producer->get_double("meta.media.frame_rate_den")); - } else filePropertyMap["fps"] = producer->get("source_fps"); - } - } + int vindex = -1; + const QString mltService = producer->get("mlt_service"); + if (mltService == "xml" || mltService == "consumer") { + // MLT playlist, create producer with blank profile to get real profile info + // TODO: is there an easier way to get this info (original source clip profile) from MLT? + Mlt::Profile *original_profile = new Mlt::Profile(); + Mlt::Producer *tmpProd = new Mlt::Producer(*original_profile, path.toUtf8().constData()); + filePropertyMap["progressive"] = QString::number(original_profile->progressive()); + filePropertyMap["colorspace"] = QString::number(original_profile->colorspace()); + filePropertyMap["fps"] = QString::number(original_profile->fps()); + filePropertyMap["aspect_ratio"] = QString::number(original_profile->sar()); + delete tmpProd; + delete original_profile; + } + else if (mltService == "avformat") { + // Get frame rate + vindex = producer->get_int("video_index"); + + // List streams + int streams = producer->get_int("meta.media.nb_streams"); + QList audio_list; + QList video_list; + for (int i = 0; i < streams; ++i) { + QByteArray propertyName = QString("meta.media.%1.stream.type").arg(i).toLocal8Bit(); + QString type = producer->get(propertyName.data()); + if (type == "audio") audio_list.append(i); + else if (type == "video") video_list.append(i); + } + + if (!info.xml.hasAttribute("video_index") && video_list.count() > 1) { + // Clip has more than one video stream, ask which one should be used + QMap data; + if (info.xml.hasAttribute("group")) data.insert("group", info.xml.attribute("group")); + if (info.xml.hasAttribute("groupId")) data.insert("groupId", info.xml.attribute("groupId")); + emit multiStreamFound(path, audio_list, video_list, data); + // Force video index so that when reloading the clip we don't ask again for other streams + filePropertyMap["video_index"] = QString::number(vindex); + } + + if (vindex > -1) { + snprintf(property, sizeof(property), "meta.media.%d.stream.frame_rate", vindex); + if (producer->get(property)) + filePropertyMap["fps"] = producer->get(property); + } + + if (!filePropertyMap.contains("fps")) { + if (producer->get_double("meta.media.frame_rate_den") > 0) { + filePropertyMap["fps"] = locale.toString(producer->get_double("meta.media.frame_rate_num") / producer->get_double("meta.media.frame_rate_den")); + } else filePropertyMap["fps"] = producer->get("source_fps"); + } + } Mlt::Frame *frame = producer->get_frame(); if (frame && frame->is_valid()) { filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + 'x' + QString::number(frame->get_int("height")); - int af = frame->get_int("audio_frequency"); - int ac = frame->get_int("audio_channels"); - // keep for compatibility with MLT <= 0.8.6 - if (af == 0) af = frame->get_int("frequency"); - if (ac == 0) ac = frame->get_int("channels"); + int af = frame->get_int("audio_frequency"); + int ac = frame->get_int("audio_channels"); + // keep for compatibility with MLT <= 0.8.6 + if (af == 0) af = frame->get_int("frequency"); + if (ac == 0) ac = frame->get_int("channels"); if (af > 0) filePropertyMap["frequency"] = QString::number(af); if (ac > 0) filePropertyMap["channels"] = QString::number(ac); if (!filePropertyMap.contains("aspect_ratio")) filePropertyMap["aspect_ratio"] = frame->get("aspect_ratio"); @@ -1031,62 +1033,62 @@ void Render::processFileProperties() // If there is a if (mltService == "avformat") { - if (vindex > -1) { - /*if (context->duration == AV_NOPTS_VALUE) { - kDebug() << " / / / / / / / /ERROR / / / CLIP HAS UNKNOWN DURATION"; - emit removeInvalidClip(clipId); - delete producer; - return; - }*/ - // Get the video_index - int video_max = 0; - int default_audio = producer->get_int("audio_index"); - int audio_max = 0; - - int scan = producer->get_int("meta.media.progressive"); - filePropertyMap["progressive"] = QString::number(scan); - - // Find maximum stream index values - for (int ix = 0; ix < producer->get_int("meta.media.nb_streams"); ix++) { - snprintf(property, sizeof(property), "meta.media.%d.stream.type", ix); - QString type = producer->get(property); - if (type == "video") - video_max = ix; - else if (type == "audio") - audio_max = ix; - } - filePropertyMap["default_video"] = QString::number(vindex); - filePropertyMap["video_max"] = QString::number(video_max); - filePropertyMap["default_audio"] = QString::number(default_audio); - filePropertyMap["audio_max"] = QString::number(audio_max); - - snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", vindex); - if (producer->get(property)) { - filePropertyMap["videocodec"] = producer->get(property); - } - snprintf(property, sizeof(property), "meta.media.%d.codec.name", vindex); - if (producer->get(property)) { - filePropertyMap["videocodecid"] = producer->get(property); - } - QString query; - query = QString("meta.media.%1.codec.pix_fmt").arg(vindex); - filePropertyMap["pix_fmt"] = producer->get(query.toUtf8().constData()); - filePropertyMap["colorspace"] = producer->get("meta.media.colorspace"); - - } else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!"; - if (producer->get_int("audio_index") > -1) { - // Get the audio_index - int index = producer->get_int("audio_index"); - snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", index); - if (producer->get(property)) { - filePropertyMap["audiocodec"] = producer->get(property); - } else { - snprintf(property, sizeof(property), "meta.media.%d.codec.name", index); - if (producer->get(property)) - filePropertyMap["audiocodec"] = producer->get(property); - } - } - } + if (vindex > -1) { + /*if (context->duration == AV_NOPTS_VALUE) { + kDebug() << " / / / / / / / /ERROR / / / CLIP HAS UNKNOWN DURATION"; + emit removeInvalidClip(clipId); + delete producer; + return; + }*/ + // Get the video_index + int video_max = 0; + int default_audio = producer->get_int("audio_index"); + int audio_max = 0; + + int scan = producer->get_int("meta.media.progressive"); + filePropertyMap["progressive"] = QString::number(scan); + + // Find maximum stream index values + for (int ix = 0; ix < producer->get_int("meta.media.nb_streams"); ix++) { + snprintf(property, sizeof(property), "meta.media.%d.stream.type", ix); + QString type = producer->get(property); + if (type == "video") + video_max = ix; + else if (type == "audio") + audio_max = ix; + } + filePropertyMap["default_video"] = QString::number(vindex); + filePropertyMap["video_max"] = QString::number(video_max); + filePropertyMap["default_audio"] = QString::number(default_audio); + filePropertyMap["audio_max"] = QString::number(audio_max); + + snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", vindex); + if (producer->get(property)) { + filePropertyMap["videocodec"] = producer->get(property); + } + snprintf(property, sizeof(property), "meta.media.%d.codec.name", vindex); + if (producer->get(property)) { + filePropertyMap["videocodecid"] = producer->get(property); + } + QString query; + query = QString("meta.media.%1.codec.pix_fmt").arg(vindex); + filePropertyMap["pix_fmt"] = producer->get(query.toUtf8().constData()); + filePropertyMap["colorspace"] = producer->get("meta.media.colorspace"); + + } else kDebug() << " / / / / /WARNING, VIDEO CONTEXT IS NULL!!!!!!!!!!!!!!"; + if (producer->get_int("audio_index") > -1) { + // Get the audio_index + int index = producer->get_int("audio_index"); + snprintf(property, sizeof(property), "meta.media.%d.codec.long_name", index); + if (producer->get(property)) { + filePropertyMap["audiocodec"] = producer->get(property); + } else { + snprintf(property, sizeof(property), "meta.media.%d.codec.name", index); + if (producer->get(property)) + filePropertyMap["audiocodec"] = producer->get(property); + } + } + } // metadata Mlt::Properties metadata; @@ -1163,7 +1165,7 @@ int Render::setProducer(Mlt::Producer *producer, int position) bool monitorIsActive = false; m_mltConsumer->set("refresh", 0); if (!m_mltConsumer->is_stopped()) { - monitorIsActive = true; + monitorIsActive = true; m_mltConsumer->stop(); } m_mltConsumer->purge(); @@ -1174,7 +1176,7 @@ int Render::setProducer(Mlt::Producer *producer, int position) if (!producer || !producer->is_valid()) { if (producer) delete producer; producer = m_blackClip->cut(0, 1); - producer->set("id", "black"); + producer->set("id", "black"); } if (!producer || !producer->is_valid()) { @@ -1188,32 +1190,32 @@ int Render::setProducer(Mlt::Producer *producer, int position) m_fps = producer->get_fps(); int volume = KdenliveSettings::volume(); if (producer->get_int("_audioclip") == 1) { - // This is an audio only clip, create fake multitrack to apply audiowave filter - Mlt::Tractor *tractor = new Mlt::Tractor(); - Mlt::Producer *color= new Mlt::Producer(*m_mltProfile, "color:red"); - color->set_in_and_out(0, producer->get_out()); - tractor->set_track(*producer, 0); - tractor->set_track(*color, 1); - - Mlt::Consumer xmlConsumer(*m_mltProfile, "xml:audio_hack"); - if (!xmlConsumer.is_valid()) return -1; - xmlConsumer.set("terminate_on_pause", 1); - xmlConsumer.connect(tractor->parent()); - xmlConsumer.run(); - delete tractor; - delete color; - delete producer; - QString playlist = QString::fromUtf8(xmlConsumer.get("audio_hack")); - - Mlt::Producer *result = new Mlt::Producer(*m_mltProfile, "xml-string", playlist.toUtf8().constData()); - Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "audiowave"); - result->attach(*filter); - tractor = new Mlt::Tractor(); - tractor->set_track(*result, 0); - delete result; - delete filter; - producer = &(tractor->parent()); - m_mltConsumer->connect(*producer); + // This is an audio only clip, create fake multitrack to apply audiowave filter + Mlt::Tractor *tractor = new Mlt::Tractor(); + Mlt::Producer *color= new Mlt::Producer(*m_mltProfile, "color:red"); + color->set_in_and_out(0, producer->get_out()); + tractor->set_track(*producer, 0); + tractor->set_track(*color, 1); + + Mlt::Consumer xmlConsumer(*m_mltProfile, "xml:audio_hack"); + if (!xmlConsumer.is_valid()) return -1; + xmlConsumer.set("terminate_on_pause", 1); + xmlConsumer.connect(tractor->parent()); + xmlConsumer.run(); + delete tractor; + delete color; + delete producer; + QString playlist = QString::fromUtf8(xmlConsumer.get("audio_hack")); + + Mlt::Producer *result = new Mlt::Producer(*m_mltProfile, "xml-string", playlist.toUtf8().constData()); + Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "audiowave"); + result->attach(*filter); + tractor = new Mlt::Tractor(); + tractor->set_track(*result, 0); + delete result; + delete filter; + producer = &(tractor->parent()); + m_mltConsumer->connect(*producer); } producer->set("meta.volume", (double)volume / 100); @@ -1228,7 +1230,7 @@ int Render::setProducer(Mlt::Producer *producer, int position) m_mltProducer = producer; m_mltProducer->set_speed(0); if (monitorIsActive) { - startConsumer(); + startConsumer(); } emit durationChanged(m_mltProducer->get_playtime()); position = m_mltProducer->position(); @@ -1237,7 +1239,7 @@ int Render::setProducer(Mlt::Producer *producer, int position) } void Render::startConsumer() { - if (m_mltConsumer->is_stopped() && m_mltConsumer->start() == -1) { + if (m_mltConsumer->is_stopped() && m_mltConsumer->start() == -1) { // ARGH CONSUMER BROKEN!!!! KMessageBox::error(qApp->activeWindow(), i18n("Could not create the video preview window.\nThere is something wrong with your Kdenlive install or your driver settings, please fix it.")); if (m_showFrameEvent) delete m_showFrameEvent; @@ -1252,7 +1254,7 @@ void Render::startConsumer() { m_isActive = true; } -int Render::setSceneList(QDomDocument list, int position) +int Render::setSceneList(const QDomDocument &list, int position) { return setSceneList(list.toString(), position); } @@ -1553,8 +1555,8 @@ void Render::start() return; } if (!m_mltConsumer) { - kDebug()<<" / - - - STARTED BEFORE CONSUMER!!!"; - return; + kDebug()<<" / - - - STARTED BEFORE CONSUMER!!!"; + return; } if (m_mltConsumer->is_stopped()) { if (m_mltConsumer->start() == -1) { @@ -1575,7 +1577,7 @@ void Render::stop() m_isActive = false; if (m_mltProducer == NULL) return; if (m_mltConsumer) { - m_mltConsumer->set("refresh", 0); + m_mltConsumer->set("refresh", 0); if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop(); m_mltConsumer->purge(); } @@ -1614,7 +1616,7 @@ void Render::pause() void Render::setActiveMonitor() { - if (!m_isActive) emit activateMonitor(m_name); + if (!m_isActive) emit activateMonitor(m_name); } void Render::switchPlay(bool play) @@ -1626,26 +1628,26 @@ void Render::switchPlay(bool play) if (m_isZoneMode) resetZoneMode(); if (play && m_paused) { if (m_name == Kdenlive::clipMonitor && m_mltConsumer->position() == m_mltProducer->get_out()) m_mltProducer->seek(0); - m_paused = false; - m_mltProducer->set_speed(1.0); + m_paused = false; + m_mltProducer->set_speed(1.0); if (m_mltConsumer->is_stopped()) { m_mltConsumer->start(); } m_mltConsumer->set("refresh", 1); } else if (!play) { - m_paused = true; - if (m_winid == 0) { - // OpenGL consumer - m_mltProducer->set_speed(0.0); - } - else { - // SDL consumer, hack to allow pausing near the end of the playlist - m_mltConsumer->set("refresh", 0); - m_mltConsumer->stop(); - m_mltProducer->set_speed(0.0); - m_mltProducer->seek(m_mltConsumer->position()); - m_mltConsumer->start(); - } + m_paused = true; + if (m_winid == 0) { + // OpenGL consumer + m_mltProducer->set_speed(0.0); + } + else { + // SDL consumer, hack to allow pausing near the end of the playlist + m_mltConsumer->set("refresh", 0); + m_mltConsumer->stop(); + m_mltProducer->set_speed(0.0); + m_mltProducer->seek(m_mltConsumer->position()); + m_mltConsumer->start(); + } } } @@ -1659,7 +1661,7 @@ void Render::play(double speed) // if (speed == 0.0) m_mltProducer->set("out", m_mltProducer->get_length() - 1); m_mltProducer->set_speed(speed); if (m_mltConsumer->is_stopped() && speed != 0) { - m_mltConsumer->start(); + m_mltConsumer->start(); } m_paused = speed == 0; if (current_speed == 0 && speed != 0) m_mltConsumer->set("refresh", 1); @@ -1691,7 +1693,7 @@ void Render::playZone(const GenTime & startTime, const GenTime & stopTime) { requestedSeekPosition = SEEK_INACTIVE; if (!m_mltProducer || !m_mltConsumer || !m_isActive) - return; + return; m_mltProducer->set("out", (int)(stopTime.frames(m_fps))); m_mltProducer->seek((int)(startTime.frames(m_fps))); m_paused = false; @@ -1723,7 +1725,7 @@ void Render::seekToFrameDiff(int diff) return; resetZoneMode(); if (requestedSeekPosition == SEEK_INACTIVE) - seek(m_mltProducer->position() + diff); + seek(m_mltProducer->position() + diff); else seek(requestedSeekPosition + diff); } @@ -1745,7 +1747,7 @@ void Render::refresh() return; if (m_mltConsumer) { if (m_mltConsumer->is_stopped()) m_mltConsumer->start(); - m_mltConsumer->set("refresh", 1); + m_mltConsumer->set("refresh", 1); //m_mltConsumer->purge(); } } @@ -1825,17 +1827,17 @@ void Render::emitFrameNumber() { int currentPos = m_mltConsumer->position(); if (currentPos == requestedSeekPosition) { - requestedSeekPosition = SEEK_INACTIVE; - m_paused = true; + requestedSeekPosition = SEEK_INACTIVE; + m_paused = true; } emit rendererPosition(currentPos); if (requestedSeekPosition != SEEK_INACTIVE) { - m_mltConsumer->purge(); - m_mltProducer->seek(requestedSeekPosition); - if (m_mltProducer->get_speed() == 0 && !m_paused) { - m_mltConsumer->set("refresh", 1); - } - requestedSeekPosition = SEEK_INACTIVE; + m_mltConsumer->purge(); + m_mltProducer->seek(requestedSeekPosition); + if (m_mltProducer->get_speed() == 0 && !m_paused) { + m_mltConsumer->set("refresh", 1); + } + requestedSeekPosition = SEEK_INACTIVE; } } @@ -1844,7 +1846,7 @@ void Render::emitConsumerStopped(bool forcePause) // This is used to know when the playing stopped if (m_mltProducer && (forcePause || (!m_paused && m_mltProducer->get_speed() == 0))) { double pos = m_mltProducer->position(); - m_paused = true; + m_paused = true; if (m_isLoopMode) play(m_loopStart); //else if (m_isZoneMode) resetZoneMode(); emit rendererStopped((int) pos); @@ -1889,18 +1891,18 @@ void Render::showFrame(Mlt::Frame* frame) if (currentPos == requestedSeekPosition) requestedSeekPosition = SEEK_INACTIVE; emit rendererPosition(currentPos); if (frame->is_valid()) { - mlt_image_format format = mlt_image_rgb24; - int width = 0; - int height = 0; - const uchar* image = frame->get_image(format, width, height); - QImage qimage(width, height, QImage::Format_RGB888); //Format_ARGB32_Premultiplied); - memcpy(qimage.scanLine(0), image, width * height * 3); - if (analyseAudio) showAudio(*frame); - delete frame; - emit showImageSignal(qimage); - if (sendFrameForAnalysis) { - emit frameUpdated(qimage); - } + mlt_image_format format = mlt_image_rgb24; + int width = 0; + int height = 0; + const uchar* image = frame->get_image(format, width, height); + QImage qimage(width, height, QImage::Format_RGB888); //Format_ARGB32_Premultiplied); + memcpy(qimage.scanLine(0), image, width * height * 3); + if (analyseAudio) showAudio(*frame); + delete frame; + emit showImageSignal(qimage); + if (sendFrameForAnalysis) { + emit frameUpdated(qimage); + } } else delete frame; showFrameSemaphore.release(); emit checkSeeking(); @@ -1908,22 +1910,22 @@ void Render::showFrame(Mlt::Frame* frame) void Render::slotCheckSeeking() { - if (requestedSeekPosition != SEEK_INACTIVE) { - m_mltProducer->seek(requestedSeekPosition); - if (m_paused) { - refresh(); - } - requestedSeekPosition = SEEK_INACTIVE; + if (requestedSeekPosition != SEEK_INACTIVE) { + m_mltProducer->seek(requestedSeekPosition); + if (m_paused) { + refresh(); + } + requestedSeekPosition = SEEK_INACTIVE; } } void Render::disablePreview(bool disable) { if (m_mltConsumer) { - m_mltConsumer->stop(); - m_mltConsumer->set("preview_off", (int) disable); - m_mltConsumer->set("refresh", 0); - m_mltConsumer->start(); + m_mltConsumer->stop(); + m_mltConsumer->set("preview_off", (int) disable); + m_mltConsumer->set("refresh", 0); + m_mltConsumer->start(); } } @@ -2008,10 +2010,10 @@ void Render::mltCheckLength(Mlt::Tractor *tractor) } delete blackclip; - if (m_mltConsumer->position() > duration) { - m_mltConsumer->purge(); - m_mltProducer->seek(duration); - } + if (m_mltConsumer->position() > duration) { + m_mltConsumer->purge(); + m_mltProducer->seek(duration); + } m_mltProducer->set("out", duration); emit durationChanged(duration); } @@ -2150,7 +2152,7 @@ bool Render::mltCutClip(int track, const GenTime &position) if (original == NULL || clip == NULL) { kDebug() << "// ERROR GRABBING CLIP AFTER SPLIT"; - return false; + return false; } Mlt::Service clipService(original->get_service()); @@ -2604,10 +2606,10 @@ int Render::mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, dou newLength = trackPlaylist.clip_length(clipIndex); service.unlock(); } else if (speed == 1.0 && strobe < 2) { - if (!prod || !prod->is_valid()) { - kDebug()<<"// Something is wrong with producer"; - return -1; - } + if (!prod || !prod->is_valid()) { + kDebug()<<"// Something is wrong with producer"; + return -1; + } service.lock(); Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex); @@ -2873,7 +2875,7 @@ bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int bool Render::addFilterToService(Mlt::Service service, EffectsParameterList params, int duration) { - // create filter + // create filter QString tag = params.paramValue("tag"); //kDebug() << " / / INSERTING EFFECT: " << tag << ", REGI: " << region; QString kfr = params.paramValue("keyframes"); @@ -2910,41 +2912,41 @@ bool Render::addFilterToService(Mlt::Service service, EffectsParameterList param filter->set(starttag, m_locale.toString(((min + y1) - paramOffset) / factor).toUtf8().data()); service.attach(*filter); } else { - delete[] starttag; - delete[] endtag; - kDebug() << "filter is NULL"; - service.unlock(); - return false; - } + delete[] starttag; + delete[] endtag; + kDebug() << "filter is NULL"; + service.unlock(); + return false; + } } else for (int i = 0; i < keyFrames.size() - 1; ++i) { - Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, qstrdup(tag.toUtf8().constData())); - if (filter && filter->is_valid()) { - filter->set("kdenlive_id", qstrdup(params.paramValue("id").toUtf8().constData())); - int x1 = keyFrames.at(i).section(':', 0, 0).toInt() + offset; - double y1 = keyFrames.at(i).section(':', 1, 1).toDouble(); - int x2 = keyFrames.at(i + 1).section(':', 0, 0).toInt(); - double y2 = keyFrames.at(i + 1).section(':', 1, 1).toDouble(); - if (x2 == -1) x2 = duration; - - for (int j = 0; j < params.count(); j++) { - filter->set(params.at(j).name().toUtf8().constData(), params.at(j).value().toUtf8().constData()); - } + Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, qstrdup(tag.toUtf8().constData())); + if (filter && filter->is_valid()) { + filter->set("kdenlive_id", qstrdup(params.paramValue("id").toUtf8().constData())); + int x1 = keyFrames.at(i).section(':', 0, 0).toInt() + offset; + double y1 = keyFrames.at(i).section(':', 1, 1).toDouble(); + int x2 = keyFrames.at(i + 1).section(':', 0, 0).toInt(); + double y2 = keyFrames.at(i + 1).section(':', 1, 1).toDouble(); + if (x2 == -1) x2 = duration; - filter->set("in", x1); - filter->set("out", x2); - //kDebug() << "// ADDING KEYFRAME vals: " << min<<" / "<set(starttag, m_locale.toString(((min + y1) - paramOffset) / factor).toUtf8().data()); - filter->set(endtag, m_locale.toString(((min + y2) - paramOffset) / factor).toUtf8().data()); - service.attach(*filter); - offset = 1; - } else { - delete[] starttag; - delete[] endtag; - kDebug() << "filter is NULL"; - service.unlock(); - return false; - } + for (int j = 0; j < params.count(); j++) { + filter->set(params.at(j).name().toUtf8().constData(), params.at(j).value().toUtf8().constData()); + } + + filter->set("in", x1); + filter->set("out", x2); + //kDebug() << "// ADDING KEYFRAME vals: " << min<<" / "<set(starttag, m_locale.toString(((min + y1) - paramOffset) / factor).toUtf8().data()); + filter->set(endtag, m_locale.toString(((min + y2) - paramOffset) / factor).toUtf8().data()); + service.attach(*filter); + offset = 1; + } else { + delete[] starttag; + delete[] endtag; + kDebug() << "filter is NULL"; + service.unlock(); + return false; } + } delete[] starttag; delete[] endtag; } else { @@ -3038,12 +3040,12 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par if (!params.paramValue("keyframes").isEmpty() || (tag == "affine" && params.hasParam("background")) || tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle") { // This is a keyframe effect, to edit it, we remove it and re-add it. bool success = mltRemoveEffect(track, position, index, false); -// if (!success) kDebug() << "// ERROR Removing effect : " << index; + // if (!success) kDebug() << "// ERROR Removing effect : " << index; if (position < GenTime()) success = mltAddTrackEffect(track, params); else success = mltAddEffect(track, position, params); -// if (!success) kDebug() << "// ERROR Adding effect : " << index; + // if (!success) kDebug() << "// ERROR Adding effect : " << index; return success; } if (position < GenTime()) { @@ -3091,27 +3093,27 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par QList filtersList; service.lock(); if (ser != tag) { - // Effect service changes, delete effect and re-add it - clip->detach(*filter); - - // Delete all effects after deleted one - filter = clip->filter(ct); + // Effect service changes, delete effect and re-add it + clip->detach(*filter); + + // Delete all effects after deleted one + filter = clip->filter(ct); while (filter) { if (filter->get_int("kdenlive_ix") > index) { filtersList.append(filter); clip->detach(*filter); - } - else ct++; + } + else ct++; filter = clip->filter(ct); - } - - // re-add filter - addFilterToService(*clip, params, clip->get_playtime()); - delete clip; - service.unlock(); + } - if (doRefresh) refresh(); - return true; + // re-add filter + addFilterToService(*clip, params, clip->get_playtime()); + delete clip; + service.unlock(); + + if (doRefresh) refresh(); + return true; } if (params.hasParam("_sync_in_out")) { // This effect must sync in / out with parent clip @@ -3124,7 +3126,7 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par } for (int j = 0; j < filtersList.count(); j++) { - clip->attach(*(filtersList.at(j))); + clip->attach(*(filtersList.at(j))); } delete clip; @@ -3465,13 +3467,13 @@ void Render::mltChangeTrackState(int track, bool mute, bool blind) // because audio mixing is done between each track and the lowest one bool audioMixingBroken = false; if (mute && trackProducer.get_int("hide") < 2 ) { - // We mute a track with sound - if (track == getLowestNonMutedAudioTrack(tractor)) audioMixingBroken = true; - kDebug()<<"Muting track: "< 1 ) { - // We un-mute a previously muted track - if (track < getLowestNonMutedAudioTrack(tractor)) audioMixingBroken = true; + // We un-mute a previously muted track + if (track < getLowestNonMutedAudioTrack(tractor)) audioMixingBroken = true; } if (mute) { @@ -3513,7 +3515,7 @@ void Render::fixAudioMixing(Mlt::Tractor tractor) QString resource = mlt_properties_get(properties, "mlt_service"); mlt_service nextservicetodisconnect; - // Delete all audio mixing transitions + // Delete all audio mixing transitions while (mlt_type == "transition") { if (resource == "mix") { nextservicetodisconnect = nextservice; @@ -3561,7 +3563,7 @@ bool Render::mltResizeClipCrop(ItemInfo info, GenTime newCropStart) int previousOut = clip->get_out(); delete clip; if (previousStart == newCropFrame) { - kDebug() << "//////// No ReSIZING Required"; + kDebug() << "//////// No ReSIZING Required"; service.unlock(); return true; } @@ -3697,7 +3699,7 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn bool checkLength = false; if (endTrack == startTrack) { Mlt::Producer *clipProducer = trackPlaylist.replace_with_blank(clipIndex); - if (!clipProducer) { + if (!clipProducer) { kDebug() << "// Cannot get clip at index: "<is_valid() || clipProducer->is_blank()) { - success = false; - } + success = false; + } else { // Check that the destination region is empty trackPlaylist.consolidate_blanks(0); @@ -3729,11 +3731,11 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn return false; } } else { - // Overwrite mode + // Overwrite mode trackPlaylist.remove_region(moveEnd, clipProducer->get_playtime()); int ix = trackPlaylist.get_clip_index_at(moveEnd); trackPlaylist.insert_blank(ix, clipProducer->get_playtime() - 1); - trackPlaylist.consolidate_blanks(0); + trackPlaylist.consolidate_blanks(0); } int newIndex = trackPlaylist.insert_at(moveEnd, clipProducer, 1); if (newIndex == -1) { @@ -3789,7 +3791,7 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn destTrackPlaylist.remove_region(moveEnd, clip->get_playtime()); int clipIndex = destTrackPlaylist.get_clip_index_at(moveEnd); destTrackPlaylist.insert_blank(clipIndex, clip->get_playtime() - 1); - destTrackPlaylist.consolidate_blanks(0); + destTrackPlaylist.consolidate_blanks(0); } int newIndex = destTrackPlaylist.insert_at(moveEnd, clip, 1); @@ -3874,7 +3876,7 @@ bool Render::mltMoveTransition(QString type, int startTrack, int newTrack, int n while (mlt_type == "transition") { Mlt::Transition transition((mlt_transition) nextservice); - nextservice = mlt_service_producer(nextservice); + nextservice = mlt_service_producer(nextservice); int currentTrack = transition.get_b_track(); int currentIn = (int) transition.get_in(); int currentOut = (int) transition.get_out(); @@ -3885,9 +3887,9 @@ bool Render::mltMoveTransition(QString type, int startTrack, int newTrack, int n Mlt::Properties trans_props(transition.get_properties()); Mlt::Transition new_transition(*m_mltProfile, transition.get("mlt_service")); Mlt::Properties new_trans_props(new_transition.get_properties()); - // We cannot use MLT's property inherit because it also clones internal values like _unique_id which messes up the playlist - cloneProperties(new_trans_props, trans_props); - new_transition.set_in_and_out(new_in, new_out); + // We cannot use MLT's property inherit because it also clones internal values like _unique_id which messes up the playlist + cloneProperties(new_trans_props, trans_props); + new_transition.set_in_and_out(new_in, new_out); field->disconnect_service(transition); mltPlantTransition(field, new_transition, newTransitionTrack, newTrack); } else transition.set_in_and_out(new_in, new_out); @@ -3906,17 +3908,17 @@ bool Render::mltMoveTransition(QString type, int startTrack, int newTrack, int n void Render::cloneProperties(Mlt::Properties &dest, Mlt::Properties &source) { - int count = source.count(); - int i = 0; - for ( i = 0; i < count; i ++ ) - { - char *value = source.get(i); - if ( value != NULL ) - { - char *name = source.get_name( i ); - if (name != NULL && name[0] != '_') dest.set(name, value); - } - } + int count = source.count(); + int i = 0; + for ( i = 0; i < count; i ++ ) + { + char *value = source.get(i); + if ( value != NULL ) + { + char *name = source.get_name( i ); + if (name != NULL && name[0] != '_') dest.set(name, value); + } + } } void Render::mltPlantTransition(Mlt::Field *field, Mlt::Transition &tr, int a_track, int b_track) @@ -3932,7 +3934,7 @@ void Render::mltPlantTransition(Mlt::Field *field, Mlt::Transition &tr, int a_tr while (mlt_type == "transition") { Mlt::Transition transition((mlt_transition) nextservice); - nextservice = mlt_service_producer(nextservice); + nextservice = mlt_service_producer(nextservice); int aTrack = transition.get_a_track(); int bTrack = transition.get_b_track(); if ((isMixTransition || resource != "mix") && (aTrack < a_track || (aTrack == a_track && bTrack > b_track))) { @@ -3940,7 +3942,7 @@ void Render::mltPlantTransition(Mlt::Field *field, Mlt::Transition &tr, int a_tr Mlt::Transition *cp = new Mlt::Transition(*m_mltProfile, transition.get("mlt_service")); Mlt::Properties new_trans_props(cp->get_properties()); //new_trans_props.inherit(trans_props); - cloneProperties(new_trans_props, trans_props); + cloneProperties(new_trans_props, trans_props); trList.append(cp); field->disconnect_service(transition); } @@ -4318,7 +4320,7 @@ const QList Render::producersList() Mlt::Producer trackProducer(tt); delete tt; Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); - if (!trackPlaylist.is_valid()) continue; + if (!trackPlaylist.is_valid()) continue; int clipNb = trackPlaylist.count(); for (int i = 0; i < clipNb; ++i) { Mlt::Producer *c = trackPlaylist.get_clip(i); @@ -4351,7 +4353,7 @@ void Render::fillSlowMotionProducers() Mlt::Producer trackProducer(tt); delete tt; Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); - if (!trackPlaylist.is_valid()) continue; + if (!trackPlaylist.is_valid()) continue; int clipNb = trackPlaylist.count(); for (int i = 0; i < clipNb; ++i) { Mlt::Producer *c = trackPlaylist.get_clip(i); @@ -4421,45 +4423,45 @@ QList Render::mltInsertTrack(int ix, bool videoTrack) while (mlt_type == "transition") { if (resource != "mix") { - Mlt::Transition transition((mlt_transition) nextservice); - nextservice = mlt_service_producer(nextservice); + Mlt::Transition transition((mlt_transition) nextservice); + nextservice = mlt_service_producer(nextservice); int currentbTrack = transition.get_b_track(); int currentaTrack = transition.get_a_track(); - bool trackChanged = false; - bool forceTransitionTrack = false; + bool trackChanged = false; + bool forceTransitionTrack = false; if (currentbTrack >= ix) { - if (currentbTrack == ix && currentaTrack < ix) forceTransitionTrack = true; - currentbTrack++; - trackChanged = true; - } - if (currentaTrack >= ix) { - currentaTrack++; - trackChanged = true; - } - kDebug()<<"// Newtrans: "<get_properties()); - cloneProperties(new_trans_props, trans_props); - //new_trans_props.inherit(trans_props); - - if (trackChanged) { - // Transition track needs to be adjusted - cp->set("a_track", currentaTrack); - cp->set("b_track", currentbTrack); - // Check if transition track was changed and needs to be forced - if (forceTransitionTrack) cp->set("force_track", 1); - TransitionInfo trInfo; - trInfo.startPos = GenTime(transition.get_in(), m_fps); - trInfo.a_track = currentaTrack; - trInfo.b_track = currentbTrack; - trInfo.forceTrack = cp->get_int("force_track"); - transitionInfos.append(trInfo); - } - trList.append(cp); - field->disconnect_service(transition); + if (currentbTrack == ix && currentaTrack < ix) forceTransitionTrack = true; + currentbTrack++; + trackChanged = true; + } + if (currentaTrack >= ix) { + currentaTrack++; + trackChanged = true; + } + kDebug()<<"// Newtrans: "<get_properties()); + cloneProperties(new_trans_props, trans_props); + //new_trans_props.inherit(trans_props); + + if (trackChanged) { + // Transition track needs to be adjusted + cp->set("a_track", currentaTrack); + cp->set("b_track", currentbTrack); + // Check if transition track was changed and needs to be forced + if (forceTransitionTrack) cp->set("force_track", 1); + TransitionInfo trInfo; + trInfo.startPos = GenTime(transition.get_in(), m_fps); + trInfo.a_track = currentaTrack; + trInfo.b_track = currentbTrack; + trInfo.forceTrack = cp->get_int("force_track"); + transitionInfos.append(trInfo); + } + trList.append(cp); + field->disconnect_service(transition); } else nextservice = mlt_service_producer(nextservice); if (nextservice == NULL) break; @@ -4683,19 +4685,19 @@ bool Render::getBlackMagicDeviceList(KComboBox *devicelist, bool force) Mlt::Producer bm(profile, "decklink"); int found_devices = 0; if (bm.is_valid()) { - bm.set("list_devices", 1); - found_devices = bm.get_int("devices"); + bm.set("list_devices", 1); + found_devices = bm.get_int("devices"); } else KdenliveSettings::setDecklink_device_found(false); if (found_devices <= 0) { - devicelist->setEnabled(false); - return false; + devicelist->setEnabled(false); + return false; } KdenliveSettings::setDecklink_device_found(true); for (int i = 0; i < found_devices; ++i) { - char *tmp = qstrdup(QString("device.%1").arg(i).toUtf8().constData()); - devicelist->addItem(bm.get(tmp)); - delete[] tmp; + char *tmp = qstrdup(QString("device.%1").arg(i).toUtf8().constData()); + devicelist->addItem(bm.get(tmp)); + delete[] tmp; } return true; } @@ -4707,19 +4709,19 @@ bool Render::getBlackMagicOutputDeviceList(KComboBox *devicelist, bool force) Mlt::Consumer bm(profile, "decklink"); int found_devices = 0; if (bm.is_valid()) { - bm.set("list_devices", 1);; - found_devices = bm.get_int("devices"); + bm.set("list_devices", 1);; + found_devices = bm.get_int("devices"); } else KdenliveSettings::setDecklink_device_found(false); if (found_devices <= 0) { - devicelist->setEnabled(false); - return false; + devicelist->setEnabled(false); + return false; } KdenliveSettings::setDecklink_device_found(true); for (int i = 0; i < found_devices; ++i) { - char *tmp = qstrdup(QString("device.%1").arg(i).toUtf8().constData()); - devicelist->addItem(bm.get(tmp)); - delete[] tmp; + char *tmp = qstrdup(QString("device.%1").arg(i).toUtf8().constData()); + devicelist->addItem(bm.get(tmp)); + delete[] tmp; } return true; } @@ -4727,18 +4729,18 @@ bool Render::getBlackMagicOutputDeviceList(KComboBox *devicelist, bool force) void Render::slotMultiStreamProducerFound(const QString path, QList audio_list, QList video_list, stringMap data) { if (KdenliveSettings::automultistreams()) { - for (int i = 1; i < video_list.count(); ++i) { - int vindex = video_list.at(i); - int aindex = 0; - if (i <= audio_list.count() -1) { - aindex = audio_list.at(i); - } - data.insert("video_index", QString::number(vindex)); - data.insert("audio_index", QString::number(aindex)); - data.insert("bypassDuplicate", "1"); - emit addClip(KUrl(path), data); - } - return; + for (int i = 1; i < video_list.count(); ++i) { + int vindex = video_list.at(i); + int aindex = 0; + if (i <= audio_list.count() -1) { + aindex = audio_list.at(i); + } + data.insert("video_index", QString::number(vindex)); + data.insert("audio_index", QString::number(aindex)); + data.insert("bypassDuplicate", "1"); + emit addClip(KUrl(path), data); + } + return; } int width = 60.0 * m_mltProfile->dar(); @@ -4758,41 +4760,41 @@ void Render::slotMultiStreamProducerFound(const QString path, QList audio_l QList comboList; // We start loading the list at 1, video index 0 should already be loaded for (int j = 1; j < video_list.count(); j++) { - Mlt::Producer multiprod(* m_mltProfile, path.toUtf8().constData()); - multiprod.set("video_index", video_list.at(j)); - QImage thumb = KThumb::getFrame(&multiprod, 0, swidth, width, 60); - QGroupBox *streamFrame = new QGroupBox(i18n("Video stream %1", video_list.at(j)), content); - streamFrame->setProperty("vindex", video_list.at(j)); - groupList << streamFrame; - streamFrame->setCheckable(true); - streamFrame->setChecked(true); - QVBoxLayout *vh = new QVBoxLayout( streamFrame ); - QLabel *iconLabel = new QLabel(content); - iconLabel->setPixmap(QPixmap::fromImage(thumb)); - vh->addWidget(iconLabel); - if (audio_list.count() > 1) { - QComboBox *cb = new QComboBox(content); - for (int k = 0; k < audio_list.count(); k++) { - cb->addItem(i18n("Audio stream %1", audio_list.at(k)), audio_list.at(k)); - } - comboList << cb; - cb->setCurrentIndex(qMin(j, audio_list.count() - 1)); - vh->addWidget(cb); - } - vbox->addWidget(streamFrame); + Mlt::Producer multiprod(* m_mltProfile, path.toUtf8().constData()); + multiprod.set("video_index", video_list.at(j)); + QImage thumb = KThumb::getFrame(&multiprod, 0, swidth, width, 60); + QGroupBox *streamFrame = new QGroupBox(i18n("Video stream %1", video_list.at(j)), content); + streamFrame->setProperty("vindex", video_list.at(j)); + groupList << streamFrame; + streamFrame->setCheckable(true); + streamFrame->setChecked(true); + QVBoxLayout *vh = new QVBoxLayout( streamFrame ); + QLabel *iconLabel = new QLabel(content); + iconLabel->setPixmap(QPixmap::fromImage(thumb)); + vh->addWidget(iconLabel); + if (audio_list.count() > 1) { + QComboBox *cb = new QComboBox(content); + for (int k = 0; k < audio_list.count(); k++) { + cb->addItem(i18n("Audio stream %1", audio_list.at(k)), audio_list.at(k)); + } + comboList << cb; + cb->setCurrentIndex(qMin(j, audio_list.count() - 1)); + vh->addWidget(cb); + } + vbox->addWidget(streamFrame); } if (dialog.exec() == QDialog::Accepted) { - // import selected streams - for (int i = 0; i < groupList.count(); ++i) { - if (groupList.at(i)->isChecked()) { - int vindex = groupList.at(i)->property("vindex").toInt(); - int aindex = comboList.at(i)->itemData(comboList.at(i)->currentIndex()).toInt(); - data.insert("video_index", QString::number(vindex)); - data.insert("audio_index", QString::number(aindex)); - data.insert("bypassDuplicate", "1"); - emit addClip(KUrl(path), data); - } - } + // import selected streams + for (int i = 0; i < groupList.count(); ++i) { + if (groupList.at(i)->isChecked()) { + int vindex = groupList.at(i)->property("vindex").toInt(); + int aindex = comboList.at(i)->itemData(comboList.at(i)->currentIndex()).toInt(); + data.insert("video_index", QString::number(vindex)); + data.insert("audio_index", QString::number(aindex)); + data.insert("bypassDuplicate", "1"); + emit addClip(KUrl(path), data); + } + } } } diff --git a/src/renderer.h b/src/renderer.h index 1f0edec1..4cc20bef 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -82,7 +82,13 @@ struct requestClipInfo { class MltErrorEvent : public QEvent { public: - MltErrorEvent(const QString &message) : QEvent(QEvent::User), m_message(message) {} + MltErrorEvent(const QString &message) + : QEvent(QEvent::User), + m_message(message) + { + + } + QString message() const { return m_message; } @@ -109,16 +115,16 @@ class Render: public AbstractRender virtual ~Render(); /** @brief Seeks the renderer clip to the given time. */ - void seek(GenTime time); + void seek(const GenTime &time); void seek(int time); void seekToFrameDiff(int diff); - QPixmap getImageThumbnail(KUrl url, int width, int height); + QPixmap getImageThumbnail(const KUrl &url, int width, int height); /** @brief Sets the current MLT producer playlist. * @param list The xml describing the playlist * @param position (optional) time to seek to */ - int setSceneList(QDomDocument list, int position = 0); + int setSceneList(const QDomDocument &list, int position = 0); /** @brief Sets the current MLT producer playlist. * @param list new playlist @@ -488,7 +494,7 @@ public slots: int getLength(); /** @brief Checks if the file is readable by MLT. */ - bool isValid(KUrl url); + bool isValid(const KUrl &url); void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime); void mltSavePlaylist(); diff --git a/src/videoglwidget.h b/src/videoglwidget.h index c9016e64..99e22e4e 100644 --- a/src/videoglwidget.h +++ b/src/videoglwidget.h @@ -19,14 +19,6 @@ public: m_backgroundColor = color; } -private: - int x, y, w, h; - int m_image_width, m_image_height; - GLuint m_texture; - double m_display_ratio; - QColor m_backgroundColor; - Qt::WindowFlags m_baseFlags; - public slots: void showImage(const QImage &image); @@ -36,6 +28,14 @@ protected: void resizeEvent(QResizeEvent* event); void paintGL(); void mouseDoubleClickEvent(QMouseEvent * event); + +private: + int x, y, w, h; + int m_image_width, m_image_height; + GLuint m_texture; + double m_display_ratio; + QColor m_backgroundColor; + Qt::WindowFlags m_baseFlags; }; #endif -- 2.39.2