Refactor drop fps calculation, cleanup monitor markers & fps overlay

parent d5251aa2
data/pics/splash-background.png

163 KB | W: | H:

data/pics/splash-background.png

449 KB | W: | H:

data/pics/splash-background.png
data/pics/splash-background.png
data/pics/splash-background.png
data/pics/splash-background.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -426,6 +426,11 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
// Load monitor overlay qml
loadQmlScene(MonitorSceneDefault);
// Monitor dropped fps timer
m_droppedTimer.setInterval(1000);
m_droppedTimer.setSingleShot(false);
connect(&m_droppedTimer, &QTimer::timeout, this, &Monitor::checkDrops);
// Info message widget
m_infoMessage = new KMessageWidget(this);
layout->addWidget(m_infoMessage);
......@@ -1343,6 +1348,18 @@ void Monitor::slotSwitchPlay()
{
slotActivateMonitor();
m_glMonitor->switchPlay(m_playAction->isActive());
bool showDropped;
if (m_id == Kdenlive::ClipMonitor) {
showDropped = KdenliveSettings::displayClipMonitorInfo() & 0x20;
} else {
showDropped = KdenliveSettings::displayProjectMonitorInfo() & 0x20;
}
if (showDropped) {
m_glMonitor->resetDrops();
m_droppedTimer.start();
} else {
m_droppedTimer.stop();
}
resetSpeedInfo();
}
......@@ -1726,31 +1743,20 @@ void Monitor::onFrameDisplayed(const SharedFrame &frame)
m_playAction->setActive(false);
}
m_monitorManager->frameDisplayed(frame);
checkDrops(m_glMonitor->droppedFrames());
}
void Monitor::checkDrops(int dropped)
void Monitor::checkDrops()
{
if (m_droppedTimer.isValid()) {
if (m_droppedTimer.hasExpired(1000)) {
m_droppedTimer.invalidate();
double fps = pCore->getCurrentFps();
if (dropped == 0) {
// No dropped frames since last check
m_qmlManager->setProperty(QStringLiteral("dropped"), false);
m_qmlManager->setProperty(QStringLiteral("fps"), QString::number(fps, 'g', 2));
} else {
m_glMonitor->resetDrops();
fps -= dropped;
m_qmlManager->setProperty(QStringLiteral("dropped"), true);
m_qmlManager->setProperty(QStringLiteral("fps"), QString::number(fps, 'g', 2));
m_droppedTimer.start();
}
}
} else if (dropped > 0) {
// Start m_dropTimer
int dropped = m_glMonitor->droppedFrames();
if (dropped == 0) {
// No dropped frames since last check
m_qmlManager->setProperty(QStringLiteral("dropped"), false);
m_qmlManager->setProperty(QStringLiteral("fps"), QString::number(pCore->getCurrentFps(), 'g', 2));
} else {
m_glMonitor->resetDrops();
m_droppedTimer.start();
dropped = pCore->getCurrentFps() - dropped;
m_qmlManager->setProperty(QStringLiteral("dropped"), true);
m_qmlManager->setProperty(QStringLiteral("fps"), QString::number(dropped, 'g', 2));
}
}
......@@ -2093,9 +2099,18 @@ void Monitor::updateQmlDisplay(int currentOverlay)
{
m_glMonitor->rootObject()->setVisible((currentOverlay & 0x01) != 0);
m_glMonitor->rootObject()->setProperty("showMarkers", currentOverlay & 0x04);
m_glMonitor->rootObject()->setProperty("showFps", currentOverlay & 0x20);
bool showDropped = currentOverlay & 0x20;
m_glMonitor->rootObject()->setProperty("showFps", showDropped);
m_glMonitor->rootObject()->setProperty("showTimecode", currentOverlay & 0x02);
m_glMonitor->rootObject()->setProperty("showAudiothumb", currentOverlay & 0x10);
if (showDropped) {
if (!m_droppedTimer.isActive() && m_playAction->isActive()) {
m_glMonitor->resetDrops();
m_droppedTimer.start();
}
} else {
m_droppedTimer.stop();
}
}
void Monitor::clearDisplay()
......
......@@ -27,7 +27,7 @@
#include "scopes/sharedframe.h"
#include "timecodedisplay.h"
#include <QElapsedTimer>
#include <QTimer>
#include <QToolBar>
#include <memory>
......@@ -217,7 +217,7 @@ private:
int m_offset;
MonitorSceneType m_lastMonitorSceneType;
MonitorAudioLevel *m_audioMeterWidget;
QElapsedTimer m_droppedTimer;
QTimer m_droppedTimer;
double m_displayedFps;
QLabel *m_scalingLabel;
QLabel *m_speedLabel;
......@@ -226,8 +226,6 @@ private:
void adjustScrollBars(float horizontal, float vertical);
void loadQmlScene(MonitorSceneType type);
void updateQmlDisplay(int currentOverlay);
/** @brief Check and display dropped frames */
void checkDrops(int dropped);
/** @brief Create temporary Mlt::Tractor holding a clip and it's effectless clone */
void buildSplitEffect(Mlt::Producer *original);
/** @brief Reset and hide speed info label */
......@@ -271,6 +269,8 @@ private slots:
void removeSnapPoint(int pos);
/** @brief Pause monitor and process seek */
void processSeek(int pos);
/** @brief Check and display dropped frames */
void checkDrops();
public slots:
void slotSetScreen(int screenIndex);
......
......@@ -223,8 +223,7 @@ Item {
anchors {
right: parent.right
bottom: parent.bottom
bottomMargin: (audioThumb.stateVisible && !audioThumb.isAudioClip) ? audioThumb.height : 0
rightMargin: 4
bottomMargin: (audioThumb.stateVisible && !audioThumb.isAudioClip && audioThumb.visible) ? audioThumb.height : 0
}
}
Label {
......@@ -235,15 +234,14 @@ Item {
color: "#ffffff"
padding: 2
background: Rectangle {
color: root.dropped ? "#99ff0000" : "#66000000"
color: root.dropped ? "#99ff0000" : "#66004400"
}
text: i18n("%1 fps", root.fps)
text: i18n("%1fps", root.fps)
visible: root.showFps
anchors {
right: timecode.visible ? timecode.left : parent.right
bottom: parent.bottom
bottomMargin: (audioThumb.stateVisible && !audioThumb.isAudioClip) ? audioThumb.height : 0
rightMargin: timecode.visible ? 0 : 4
}
}
Label {
......@@ -259,16 +257,8 @@ Item {
background: Rectangle {
color: "#228b22"
}
height: marker.height
width: textMetricsIn.width + 10
leftPadding:0
rightPadding:0
padding:4
horizontalAlignment: TextInput.AlignHCenter
TextMetrics {
id: textMetricsIn
font: inPoint.font
text: inPoint.text
}
}
Label {
id: outPoint
......@@ -283,22 +273,15 @@ Item {
background: Rectangle {
color: "#ff4500"
}
width: textMetricsOut.width + 10
height: marker.height
leftPadding:0
rightPadding:0
padding: 4
horizontalAlignment: TextInput.AlignHCenter
TextMetrics {
id: textMetricsOut
font: outPoint.font
text: outPoint.text
}
}
TextField {
id: marker
font: fixedFont
objectName: "markertext"
activeFocusOnPress: true
text: controller.markerComment
onEditingFinished: {
root.markerText = marker.displayText
marker.focus = false
......@@ -309,20 +292,14 @@ Item {
bottom: parent.bottom
}
visible: root.showMarkers && text != ""
text: controller.markerComment
width: textMetrics.width + 10
horizontalAlignment: TextInput.AlignHCenter
height: inPoint.height
width: fontMetrics.boundingRect(displayText).width + 10
horizontalAlignment: displayText == text ? TextInput.AlignHCenter : TextInput.AlignLeft
background: Rectangle {
color: "#990000ff"
}
color: "white"
padding:0
TextMetrics {
id: textMetrics
font: marker.font
text: controller.markerComment
}
color: "#ffffff"
padding: 0
maximumLength: 20
}
}
......@@ -330,7 +307,7 @@ Item {
Rectangle {
// Audio or video only drag zone
x: 2
y: inPoint.visible ? inPoint.y - height - 2 : parent.height - height - 2
y: inPoint.visible || outPoint.visible || marker.visible ? parent.height - inPoint.height - height - 2 : parent.height - height - 2
width: childrenRect.width
height: childrenRect.height
color: Qt.rgba(activePalette.highlight.r, activePalette.highlight.g, activePalette.highlight.b, 0.7)
......
......@@ -131,7 +131,6 @@ Item {
anchors {
right: parent.right
bottom: parent.bottom
rightMargin: 4
}
}
Label {
......@@ -142,14 +141,13 @@ Item {
color: "#ffffff"
padding: 2
background: Rectangle {
color: root.dropped ? "#99ff0000" : "#66000000"
color: root.dropped ? "#99ff0000" : "#66004400"
}
text: i18n("%1 fps", root.fps)
text: i18n("%1fps", root.fps)
visible: root.showFps
anchors {
right: timecode.visible ? timecode.left : parent.right
bottom: parent.bottom
rightMargin: timecode.visible ? 0 : 4
}
}
Label {
......@@ -165,16 +163,8 @@ Item {
background: Rectangle {
color: "#228b22"
}
height: marker.height
width: textMetricsIn.width + 10
leftPadding:0
rightPadding:0
padding: 5
horizontalAlignment: TextInput.AlignHCenter
TextMetrics {
id: textMetricsIn
font: inPoint.font
text: inPoint.text
}
}
Label {
id: outPoint
......@@ -189,16 +179,8 @@ Item {
background: Rectangle {
color: "#ff4500"
}
width: textMetricsOut.width + 10
height: marker.height
leftPadding:0
rightPadding:0
padding: 5
horizontalAlignment: TextInput.AlignHCenter
TextMetrics {
id: textMetricsOut
font: outPoint.font
text: outPoint.text
}
}
TextField {
id: marker
......@@ -216,19 +198,14 @@ Item {
}
visible: root.showMarkers && text != ""
text: controller.markerComment
width: textMetrics.width + 10
horizontalAlignment: TextInput.AlignHCenter
height: inPoint.height
width: fontMetrics.boundingRect(displayText).width + 10
horizontalAlignment: displayText == text ? TextInput.AlignHCenter : TextInput.AlignLeft
background: Rectangle {
color: "#990000ff"
}
color: "white"
padding:0
TextMetrics {
id: textMetrics
font: marker.font
text: controller.markerComment
}
color: "#ffffff"
padding: 0
maximumLength: 25
}
}
......
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