]> git.sesse.net Git - kdenlive/blobdiff - thumbnailer/westleypreview.cpp
small cleanup
[kdenlive] / thumbnailer / westleypreview.cpp
index 0ce57323a73c33d150f113c8d74724ca8ff211f2..a68787526576115daa26996ed70062aeb002f6b1 100644 (file)
@@ -126,17 +126,18 @@ uint MltPreview::imageVariance(QImage image)
     uint STEPS = bytes / 2;
     QVarLengthArray<uchar> pivot(STEPS);
     kDebug(DBG_AREA) << "Using " << STEPS << " steps\n";
-    uchar *bits = image.bits();
+    const uchar *bits=image.bits();
     // First pass: get pivots and taking average
-    for (uint i = 0; i < STEPS ; i++) {
-        pivot[i] = bits[i*(bytes/STEPS)];
-        avg += pivot[i];
+    for( uint i=0; i<STEPS ; i++ ){
+        pivot[i] = bits[2 * i];
+        avg+=pivot.at(i);
     }
-    avg = avg / STEPS;
+    avg=avg/STEPS;
     // Second Step: calculate delta (average?)
-    for (uint i = 0; i < STEPS; i++) {
-        int curdelta = abs(int(avg - pivot[i]));
-        delta += curdelta;
+    for (uint i=0; i<STEPS; i++)
+    {
+        int curdelta=abs(int(avg - pivot.at(i)));
+        delta+=curdelta;
     }
     return delta / STEPS;
 }