]> git.sesse.net Git - kdenlive/blobdiff - src/colorcorrection/vectorscopegenerator.cpp
Const'ref
[kdenlive] / src / colorcorrection / vectorscopegenerator.cpp
index 9f3a9bd1f7f40e0896ccd414b8da36866a8d40f9..480286f800bc4f4148d3e39870a682df60ea0a04 100644 (file)
@@ -118,7 +118,7 @@ QPoint VectorscopeGenerator::mapToCircle(const QSize &targetSize, const QPointF
 QImage VectorscopeGenerator::calculateVectorscope(const QSize &vectorscopeSize, const QImage &image, const float &gain,
                                                   const VectorscopeGenerator::PaintMode &paintMode,
                                                   const VectorscopeGenerator::ColorSpace &colorSpace,
-                                                  const bool &, const uint &accelFactor) const
+                                                  bool, uint accelFactor) const
 {
     if (vectorscopeSize.width() <= 0 || vectorscopeSize.height() <= 0 || image.width() <= 0 || image.height() <= 0) {
         // Invalid size
@@ -134,15 +134,15 @@ QImage VectorscopeGenerator::calculateVectorscope(const QSize &vectorscopeSize,
 
     int r,g,b;
     double dy, dr, dg, db, dmax;
-    double y,u,v;
+    double /*y,*/ u, v;
     QPoint pt;
     QRgb px;
 
-    const int stepsize = 4*accelFactor;
+    const int stepsize = image.depth() / 8 * accelFactor;
 
     // Just an average for the number of image pixels per scope pixel.
     // NOTE: byteCount() has to be replaced by (img.bytesPerLine()*img.height()) for Qt 4.5 to compile, see: http://doc.trolltech.org/4.6/qimage.html#bytesPerLine
-    double avgPxPerPx = (double) 4*(image.bytesPerLine()*image.height())/scope.size().width()/scope.size().height()/accelFactor;
+    double avgPxPerPx = (double) image.depth() / 8 *(image.bytesPerLine()*image.height())/scope.size().width()/scope.size().height()/accelFactor;
 
     for (int i = 0; i < (image.bytesPerLine()*image.height()); i+= stepsize) {
         QRgb *col = (QRgb *) bits;
@@ -153,12 +153,13 @@ QImage VectorscopeGenerator::calculateVectorscope(const QSize &vectorscopeSize,
 
         switch (colorSpace) {
         case VectorscopeGenerator::ColorSpace_YUV:
-            y = (double)  0.001173 * r +0.002302 * g +0.0004471* b;
+//             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;
             break;
         case VectorscopeGenerator::ColorSpace_YPbPr:
-            y = (double)  0.001173 * r +0.002302 * g +0.0004471* b;
+        default:
+//             y = (double)  0.001173 * r +0.002302 * g +0.0004471* b;
             u = (double) -0.0006671* r -0.001299 * g +0.0019608* b;
             v = (double)  0.001961 * r -0.001642 * g -0.0003189* b;
             break;
@@ -187,6 +188,7 @@ QImage VectorscopeGenerator::calculateVectorscope(const QSize &vectorscopeSize,
                     db = dy + 517.2*u;
                     break;
                 case VectorscopeGenerator::ColorSpace_YPbPr:
+                default:
                     dr = dy + 357.5*v;
                     dg = dy - 87.75*u - 182*v;
                     db = dy + 451.9*u;
@@ -215,6 +217,7 @@ QImage VectorscopeGenerator::calculateVectorscope(const QSize &vectorscopeSize,
                     db = dy + 517.2*u;
                     break;
                 case VectorscopeGenerator::ColorSpace_YPbPr:
+                default:
                     dr = dy + 357.5*v;
                     dg = dy - 87.75*u - 182*v;
                     db = dy + 451.9*u;
@@ -257,3 +260,5 @@ QImage VectorscopeGenerator::calculateVectorscope(const QSize &vectorscopeSize,
     }
     return scope;
 }
+
+#include "vectorscopegenerator.moc"