]> git.sesse.net Git - kdenlive/commitdiff
scale thumbnail before converting it to rgb
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 17 Jun 2008 22:37:17 +0000 (22:37 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 17 Jun 2008 22:37:17 +0000 (22:37 +0000)
svn path=/branches/KDE4/; revision=2255

src/kthumb.cpp
src/projectlist.cpp
src/renderer.cpp
src/renderer.h

index 948affe7aad8cb3a3bbffd601f094ee060d42caa..d1da86307bd3cad4b07656a92a1612aae0769af2 100644 (file)
@@ -230,6 +230,9 @@ QPixmap KThumb::getFrame(Mlt::Producer* producer, int framepos, int width, int h
     uint8_t* data;
     int frame_width = 0;
     int frame_height = 0;
+       //frame->set("rescale.interp", "nearest");
+       frame->set("normalised_height", height);
+       frame->set("normalised_width", width);
     mlt_frame_get_image(frame->get_frame(), &data, &format, &frame_width, &frame_height, 0);
     QPixmap pix(width, height);
     uint8_t *new_image = (uint8_t *)mlt_pool_alloc(frame_width * (frame_height + 1) * 4);
@@ -237,8 +240,9 @@ QPixmap KThumb::getFrame(Mlt::Producer* producer, int framepos, int width, int h
     QImage image((uchar *)new_image, frame_width, frame_height, QImage::Format_ARGB32);
 
     if (!image.isNull()) {
-        QImage scale = image.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation).rgbSwapped();
-        pix = pix.fromImage(scale);
+        //QImage scale = image.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation).rgbSwapped();
+               image = image.rgbSwapped();
+        pix = pix.fromImage(image);
     } else pix.fill(Qt::black);
        mlt_pool_release(new_image);
     if (frame) delete frame;
index 51429e4446e58194f702bd3c6bb326b19abc537d..ea95c5aea73b571512ccba80501a99378e0b3aa3 100644 (file)
@@ -444,8 +444,8 @@ void ProjectList::slotRefreshClipThumbnail(int clipId) {
 
 void ProjectList::slotRefreshClipThumbnail(ProjectItem *item) {
     if (item) {
-        int height = 40;
-        int width = (int)(height  * (double) m_render->renderWidth() / m_render->renderHeight());
+               int height = 50;
+               int width = (int)(height  * m_render->dar());
         QPixmap pix = KThumb::getImage(item->toXml(), item->referencedClip()->getProjectThumbFrame(), width, height);
         //QPixmap pix = KThumb::getFrame(item->toXml()), 0, width, height);
         item->setIcon(0, pix);
index 1334f826cf03bdd9fa183fc3a949a53deeab2b77..343092fd1ee44a6a4132a475ca898efb8ef87a7d 100644 (file)
@@ -378,6 +378,10 @@ bool Render::isValid(KUrl url) {
     return true;
 }
 
+const double Render::dar() const {
+       return m_mltProfile->dar();
+}
+
 void Render::getFileProperties(const QDomElement &xml, int clipId) {
     int height = 50;
     int width = (int)(height  * m_mltProfile->dar());
@@ -394,6 +398,10 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
     Mlt::Producer producer(*m_mltProfile, "westley-xml", tmp);
     delete[] tmp;
 
+/*     Mlt::Filter filter(*m_mltProfile, "rescale");
+       producer.attach(filter);*/
+    //mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_fezzik", 1 );
+
     if (producer.is_blank()) {
         return;
     }
@@ -408,8 +416,6 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
     //kDebug() << "///////  PRODUCER: " << url.path() << " IS: " << producer.get_playtime();
 
     Mlt::Frame * frame = producer.get_frame();
-    //frame->set("rescale", "nearest");
-    //filePropertyMap["fps"] = QString::number(mlt_producer_get_fps(producer.get_producer()));
     filePropertyMap["fps"] = producer.get("source_fps");
 
     if (frame && frame->is_valid()) {
@@ -431,16 +437,19 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) {
             uint8_t* data;
             int frame_width = 0;
             int frame_height = 0;
+                       //frame->set("rescale.interp", "hyper");
+                       frame->set("normalised_height", height);
+                       frame->set("normalised_width", width);
             mlt_frame_get_image(frame->get_frame(), &data, &format, &frame_width, &frame_height, 0);
-
+                       //kDebug()<<"/// GOT TUMB, SIZE: "<<frame_width<<"x"<<frame_height;
             QPixmap pix(width, height);
             uint8_t *new_image = (uint8_t *)mlt_pool_alloc(frame_width * (frame_height + 1) * 4);
             mlt_convert_yuv422_to_rgb24a((uint8_t *)data, new_image, frame_width * frame_height);
             QImage image((uchar *)new_image, frame_width, frame_height, QImage::Format_ARGB32);
 
             if (!image.isNull()) {
-                QImage scale = image.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation).rgbSwapped();
-                pix = pix.fromImage(scale);
+                image = image.rgbSwapped();// = image.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation).rgbSwapped();
+                pix = pix.fromImage(image);
             } else pix.fill(Qt::black);
                        mlt_pool_release(new_image);
             emit replyGetImage(clipId, 0, pix, width, height);
index 8696fc6589e08e6d88b83a2aa7f4f8f44e7e086d..e04c66a8767c32d58265c6bb2139d19a05a5f219 100644 (file)
@@ -145,6 +145,8 @@ Q_OBJECT public:
     const double fps() const;
     const int renderWidth() const;
     const int renderHeight() const;
+       /** get display aspect ratio */
+    const double dar() const;
 
     /** Playlist manipulation */
     void mltInsertClip(int track, GenTime position, QDomElement element);