void KThumb::setProducer(Mlt::Producer *producer)
{
+ m_requestedThumbs.clear();
+ m_future.waitForFinished();
m_producer = producer;
// FIXME: the profile() call leaks an object, but trying to free
// it leads to a double-free in Profile::~Profile()
void KThumb::updateClipUrl(KUrl url, const QString &hash)
{
m_url = url;
- if (m_producer) {
- char *tmp = Render::decodedString(url.path());
- m_producer->set("resource", tmp);
- delete[] tmp;
- }
+ if (m_producer)
+ m_producer->set("resource", url.path().toUtf8().constData());
m_thumbFile = m_clipManager->projectFolder() + "/thumbs/" + hash + ".thumb";
}
void KThumb::doGetThumbs()
{
- const int twidth = (int)(KdenliveSettings::trackheight() * m_dar);
const int theight = KdenliveSettings::trackheight();
+ const int twidth = FRAME_SIZE;//(int)(theight * m_dar + 0.5);
while (!m_requestedThumbs.isEmpty()) {
int frame = m_requestedThumbs.takeFirst();
//static
QPixmap KThumb::getImage(KUrl url, int frame, int width, int height)
{
- char *tmp = Render::decodedString(KdenliveSettings::current_profile());
- Mlt::Profile profile(tmp);
- delete[] tmp;
+ Mlt::Profile profile(KdenliveSettings::current_profile().toUtf8().constData());
QPixmap pix(width, height);
if (url.isEmpty()) return pix;
- tmp = Render::decodedString(url.path());
//"<mlt><playlist><producer resource=\"" + url.path() + "\" /></playlist></mlt>");
//Mlt::Producer producer(profile, "xml-string", tmp);
- Mlt::Producer *producer = new Mlt::Producer(profile, tmp);
- delete[] tmp;
+ Mlt::Producer *producer = new Mlt::Producer(profile, url.path().toUtf8().constData());
pix = QPixmap::fromImage(getFrame(producer, frame, width, height));
delete producer;
//static
QImage KThumb::getFrame(Mlt::Producer *producer, int framepos, int width, int height)
{
- QImage p(width, height, QImage::Format_ARGB32);
+ QImage p(width, height, QImage::Format_ARGB32_Premultiplied);
if (producer == NULL) {
p.fill(Qt::red);
return p;
/*Mlt::Producer parentProd(producer->parent());
Mlt::Service service(parentProd.get_service());
mlt_service_lock(service.get_service());*/
-
+ int ow = width;
+ int oh = height;
mlt_image_format format = mlt_image_rgb24a;
- uint8_t *data = frame->get_image(format, width, height, 0);
- QImage image((uchar *)data, width, height, QImage::Format_ARGB32);
+ uint8_t *data = frame->get_image(format, ow, oh, 0);
+ QImage image((uchar *)data, ow, oh, QImage::Format_ARGB32_Premultiplied);
//mlt_service_unlock(service.get_service());
if (!image.isNull()) {
- p = image.rgbSwapped();
+ if (ow > (2 * width)) {
+ // there was a scaling problem, do it manually
+ QImage scaled = image.scaled(width, height);
+ p = scaled.rgbSwapped();
+ } else p = image.rgbSwapped();
} else
p.fill(Qt::red);
{
if (url.isEmpty()) return;
QPixmap image(width, height);
- char *tmp = KRender::decodedString(url.path());
- Mlt::Producer m_producer(tmp);
- delete tmp;
+ Mlt::Producer m_producer(url.path().toUtf8().constData());
image.fill(Qt::black);
if (m_producer.is_blank()) {
{
if (url.isEmpty()) return;
QPixmap image(width, height);
- char *tmp = KRender::decodedString(url.path());
- Mlt::Producer m_producer(tmp);
- delete tmp;
+ Mlt::Producer m_producer(url.path().toUtf8().constData());
image.fill(Qt::black);
if (m_producer.is_blank()) {
slotAudioThumbOver();
return;
}
+
kDebug() << "reading audio thumbs from file";
+
+ int h1 = arrayWidth * m_channels;
+ int h2 = (int) frame * h1;
+ int h3;
for (int z = (int) frame; z < (int)(frame + frameLength); z++) {
+ h2 += h1;
+ h3 = 0;
for (int c = 0; c < m_channels; c++) {
+ h3 += arrayWidth;
QByteArray m_array(arrayWidth, '\x00');
for (int i = 0; i < arrayWidth; i++)
- m_array[i] = channelarray[z*arrayWidth*m_channels + c*arrayWidth + i];
+ m_array[i] = channelarray[h2 + h3 + i];
storeIn[z][c] = m_array;
}
}