From 80edd2d58253e7dd0734c1416c7ac5115e0ebd4a Mon Sep 17 00:00:00 2001 From: Marco Gittler Date: Sat, 23 Feb 2008 19:29:22 +0000 Subject: [PATCH] enables most parts of audio thumb svn path=/branches/KDE4/; revision=1913 --- src/kthumb.cpp | 73 ++++++++++++++++++++++++++------------------------ src/kthumb.h | 10 +++---- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/src/kthumb.cpp b/src/kthumb.cpp index 663a0eb2..f778a853 100644 --- a/src/kthumb.cpp +++ b/src/kthumb.cpp @@ -33,22 +33,21 @@ #include #include -#include -#include -#include +#include +#include +#include #include "renderer.h" #include "kthumb.h" #include "kdenlivesettings.h" -/* - void MyThread::init(KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth) +void MyThread::init(KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth) { stop_me = false; m_isWorking = false; - f.setName(target); + f.setFileName(target); m_url = url; m_frame = frame; m_frameLength = frameLength; @@ -65,33 +64,33 @@ void MyThread::run() { - if (!f.open( IO_WriteOnly )) { - kdDebug()<<"++++++++ ERROR WRITING TO FILE: "<mainWidget()) + /*TODO if (qApp->mainWidget()) QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(-1, 10005)); - + */ int last_val = 0; int val = 0; for (int z=(int) m_frame;z<(int) (m_frame+m_frameLength) && m_producer.is_valid();z++){ if (stop_me) break; val=(int)((z-m_frame)/(m_frame+m_frameLength)*100.0); if (last_val!=val & val > 1){ - QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(val, 10005)); + //TODO QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(val, 10005)); last_val=val; } m_producer.seek( z ); @@ -105,14 +104,15 @@ int16_t* m_pcm = mlt_frame->get_audio(m_audioFormat, m_frequency, m_channels, m_samples ); for (int c=0;c< m_channels;c++){ - QByteArray m_array(m_arrayWidth); + QByteArray m_array; + m_array.resize(m_arrayWidth); for (uint i = 0; i < m_array.size(); i++){ - m_array[i] = QABS((*( m_pcm + c + i * m_samples / m_array.size() ))>>8); + m_array[i] = qAbs((*( m_pcm + c + i * m_samples / m_array.size() ))>>8); } - f.writeBlock(m_array); + f.write(m_array); } } else{ - f.writeBlock(QByteArray(m_arrayWidth)); + f.write(QByteArray(m_arrayWidth,'\x00')); } if (mlt_frame) delete mlt_frame; @@ -121,9 +121,9 @@ m_isWorking = false; if (stop_me) { f.remove(); - QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(-1, 10005)); + //TODO QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(-1, 10005)); } - else QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(0, 10005)); + //TODO else QApplication::postEvent(qApp->mainWidget(), new ProgressEvent(0, 10005)); } @@ -131,7 +131,7 @@ #define _R(y,u,v) (0x2568*(y) + 0x3343*(u)) /0x2000 #define _G(y,u,v) (0x2568*(y) - 0x0c92*(v) - 0x1a1e*(u)) /0x2000 #define _B(y,u,v) (0x2568*(y) + 0x40cf*(v)) /0x2000 -*/ + KThumb::KThumb(KUrl url, int width, int height, QObject * parent, const char *name):QObject(parent), m_url(url), m_width(width), m_height(height) { kDebug()<<"+++++++++++ CREATING THMB PROD FOR: "<