1 /***************************************************************************
4 begin : Fri Nov 22 2002
5 copyright : (C) 2002 by Jason Wood
6 email : jasonwood@blueyonder.co.uk
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
23 #include <QDomElement>
27 #include <kdeversion.h>
29 #include <mlt++/Mlt.h>
32 /**KRender encapsulates the client side of the interface to a renderer.
33 From Kdenlive's point of view, you treat the KRender object as the
34 renderer, and simply use it as if it was local. Calls are asyncrhonous -
35 you send a call out, and then receive the return value through the
36 relevant signal that get's emitted once the call completes.
52 typedef QMap <int, QMap <int, QByteArray> > audioByteArray;
54 class KThumb: public QObject
59 KThumb(ClipManager *clipManager, KUrl url, const QString &id, const QString &hash, QObject * parent = 0);
61 void setProducer(Mlt::Producer *producer);
62 bool hasProducer() const;
64 void updateThumbUrl(const QString &hash);
65 void extractImage(QList <int> frames);
66 QImage extractImage(int frame, int width, int height);
67 #if KDE_IS_VERSION(4,5,0)
68 /** @brief Request thumbnails for the frame range. */
69 void queryIntraThumbs(QList <int> missingFrames);
70 /** @brief Query cached thumbnail. */
71 QImage findCachedThumb(const QString &path);
73 void getThumb(int frame);
76 void updateClipUrl(KUrl url, const QString &hash);
77 static QPixmap getImage(KUrl url, int width, int height);
78 // static QPixmap getImage(QDomElement xml, int frame, int width, int height);
79 /* void getImage(KUrl url, int frame, int width, int height);
80 void getThumbs(KUrl url, int startframe, int endframe, int width, int height);*/
81 void slotCreateAudioThumbs();
82 static QPixmap getImage(KUrl url, int frame, int width, int height);
83 static QImage getFrame(Mlt::Producer *producer, int framepos, int frameWidth, int displayWidth, int height);
84 static QImage getFrame(Mlt::Frame *frame, int frameWidth, int displayWidth, int height);
85 /** @brief Calculates image variance, useful to know if a thumbnail is interesting.
86 * @return an integer between 0 and 100. 0 means no variance, eg. black image while bigger values mean contrasted image
88 static uint imageVariance(QImage image);
91 #if KDE_IS_VERSION(4,5,0)
92 /** @brief Fetch all requested frames. */
93 void slotGetIntraThumbs();
101 Mlt::Producer *m_producer;
102 ClipManager *m_clipManager;
104 /** @brief Controls the intra frames thumbnails process (cached thumbnails). */
105 QFuture<void> m_intra;
106 /** @brief List of frame numbers from which we want to extract thumbnails. */
107 QList <int> m_intraFramesQueue;
109 QImage getProducerFrame(int framepos, int frameWidth, int displayWidth, int height);
112 void thumbReady(int, QImage);
113 void mainThumbReady(const QString &, QPixmap);
114 void audioThumbReady(const audioByteArray&);
115 /** @brief We have finished caching all requested thumbs. */