Commit 0c2ea959 authored by Simon Eugster's avatar Simon Eugster

Waveform changes:

* Support for Rec.709 (activated by default)
* New paint mode: White (color neutral)

svn path=/trunk/kdenlive/; revision=4797
parent 3697a1a2
......@@ -27,7 +27,7 @@ WaveformGenerator::~WaveformGenerator()
}
QImage WaveformGenerator::calculateWaveform(const QSize &waveformSize, const QImage &image, WaveformGenerator::PaintMode paintMode,
const bool &drawAxis, const uint &accelFactor)
const bool &drawAxis, WaveformGenerator::Rec rec, const uint &accelFactor)
{
Q_ASSERT(accelFactor >= 1);
......@@ -70,9 +70,14 @@ QImage WaveformGenerator::calculateWaveform(const QSize &waveformSize, const QIm
col = (QRgb *)bits;
// CIE 601 Luminance
if (rec == WaveformGenerator::Rec_601) {
// CIE 601 Luminance
dY = .299*qRed(*col) + .587*qGreen(*col) + .114*qBlue(*col);
} else {
// CIE 709 Luminance
dY = .2125*qRed(*col) + .7154*qGreen(*col) + .0721*qBlue(*col);
}
// dY is on [0,255] now.
dY = .299*qRed(*col) + .587*qGreen(*col) + .114*qBlue(*col);
dy = dY*hPrediv;
dx = x*wPrediv;
......@@ -84,10 +89,14 @@ QImage WaveformGenerator::calculateWaveform(const QSize &waveformSize, const QIm
wave.setPixel(wavePoint, qRgba(CHOP255(9 + qRed(waveCol)), CHOP255(36 + qGreen(waveCol)),
CHOP255(18 + qBlue(waveCol)), 255));
break;
default:
case PaintMode_Yellow:
wave.setPixel(wavePoint, qRgba(255, 242,
0, CHOP255(brightnessAdjustment*10+qAlpha(waveCol))));
break;
default:
wave.setPixel(wavePoint, qRgba(255,255,255,
CHOP255(brightnessAdjustment*32+qAlpha(waveCol))));
break;
}
bits += stepsize;
......
......@@ -20,13 +20,14 @@ class WaveformGenerator : public QObject
Q_OBJECT
public:
enum PaintMode { PaintMode_Green, PaintMode_Yellow };
enum PaintMode { PaintMode_Green, PaintMode_Yellow, PaintMode_White };
enum Rec { Rec_601, Rec_709 };
WaveformGenerator();
~WaveformGenerator();
QImage calculateWaveform(const QSize &waveformSize, const QImage &image, WaveformGenerator::PaintMode paintMode,
const bool &drawAxis, const uint &accelFactor = 1);
const bool &drawAxis, const WaveformGenerator::Rec rec, const uint &accelFactor = 1);
signals:
void signalCalculationFinished(QImage image, const uint &ms);
......
......@@ -28,7 +28,6 @@ Histogram::Histogram(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent
m_aRec601->setCheckable(true);
m_aRec709 = new QAction(i18n("Rec. 709"), this);
m_aRec709->setCheckable(true);
m_agRec = new QActionGroup(this);
m_agRec->addAction(m_aRec601);
m_agRec->addAction(m_aRec709);
......
......@@ -8,10 +8,10 @@
* (at your option) any later version. *
***************************************************************************/
#include <QMenu>
#include <QMouseEvent>
#include <QPainter>
#include <QPoint>
#include <QDebug>
#include "renderer.h"
#include "waveform.h"
......@@ -27,11 +27,27 @@ Waveform::Waveform(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent)
ui->setupUi(this);
ui->paintMode->addItem(i18n("Yellow"), QVariant(WaveformGenerator::PaintMode_Yellow));
ui->paintMode->addItem(i18n("White"), QVariant(WaveformGenerator::PaintMode_White));
ui->paintMode->addItem(i18n("Green"), QVariant(WaveformGenerator::PaintMode_Green));
m_aRec601 = new QAction(i18n("Rec. 601"), this);
m_aRec601->setCheckable(true);
m_aRec709 = new QAction(i18n("Rec. 709"), this);
m_aRec709->setCheckable(true);
m_agRec = new QActionGroup(this);
m_agRec->addAction(m_aRec601);
m_agRec->addAction(m_aRec709);
m_menu->addSeparator()->setText(i18n("Luma mode"));
m_menu->addAction(m_aRec601);
m_menu->addAction(m_aRec709);
bool b = true;
b &= connect(ui->paintMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceUpdateScope()));
b &= connect(this, SIGNAL(signalMousePositionChanged()), this, SLOT(forceUpdateHUD()));
b &= connect(m_aRec601, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
b &= connect(m_aRec709, SIGNAL(toggled(bool)), this, SLOT(forceUpdateScope()));
Q_ASSERT(b);
init();
......@@ -43,6 +59,9 @@ Waveform::~Waveform()
writeConfig();
delete m_waveformGenerator;
delete m_aRec601;
delete m_aRec709;
delete m_agRec;
}
void Waveform::readConfig()
......@@ -52,6 +71,8 @@ void Waveform::readConfig()
KSharedConfigPtr config = KGlobal::config();
KConfigGroup scopeConfig(config, configName());
ui->paintMode->setCurrentIndex(scopeConfig.readEntry("paintmode", 0));
m_aRec601->setChecked(scopeConfig.readEntry("rec601", false));
m_aRec709->setChecked(!m_aRec601->isChecked());
}
void Waveform::writeConfig()
......@@ -59,6 +80,7 @@ void Waveform::writeConfig()
KSharedConfigPtr config = KGlobal::config();
KConfigGroup scopeConfig(config, configName());
scopeConfig.writeEntry("paintmode", ui->paintMode->currentIndex());
scopeConfig.writeEntry("rec601", m_aRec601->isChecked());
scopeConfig.sync();
}
......@@ -110,8 +132,9 @@ QImage Waveform::renderScope(uint accelFactor, QImage qimage)
start.start();
int paintmode = ui->paintMode->itemData(ui->paintMode->currentIndex()).toInt();
WaveformGenerator::Rec rec = m_aRec601->isChecked() ? WaveformGenerator::Rec_601 : WaveformGenerator::Rec_709;
QImage wave = m_waveformGenerator->calculateWaveform(scopeRect().size() - m_textWidth, qimage, (WaveformGenerator::PaintMode) paintmode,
true, accelFactor);
true, rec, accelFactor);
emit signalScopeRenderingFinished(start.elapsed(), 1);
return wave;
......
......@@ -35,6 +35,10 @@ private:
Ui::Waveform_UI *ui;
WaveformGenerator *m_waveformGenerator;
QAction *m_aRec601;
QAction *m_aRec709;
QActionGroup *m_agRec;
static const QSize m_textWidth;
QImage m_waveform;
......
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