]> git.sesse.net Git - kdenlive/blobdiff - thumbnailer/westleypreview.cpp
Merge branch 'master' of git://anongit.kde.org/kdenlive
[kdenlive] / thumbnailer / westleypreview.cpp
index a68787526576115daa26996ed70062aeb002f6b1..91132787f6cef51f6431a56404eba5fbc70a346e 100644 (file)
@@ -123,6 +123,7 @@ uint MltPreview::imageVariance(QImage image)
     uint delta = 0;
     uint avg = 0;
     uint bytes = image.numBytes();
+    if (bytes == 0) return 0;
     uint STEPS = bytes / 2;
     QVarLengthArray<uchar> pivot(STEPS);
     kDebug(DBG_AREA) << "Using " << STEPS << " steps\n";
@@ -130,13 +131,21 @@ uint MltPreview::imageVariance(QImage image)
     // First pass: get pivots and taking average
     for( uint i=0; i<STEPS ; i++ ){
         pivot[i] = bits[2 * i];
+#if QT_VERSION >= 0x040700
         avg+=pivot.at(i);
+#else
+        avg+=pivot[i];
+#endif
     }
     avg=avg/STEPS;
     // Second Step: calculate delta (average?)
     for (uint i=0; i<STEPS; i++)
     {
+#if QT_VERSION >= 0x040700
         int curdelta=abs(int(avg - pivot.at(i)));
+#else
+        int curdelta=abs(int(avg - pivot[i]));
+#endif
         delta+=curdelta;
     }
     return delta / STEPS;