[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdereview/mplayerthumbs/src
From:       David Nolden <david.nolden.kde () art-master ! de>
Date:       2009-04-30 11:20:33
Message-ID: 1241090433.823945.30178.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 961560 by zwabel:

Since the video thumbnailer thumbnails a sequence, it should support the ThumbSequenceCreator \
interface added in KDE 4.3. Use the sequence index to iterate through the video using some \
sequence-given bounds, while still keeping the exact used frame random within those bounds.


 M  +28 -5     previewingfile.cpp  
 M  +1 -1      previewingfile.h  
 M  +1 -1      videopreview.cpp  
 M  +2 -2      videopreview.h  


--- trunk/kdereview/mplayerthumbs/src/previewingfile.cpp #961559:961560
@@ -60,18 +60,41 @@
     return false;
 }
 
-Thumbnail* PreviewingFile::getPreview(VideoBackendIFace* videoBackend, uint minVariance, \
unsigned int maxTries) { +float modulo1(float num) {
+    while(num > 1)
+      num -= 1;
+    return num;
+}
+
+Thumbnail* PreviewingFile::getPreview(VideoBackendIFace* videoBackend, uint minVariance, \
unsigned int maxTries, float sequenceIndex) {  kDebug() << "getPreview with minVariance: " << \
minVariance << " and max tries: " << maxTries << endl;  ThumbnailsMap thumbnailsMap;
-  RandomFrameSelector randomFrameSelector(25, 75);
+
+  unsigned int useStart = 25;
+  unsigned int useEnd = 75;
+
+  if(sequenceIndex) {
+    const unsigned int startPercent = 5;
+    const unsigned int endPercent = 85;
+    const unsigned int sequenceLength = 8; //Count of indices needed to iterate through the \
whole video once +
+    //Compute sequence start between 5 and 85%
+    const unsigned int posPercent = (unsigned long)(startPercent+(modulo1((sequenceIndex / \
float(sequenceLength))) * (endPercent-startPercent) ) ); +    //Create random frames within the \
bound of ten percent around the sequence position +    //This means that the first frame is \
between 5% and 15%, the second between 15% and 25%, the third between 25% and 35%, etc. +    \
useStart = posPercent; +    useEnd = posPercent+10;
+  }
+
+  RandomFrameSelector randomFrameSelector(useStart, useEnd);
   PlainFrameSelector plainFrameSelector(10000);
   FrameSelector *frameSelector = &randomFrameSelector;
-  
+
   while(! thumbnailsMap.hasAGoodImageOrSurrenders(minVariance, maxTries)) {
     Thumbnail *currentFrame=videoBackend->preview(frameSelector);
     thumbnailsMap.addThumbnail( currentFrame );
-    kDebug() << "try " << thumbnailsMap.size() << ", image variance: " << \
                currentFrame->getVariance() << endl;;
-    if(thumbnailsMap.size()>=maxTries-1) frameSelector=&plainFrameSelector;
+    kDebug() << "try " << thumbnailsMap.size() << ", image variance: " << \
currentFrame->getVariance() << endl; +    if(thumbnailsMap.size()>=maxTries-1 && \
!sequenceIndex) frameSelector=&plainFrameSelector;  }
   return thumbnailsMap.getBestThumbnail();
 }
--- trunk/kdereview/mplayerthumbs/src/previewingfile.h #961559:961560
@@ -37,7 +37,7 @@
   bool isWide();
   uint getScalingWidth();
   uint getScalingHeight();
-  Thumbnail *getPreview(VideoBackendIFace *videoBackend, uint minVariance, uint maxTries);
+  Thumbnail *getPreview(VideoBackendIFace *videoBackend, uint minVariance, uint maxTries, \
float sequenceIndex);  public slots:
   void setTotalTime(quint64 totalTime);
   void setFPS(uint fps);
--- trunk/kdereview/mplayerthumbs/src/videopreview.cpp #961559:961560
@@ -70,7 +70,7 @@
       kDebug(DBG_AREA) << "cannot preview: " << videoBackend->cannotPreview() << endl;
     }
     
-    Thumbnail *thumbnail=previewingFile->getPreview(videoBackend, 40, 4);
+    Thumbnail *thumbnail=previewingFile->getPreview(videoBackend, 40, 4, sequenceIndex());
     if(!thumbnail || ! thumbnail->imageIsValid() ) return false;
     delete videoBackend;
     kDebug(DBG_AREA) << "got valid thumbnail, image variance: " << thumbnail->getVariance() << \
                endl;
--- trunk/kdereview/mplayerthumbs/src/videopreview.h #961559:961560
@@ -25,7 +25,7 @@
 
 #include <qobject.h>
 #include <qpixmap.h>
-#include <kio/thumbcreator.h>
+#include <kio/thumbsequencecreator.h>
 
 class QProcess;
 class KTempDir;
@@ -33,7 +33,7 @@
 class ServicesFactory;
 class QFileInfo;
 class MPlayerThumbsCfg;
-class VideoPreview : public QObject, public ThumbCreator
+class VideoPreview : public QObject, public ThumbSequenceCreator
 {
 Q_OBJECT
     public:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic