Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Minor optimizations

parent 904824cc
......@@ -86,6 +86,7 @@ void MixerManager::registerTrack(int tid, std::shared_ptr<Mlt::Tractor> service,
mixer->connectMixer(true);
}
connect(this, &MixerManager::updateLevels, mixer.get(), &MixerWidget::updateAudioLevel);
connect(this, &MixerManager::clearMixers, mixer.get(), &MixerWidget::clear);
connect(mixer.get(), &MixerWidget::toggleSolo, [&](int trid, bool solo) {
if (!solo) {
// unmute
......@@ -124,17 +125,6 @@ void MixerManager::deregisterTrack(int tid)
m_mixers.erase(tid);
}
void MixerManager::resetAudioValues()
{
qDebug()<<"======\n\nRESTTING AUDIO VALUES\n\n------------------_";
for (auto item : m_mixers) {
item.second.get()->clear();
}
if (m_masterMixer) {
m_masterMixer->clear();
}
}
void MixerManager::cleanup()
{
for (auto item : m_mixers) {
......@@ -174,6 +164,7 @@ void MixerManager::setModel(std::shared_ptr<TimelineItemModel> model)
m_masterMixer->connectMixer(true);
}
connect(this, &MixerManager::updateLevels, m_masterMixer.get(), &MixerWidget::updateAudioLevel);
connect(this, &MixerManager::clearMixers, m_masterMixer.get(), &MixerWidget::clear);
m_masterBox->addWidget(m_masterMixer.get());
collapseMixers();
}
......
......@@ -54,7 +54,6 @@ public:
void collapseMixers();
public slots:
void resetAudioValues();
void recordStateChanged(int tid, bool recording);
private slots:
......@@ -64,6 +63,7 @@ signals:
void updateLevels(int);
void recordAudio(int tid);
void purgeCache();
void clearMixers();
protected:
std::unordered_map<int, std::shared_ptr<MixerWidget>> m_mixers;
......
......@@ -772,6 +772,7 @@ std::shared_ptr<Mlt::Producer> ProjectClip::cloneProducer(bool removeEffects)
if (strcmp(prod->get("mlt_service"), "avformat") == 0) {
prod->set("mlt_service", "avformat-novalidate");
prod->set("mute_on_pause", 0);
}
// we pass some properties that wouldn't be passed because of the novalidate
......@@ -830,6 +831,7 @@ std::shared_ptr<Mlt::Producer> ProjectClip::cloneProducer(const std::shared_ptr<
std::shared_ptr<Mlt::Producer> prod(new Mlt::Producer(*producer->profile(), "xml-string", clipXml.constData()));
if (strcmp(prod->get("mlt_service"), "avformat") == 0) {
prod->set("mlt_service", "avformat-novalidate");
prod->set("mute_on_pause", 0);
}
return prod;
}
......
......@@ -175,7 +175,7 @@ void Core::initGUI(const QUrl &Url)
connect(this, &Core::updateLibraryPath, m_library, &LibraryWidget::slotUpdateLibraryPath);
connect(m_capture.get(), &MediaCapture::recordStateChanged, m_mixerWidget, &MixerManager::recordStateChanged);
m_monitorManager = new MonitorManager(this);
connect(m_monitorManager, &MonitorManager::cleanMixer, m_mixerWidget, &MixerManager::resetAudioValues);
connect(m_monitorManager, &MonitorManager::cleanMixer, m_mixerWidget, &MixerManager::clearMixers);
// Producer queue, creating MLT::Producers on request
/*
m_producerQueue = new ProducerQueue(m_binController);
......
......@@ -53,6 +53,16 @@
#include <QUrl> //new
#include <klocalizedstring.h>
#ifdef Q_OS_WIN
extern "C"
{
// Inform the driver we could make use of the discrete gpu
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
int main(int argc, char *argv[])
{
#ifdef USE_DRMINGW
......@@ -63,6 +73,7 @@ int main(int argc, char *argv[])
Logger::init();
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
//TODO: is it a good option ?
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
......
......@@ -219,6 +219,7 @@ void ClipController::getInfoForProducer()
}
if (m_service == QLatin1String("avformat")) {
m_properties->set("mlt_service", "avformat-novalidate");
m_properties->set("mute_on_pause", 0);
}
}
} else if (m_service == QLatin1String("qimage") || m_service == QLatin1String("pixbuf")) {
......
......@@ -90,6 +90,9 @@ GLWidget::GLWidget(int id, QObject *parent)
, m_texCoordLocation(0)
, m_colorspaceLocation(0)
, m_zoom(1.0f)
, m_profileSize(1920, 1080)
, m_colorSpace(601)
, m_dar(1.78)
, m_sendFrame(false)
, m_isZoneMode(false)
, m_isLoopMode(false)
......@@ -122,7 +125,7 @@ GLWidget::GLWidget(int id, QObject *parent)
m_refreshTimer.setSingleShot(true);
m_refreshTimer.setInterval(50);
m_blackClip.reset(new Mlt::Producer(pCore->getCurrentProfile()->profile(), "color:black"));
m_blackClip.reset(new Mlt::Producer(pCore->getCurrentProfile()->profile(), "color:0"));
m_blackClip->set("kdenlive:id", "black");
m_blackClip->set("out", 3);
connect(&m_refreshTimer, &QTimer::timeout, this, &GLWidget::refresh);
......@@ -213,8 +216,6 @@ void GLWidget::initializeGL()
m_frameRenderer->sendAudioForAnalysis = KdenliveSettings::monitor_audio();
openglContext()->makeCurrent(this);
// openglContext()->blockSignals(false);
connect(m_frameRenderer, &FrameRenderer::frameDisplayed, this, &GLWidget::frameDisplayed, Qt::QueuedConnection);
connect(m_frameRenderer, &FrameRenderer::textureReady, this, &GLWidget::updateTexture, Qt::DirectConnection);
connect(m_frameRenderer, &FrameRenderer::frameDisplayed, this, &GLWidget::onFrameDisplayed, Qt::QueuedConnection);
......@@ -229,29 +230,28 @@ void GLWidget::resizeGL(int width, int height)
int x, y, w, h;
height -= m_rulerHeight;
double this_aspect = (double)width / height;
double video_aspect = pCore->getCurrentProfile()->dar();
// Special case optimization to negate odd effect of sample aspect ratio
// not corresponding exactly with image resolution.
if ((int)(this_aspect * 1000) == (int)(video_aspect * 1000)) {
if ((int)(this_aspect * 1000) == (int)(m_dar * 1000)) {
w = width;
h = height;
}
// Use OpenGL to normalise sample aspect ratio
else if (height * video_aspect > width) {
else if (height * m_dar > width) {
w = width;
h = width / video_aspect;
h = width / m_dar;
} else {
w = height * video_aspect;
w = height * m_dar;
h = height;
}
x = (width - w) / 2;
y = (height - h) / 2;
m_rect.setRect(x, y, w, h);
double scalex = (double)m_rect.width() / pCore->getCurrentProfile()->width() * m_zoom;
double scalex = (double)m_rect.width() / m_profileSize.width() * m_zoom;
double scaley = (double)m_rect.width() /
((double)pCore->getCurrentProfile()->height() * pCore->getCurrentProfile()->dar() / pCore->getCurrentProfile()->width()) /
pCore->getCurrentProfile()->width() * m_zoom;
((double)m_profileSize.height() * m_dar / m_profileSize.width()) /
m_profileSize.width() * m_zoom;
QPoint center = m_rect.center();
QQuickItem *rootQml = rootObject();
if (rootQml) {
......@@ -448,7 +448,7 @@ void GLWidget::bindShaderProgram()
m_shader->setUniformValue(m_textureLocation[0], 0);
m_shader->setUniformValue(m_textureLocation[1], 1);
m_shader->setUniformValue(m_textureLocation[2], 2);
m_shader->setUniformValue(m_colorspaceLocation, pCore->getCurrentProfile()->colorspace());
m_shader->setUniformValue(m_colorspaceLocation, m_colorSpace);
}
}
......@@ -588,17 +588,15 @@ void GLWidget::paintGL()
if (m_sendFrame && m_analyseSem.tryAcquire(1)) {
// Render RGB frame for analysis
int fullWidth = pCore->getCurrentProfile()->width();
int fullHeight = pCore->getCurrentProfile()->height();
if ((m_fbo == nullptr) || m_fbo->size() != QSize(fullWidth, fullHeight)) {
if ((m_fbo == nullptr) || m_fbo->size() != m_profileSize) {
delete m_fbo;
QOpenGLFramebufferObjectFormat fmt;
fmt.setSamples(1);
fmt.setInternalTextureFormat(GL_RGB); // GL_RGBA32F); // which one is the fastest ?
m_fbo = new QOpenGLFramebufferObject(fullWidth, fullHeight, fmt); // GL_TEXTURE_2D);
m_fbo = new QOpenGLFramebufferObject(m_profileSize.height(), m_profileSize.height(), fmt); // GL_TEXTURE_2D);
}
m_fbo->bind();
glViewport(0, 0, fullWidth, fullHeight);
glViewport(0, 0, m_profileSize.width(), m_profileSize.height());
QMatrix4x4 projection2;
projection2.scale(2.0f / (float)width, 2.0f / (float)height);
......@@ -1093,7 +1091,7 @@ int GLWidget::reconfigure(bool reload)
// use SDL for audio, OpenGL for video
QString serviceName = property("mlt_service").toString();
if (reload) {
m_blackClip.reset(new Mlt::Producer(pCore->getCurrentProfile()->profile(), "color:black"));
m_blackClip.reset(new Mlt::Producer(pCore->getCurrentProfile()->profile(), "color:0"));
m_blackClip->set("kdenlive:id", "black");
reloadProfile();
return error;
......@@ -1114,6 +1112,9 @@ int GLWidget::reconfigure(bool reload)
if (KdenliveSettings::external_display()) {
m_consumer->set("terminate_on_pause", 0);
}
m_profileSize = pCore->getCurrentFrameSize();
m_colorSpace = pCore->getCurrentProfile()->colorspace();
m_dar = pCore->getCurrentDar();
} else {
// Warning, audio backend unavailable on system
m_consumer.reset();
......@@ -1190,7 +1191,6 @@ int GLWidget::reconfigure(bool reload)
m_displayEvent = m_consumer->listen("consumer-frame-show", this, (mlt_listener)on_audio_frame_show);
m_sharedFrame = SharedFrame();
m_texture[0] = 0;
} else if (m_glslManager) {
m_displayEvent = m_consumer->listen("consumer-frame-show", this, (mlt_listener)on_gl_frame_show);
} else {
......@@ -1245,11 +1245,6 @@ float GLWidget::zoom() const
return m_zoom;
}
float GLWidget::scale() const
{
return (double)m_rect.width() / pCore->getCurrentProfile()->width() * m_zoom;
}
void GLWidget::reloadProfile()
{
// The profile display aspect ratio may have changed.
......@@ -1266,7 +1261,7 @@ void GLWidget::reloadProfile()
QSize GLWidget::profileSize() const
{
return {pCore->getCurrentProfile()->width(), pCore->getCurrentProfile()->height()};
return m_profileSize;
}
QRect GLWidget::displayRect() const
......@@ -1276,8 +1271,8 @@ QRect GLWidget::displayRect() const
QPoint GLWidget::offset() const
{
return {m_offset.x() - ((int)((float)pCore->getCurrentProfile()->width() * m_zoom) - width()) / 2,
m_offset.y() - ((int)((float)pCore->getCurrentProfile()->height() * m_zoom) - height()) / 2};
return {m_offset.x() - ((int)((float)m_profileSize.width() * m_zoom) - width()) / 2,
m_offset.y() - ((int)((float)m_profileSize.height() * m_zoom) - height()) / 2};
}
void GLWidget::setZoom(float zoom)
......@@ -1302,6 +1297,7 @@ void GLWidget::onFrameDisplayed(const SharedFrame &frame)
m_sendFrame = sendFrameForAnalysis;
m_contextSharedAccess.unlock();
update();
emit frameDisplayed(frame);
}
void GLWidget::mouseReleaseEvent(QMouseEvent *event)
......@@ -1677,12 +1673,12 @@ void GLWidget::refreshSceneLayout()
if (!rootObject()) {
return;
}
rootObject()->setProperty("profile", QPoint(pCore->getCurrentProfile()->width(), pCore->getCurrentProfile()->height()));
rootObject()->setProperty("profile", QPoint(m_profileSize.width(), m_profileSize.height()));
rootObject()->setProperty("scalex", (double)m_rect.width() / pCore->getCurrentProfile()->width() * m_zoom);
rootObject()->setProperty("scaley",
(double)m_rect.width() /
(((double)pCore->getCurrentProfile()->height() * pCore->getCurrentProfile()->dar() / pCore->getCurrentProfile()->width())) /
pCore->getCurrentProfile()->width() * m_zoom);
(((double)m_profileSize.height() * m_dar / m_profileSize.width())) /
m_profileSize.width() * m_zoom);
}
void GLWidget::switchPlay(bool play, double speed)
......
......@@ -99,7 +99,6 @@ public:
QRect rect() const { return m_rect; }
QRect effectRect() const { return m_effectRect; }
float zoom() const;
float scale() const;
QPoint offset() const;
std::shared_ptr<Mlt::Consumer> consumer();
Mlt::Producer *producer();
......@@ -223,6 +222,9 @@ private:
int m_textureLocation[3];
QTimer m_refreshTimer;
float m_zoom;
QSize m_profileSize;
int m_colorSpace;
double m_dar;
bool m_sendFrame;
bool m_isZoneMode;
bool m_isLoopMode;
......
......@@ -184,7 +184,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
m_horizontalScroll->hide();
connect(m_horizontalScroll, &QAbstractSlider::valueChanged, this, &Monitor::setOffsetX);
connect(m_verticalScroll, &QAbstractSlider::valueChanged, this, &Monitor::setOffsetY);
connect(m_glMonitor, &GLWidget::frameDisplayed, this, &Monitor::onFrameDisplayed);
connect(m_glMonitor, &GLWidget::frameDisplayed, this, &Monitor::onFrameDisplayed, Qt::DirectConnection);
connect(m_glMonitor, &GLWidget::mouseSeek, this, &Monitor::slotMouseSeek);
connect(m_glMonitor, &GLWidget::monitorPlay, this, &Monitor::slotPlay);
connect(m_glMonitor, &GLWidget::startDrag, this, &Monitor::slotStartDrag);
......@@ -1648,10 +1648,10 @@ void Monitor::updateAudioForAnalysis()
void Monitor::onFrameDisplayed(const SharedFrame &frame)
{
m_monitorManager->frameDisplayed(frame);
if (!m_glMonitor->checkFrameNumber(frame.get_position(), m_id == Kdenlive::ClipMonitor ? 0 : TimelineModel::seekDuration)) {
m_playAction->setActive(false);
}
m_monitorManager->frameDisplayed(frame);
checkDrops(m_glMonitor->droppedFrames());
}
......
......@@ -113,7 +113,6 @@ std::unique_ptr<ProfileModel> &ProfileRepository::getProfile(const QString &path
}
return m_profiles.at(default_profile);
}
return m_profiles.at(path);
}
......
......@@ -111,7 +111,7 @@ TimelineModel::TimelineModel(Mlt::Profile *profile, std::weak_ptr<DocUndoStack>
, m_snaps(new SnapModel())
, m_undoStack(std::move(undo_stack))
, m_profile(profile)
, m_blackClip(new Mlt::Producer(*profile, "color:black"))
, m_blackClip(new Mlt::Producer(*profile, "color:0"))
, m_lock(QReadWriteLock::Recursive)
, m_timelineEffectsEnabled(true)
, m_id(getNextId())
......@@ -126,6 +126,7 @@ TimelineModel::TimelineModel(Mlt::Profile *profile, std::weak_ptr<DocUndoStack>
m_blackClip->set("mlt_type", "producer");
m_blackClip->set("aspect_ratio", 1);
m_blackClip->set("length", INT_MAX);
m_blackClip->set("mlt_image_format", "rgb24a");
m_blackClip->set("set.test_audio", 0);
m_blackClip->set_in_and_out(0, TimelineModel::seekDuration);
m_tractor->insert_track(*m_blackClip, 0);
......
......@@ -661,6 +661,7 @@ void PreviewManager::reloadChunks(const QVariantList chunks)
if (prod.is_valid()) {
// m_ruler->updatePreview(ix, true);
prod.set("mlt_service", "avformat-novalidate");
prod.set("mute_on_pause", 1);
m_previewTrack->insert_at(ix.toInt(), &prod, 1);
}
}
......@@ -695,6 +696,7 @@ void PreviewManager::gotPreviewRender(int frame, const QString &file, int progre
m_renderedChunks << frame;
m_controller->renderedChunksChanged();
prod.set("mlt_service", "avformat-novalidate");
prod.set("mute_on_pause", 1);
qDebug() << "|||| PLUGGING PREVIEW CHUNK AT: " << frame;
m_tractor->lock();
m_previewTrack->insert_at(frame, &prod, 1);
......
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