]> git.sesse.net Git - kdenlive/commitdiff
audio thumb should now work for whole video, but disabled because of undefined crash...
authorMarco Gittler <marco@gitma.de>
Sun, 24 Feb 2008 12:12:39 +0000 (12:12 +0000)
committerMarco Gittler <marco@gitma.de>
Sun, 24 Feb 2008 12:12:39 +0000 (12:12 +0000)
svn path=/branches/KDE4/; revision=1918

src/clipitem.cpp
src/docclipbase.cpp
src/kthumb.cpp

index 1cf8ea44c802e1247539537af54c0e5c0a4f6481..0f78a45abcd91754503712c5a30dd06d7981965e 100644 (file)
@@ -220,22 +220,41 @@ int ClipItem::endPos()
                 QPainterPath path= m_clipType==AV ? roundRectPathLower : roundRectPathUpper.united(roundRectPathLower);
                 painter->fillPath(path,QBrush(QColor(200,200,200,127)));
                 //for test 
+                double pixelForOneFrame=(double)br.width()/duration();
                 int channels=2;
-                kDebug() << "audioframes=" << baseClip()->audioFrameChache.size();
-                for (int frame=0;frame<10 && frame+1< baseClip()->audioFrameChache.size();frame++){
-                       QRectF re=path.boundingRect();
-                        
-                        QMap<int,QByteArray> frame_channel_data=baseClip()->audioFrameChache[frame];
-                        kDebug() << "size=" <<frame_channel_data.size()  << " " << frame_channel_data[0].size();;
-                        int audio_frame_samples=frame_channel_data[0].size();
-                        for (int samples=0;samples<audio_frame_samples/*AUDIO_FRAME_SIZE*/;samples++){
-                               for (int channel=0;channel<channels && frame_channel_data[channel].size()> 0;channel++){
-                                
+
+                /*for (int frame=m_cropStart;frame<m_cropStart+m_cropDuration && frame< baseClip()->audioFrameChache.size();frame++){
+                       
+                       QMap<int,QByteArray> frame_channel_data=baseClip()->audioFrameChache[frame];
+                       int audio_frame_samples=frame_channel_data[0].size();
+                       
+                       for (int samples=0;samples<audio_frame_samples;samples++){
+                               
+                               for (int channel=0;channel<channels && frame_channel_data[channel].size()> 0;channel++){
                                        int y=re.y()+re.height()*channel/channels+ (re.height()/channels)/2;
-                                       painter->drawLine(re.x() + frame*audio_frame_samples+samples  , y+frame_channel_data[channel][0], re.x() +frame*audio_frame_samples+samples+1 /*+ re.width()*/, y+frame_channel_data[channel][0] );
+                                       int x1=re.x() + ((double)frame*pixelForOneFrame*audio_frame_samples+samples)/pixelForOneFrame;
+                                       kDebug() <<" frame " << frame   << " " << x1 ;
+                                       painter->drawLine(x1 , y+frame_channel_data[channel][0],x1+1, y+frame_channel_data[channel][0] );
                                }
-                        }
-                }
+                       }
+        }*/
+               QRectF re=path.boundingRect();
+               for (int samples=re.x();samples<re.x()+re.width();samples++){
+                       double frame=(double)(samples-re.x())/pixelForOneFrame;
+                       int sample=(frame-(int)(frame))*20 ;// AUDIO_FRAME_SIZE
+                       
+                       if (frame<0 || sample< 0 || sample>19 )
+                               continue;
+                       QMap<int,QByteArray> frame_channel_data=baseClip()->audioFrameChache[(int)frame];
+                       
+                       for (int channel=0;channel<channels && frame_channel_data[channel].size()> 0;channel++){
+                               
+                               int y=re.y()+re.height()*channel/channels+ (re.height()/channels)/2;
+                               painter->drawLine(samples , y+frame_channel_data[channel][sample],samples+1, y+frame_channel_data[channel][sample] );
+                               //painter->drawLine(samples , y+samples-10,samples+1, y+samples-10 );
+                               
+                       }
+               }
         }
     // draw start / end fades
     double scale = br.width() / m_cropDuration;
index 874a385bc434a2235110c9a852d95aee18d2bdb0..a1cf7b20569b4b4a0dc191500f8d1e46a3f1dd57 100644 (file)
@@ -42,7 +42,8 @@ m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0),
        if (m_clipType == AV || m_clipType==AUDIO ||m_clipType==UNKNOWN){
                m_audioTimer = new QTimer( this );
                connect(m_audioTimer, SIGNAL(timeout()), this, SLOT(slotGetAudioThumbs()));
-               emit getAudioThumbs();
+               //TODO disabled until the crash cause is found 
+               //emit getAudioThumbs();
        }
 }
 
@@ -408,6 +409,7 @@ void DocClipBase::slotGetAudioThumbs(){
                double lengthInFrames=duration().frames(/*framesPerSecond()*/25);
                m_thumbProd->getAudioThumbs(fileURL(), 1, 0, 10 /*must be number of frames*/, 20);
                
+               
        }
 }
 
index 42313c44a1806b6052971e23d934fb949458f571..9657399170c2ba4c3a9b7de3ca6e34ad3b8a3287 100644 (file)
@@ -330,7 +330,7 @@ void KThumb::getAudioThumbs(KUrl url, int channel, double frame, double frameLen
        //FIXME: Hardcoded!!! 
        int m_frequency = 48000;
        int m_channels = channel;
-       
+
        m_thumbFile="/tmp/testfile";
        /*FIXME WHY crash here ??????
        if (m_url != url) {
@@ -351,11 +351,10 @@ void KThumb::getAudioThumbs(KUrl url, int channel, double frame, double frameLen
                        f.remove();
                        return;
                }
-               
+               kDebug() << "reading audio thumbs from file";
                for (int z=(int) frame;z<(int) (frame+frameLength);z++) {
                        for (int c=0;c< m_channels;c++){
-                               QByteArray m_array;
-                               m_array.resize(arrayWidth);
+                               QByteArray m_array(arrayWidth,'\x00');
                                for (int i = 0; i < arrayWidth; i++)
                                        m_array[i] = channelarray[z*arrayWidth*m_channels + c*arrayWidth + i];
                                storeIn[z][c] = m_array;
@@ -364,9 +363,10 @@ void KThumb::getAudioThumbs(KUrl url, int channel, double frame, double frameLen
                emit audioThumbReady(storeIn);
        }
        else {
-               if (thumbProducer.isRunning()) return;
+               /*if (thumbProducer.isRunning()) return;
                thumbProducer.init(m_url, m_thumbFile, frame, frameLength, m_frequency, m_channels, arrayWidth);
                thumbProducer.start(QThread::LowestPriority );
+               */
        }
 }