+bool Vectorscope::prodCalcThread()
+{
+ if (m_scopeCalcThread.isRunning()) {
+ qDebug() << "Calc thread still running.";
+ return false;
+ } else {
+ // See http://doc.qt.nokia.com/latest/qtconcurrentrun.html#run about
+ // running member functions in a thread
+ qDebug() << "Calc thread not running anymore, finished: " << m_scopeCalcThread.isFinished() << ", Starting new thread";
+ m_scopeCalcThread = QtConcurrent::run(this, &Vectorscope::calculateScope);
+ return true;
+ }
+}
+
+void Vectorscope::calculateScope()
+{
+ // Prepare the vectorscope data
+ QImage scope(cw, cw, QImage::Format_ARGB32);
+ scope.fill(qRgba(0,0,0,0));
+
+ QImage img(m_activeRender->extractFrame(m_activeRender->seekFramePosition()));
+ newFrames.fetchAndStoreRelease(0); // Reset number of new frames, as we just got the newest
+ uchar *bits = img.bits();
+
+ int r,g,b;
+ double dy, dr, dg, db, dmax;
+ double y,u,v;
+ QPoint pt;
+ QRgb px;
+
+ for (int i = 0; i < img.byteCount(); i+= 4) {
+ QRgb *col = (QRgb *) bits;
+
+ r = qRed(*col);
+ g = qGreen(*col);
+ b = qBlue(*col);
+
+ y = (double) 0.001173 * r + 0.002302 * g + 0.0004471 * b;
+ u = (double) -0.0005781*r -0.001135*g +0.001713*b;
+ v = (double) 0.002411*r -0.002019*g -0.0003921*b;
+
+ pt = mapToCanvas(QRect(QPoint(0,0), scope.size()), QPointF(SCALING*scaling*u, SCALING*scaling*v));
+
+ if (!(pt.x() <= scopeRect.width() && pt.x() >= 0
+ && pt.y() <= scopeRect.height() && pt.y() >= 0)) {
+ // Point lies outside (because of scaling), don't plot it
+ continue;
+ }
+
+ // Draw the pixel using the chosen draw mode
+ switch (iPaintMode) {
+ case CHROMA:
+ dy = 200;
+ dr = dy + 290.8*v;
+ dg = dy - 100.6*u - 148*v;
+ db = dy + 517.2*u;
+
+ dmax = dr;
+ if (dg > dmax) dmax = dg;
+ if (db > dmax) dmax = db;
+ dmax = 255/dmax;
+
+ dr *= dmax;
+ dg *= dmax;
+ db *= dmax;
+
+ scope.setPixel(pt, qRgba(dr, dg, db, 255));
+ break;
+ case ORIG:
+ scope.setPixel(pt, *col);
+ break;
+ case GREEN:
+ px = scope.pixel(pt);
+ scope.setPixel(pt, qRgba(qRed(px)+(255-qRed(px))/40, 255, qBlue(px)+(255-qBlue(px))/40, qAlpha(px)+(255-qAlpha(px))/20));
+ break;
+ }
+
+ bits += 4;
+ }
+
+ m_scope = scope;
+
+ qDebug() << "Scope rendered";
+ emit signalScopeCalculationFinished();
+}
+
+void Vectorscope::updateDimensions()