]> git.sesse.net Git - mlt/commitdiff
qimage module: add support for Qt4 (you can force compile against Qt3 with --force...
authorj-b-m <j-b-m@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 10 Jul 2008 13:49:55 +0000 (13:49 +0000)
committerj-b-m <j-b-m@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 10 Jul 2008 13:49:55 +0000 (13:49 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1158 d19143bc-622f-0410-bfdd-b5b2a6649095

src/modules/qimage/configure
src/modules/qimage/producer_qimage.c
src/modules/qimage/qimage_wrapper.cpp
src/modules/qimage/qimage_wrapper.h

index 559404da603ad47611fb91c50278bf8f53de0c15..bde70b02ede1bd8b1bb19f49de6d7519c04b8196 100755 (executable)
@@ -5,8 +5,9 @@ then
        cat << EOF
 QImage options:
 
-  --qimage-libdir         - Location of QT lib directory [/usr/lib/qt3]
-  --qimage-includedir     - Location of QT include directory [/usr/include/qt3]
+  --force-qt3            - Force compile against Qt3 if Qt4 is present on the system
+  --qimage-libdir         - Location of QT lib directory [/usr/lib/qt4 or /usr/lib/qt3]
+  --qimage-includedir     - Location of QT include directory [/usr/include/qt4 or /usr/include/qt3]
   --kde-libdir            - Location of KDE lib directory [/usr/lib]
   --kde-includedir        - Location of KDE include directory [/usr/include/kde]
 
@@ -28,11 +29,21 @@ else
                ;;
        esac
 
-       qimage_includedir=/usr/include/qt3
-       qimage_libdir=/usr/lib/qt3
+       qimage_includedir=/usr/include/qt4
+       qimage_libdir=/usr/lib/qt4
 
-       kde_includedir=/usr/include/kde
-       kde_libdir=/usr/lib
+       if [ -d "$qimage_libdir" -a -d "$qimage_includedir" ]
+       then
+               qimage_includedir=/usr/include/qt3
+               qimage_libdir=/usr/lib/qt3
+               kde_includedir=/usr/include/kde
+               kde_libdir=/usr/lib
+               if [ "$KDEDIR" != "" ]
+               then
+                       kde_includedir="$KDEDIR/include"
+                       kde_libdir="$KDEDIR"
+               fi
+       fi
 
        if [ "$QTDIR" != "" ]
        then
@@ -40,11 +51,8 @@ else
                qimage_libdir="$QTDIR"
        fi
 
-       if [ "$KDEDIR" != "" ]
-       then
-               kde_includedir="$KDEDIR/include"
-               kde_libdir="$KDEDIR"
-       fi
+       export force_qt3=
+       export qt4_found=
 
        for i in "$@"
        do
@@ -53,23 +61,48 @@ else
                        --qimage-includedir=* ) qimage_includedir="${i#--qimage-includedir=}" ;;
                        --kde-libdir=* )        kde_libdir="${i#--kde-libdir=}" ;;
                        --kde-includedir=* )    kde_includedir="${i#--kde-includedir=}" ;;
+                       --force-qt3 )           force_qt3="true" ;;
                esac
        done
 
        if [ -d "$qimage_libdir" -a -d "$qimage_includedir" ]
        then
+
+               # test if we have a Qt3 or Qt4
+               if test -f $QTDIR/lib/libQtCore.so && [ "$force_qt3" = "" ]
+               then
+                       echo "Qt version 4.x detected, will compile Qt4 qimage producer"
+                       qt4_found=true
+               else
+                       echo "Qt version 3.x detected, will compile Qt3 qimage producer"
+               fi
+
+               echo "Include directory: " $qimage_includedir
+
                echo > config.h
                echo > config.mak
-               if [ -d "$kde_includedir" ]
-               then 
-                       echo "#define USE_KDE" >> config.h
-                       echo "USE_KDE=1" >> config.mak
-                       echo QTCXXFLAGS=-I$qimage_includedir -I$kde_includedir >> config.mak
-                       echo QTLIBS=-L$qimage_libdir/lib -L$kde_libdir/lib -lqt-mt >> config.mak
-               else 
-                       echo "qimage: KDE environment not found - disabling extra image formats"
+               if [ "$qt4_found" != "" ] && [ "$force_qt3" = "" ]
+               then
+                       echo "#define USE_QT4" >> config.h
+                       echo "USE_QT4=1" >> config.mak
                        echo QTCXXFLAGS=-I$qimage_includedir >> config.mak
-                       echo QTLIBS=-L$qimage_libdir/lib -lqt-mt >> config.mak
+                       echo QTLIBS=-L$qimage_libdir/lib -lQtGui >> config.mak
+               else 
+                   if [ -d "$kde_includedir" ]
+                   then 
+                           echo "#define USE_KDE" >> config.h
+                           echo "USE_KDE=1" >> config.mak
+                           echo "#define USE_QT3" >> config.h
+                           echo "USE_QT3=1" >> config.mak
+                           echo QTCXXFLAGS=-I$qimage_includedir -I$kde_includedir >> config.mak
+                           echo QTLIBS=-L$qimage_libdir/lib -L$kde_libdir/lib -lqt-mt >> config.mak
+                   else 
+                           echo "qimage: KDE environment not found - disabling extra image formats"
+                           echo "#define USE_QT3" >> config.h
+                           echo "USE_QT3=1" >> config.mak
+                           echo QTCXXFLAGS=-I$qimage_includedir >> config.mak
+                           echo QTLIBS=-L$qimage_libdir/lib -lqt-mt >> config.mak
+                   fi
                fi
        else
                echo "qimage: QT environment not found - disabling"
index 6008b7e6ef53fb663bd3194d053516d0ace84d2f..70c8d18e3cbe6fd7af6eae3081e7d93bc2c35944 100644 (file)
@@ -46,7 +46,9 @@ mlt_producer producer_qimage_init( mlt_profile profile, mlt_service_type type, c
                mlt_properties properties = MLT_PRODUCER_PROPERTIES( &this->parent );
        
                // Callback registration
+#ifdef USE_KDE
                init_qimage();
+#endif
                producer->get_frame = producer_get_frame;
                producer->close = ( mlt_destructor )producer_close;
 
@@ -210,7 +212,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                                if ( stat( full, &buf ) == 0 )
                                {
                                        sprintf( key, "%d", keyvalue ++ );
-                                       mlt_properties_set( this->filenames, "0", full );
+                                       mlt_properties_set( this->filenames, key, full );
                                        gap = 0;
                                }
                                else
index 63cff87bf87a950a675a01e6f6be58677af8a7c6..e3b84c92bfc69289ddbba423d406e07047db8307 100644 (file)
  */
 
 #include "qimage_wrapper.h"
-#include <qimage.h>
-
 
-#include "config.h"
+#ifdef USE_QT3
+#include <qimage.h>
 
 #ifdef USE_KDE
 #include <kinstance.h>
 #include <kimageio.h>
 #endif
 
+#endif
+
+
+#ifdef USE_QT4
+#include <QtGui/QImage>
+#include <QtCore/QSysInfo>
+#endif
+
+
 #include <cmath>
 
 extern "C" {
@@ -74,15 +82,15 @@ static void assign_buffered_image( mlt_properties producer_props, uint8_t *curre
        mlt_events_unblock( producer_props, NULL );
 }
 
+#ifdef USE_KDE
 void init_qimage()
 {
-#ifdef USE_KDE
        if (!instance) {
            instance = new KInstance("qimage_prod");
            KImageIO::registerFormats();
        }
-#endif
 }
+#endif
 
 void refresh_qimage( mlt_frame frame, int width, int height )
 {
@@ -117,6 +125,7 @@ void refresh_qimage( mlt_frame frame, int width, int height )
 
        // Get the original position of this frame
        mlt_position position = mlt_properties_get_position( properties, "qimage_position" );
+       position += mlt_producer_get_in( producer );
 
        // Image index
        int image_idx = ( int )floor( ( double )position / ttl ) % self->count;
@@ -205,9 +214,17 @@ void refresh_qimage( mlt_frame frame, int width, int height )
                else if ( strcmp( interps, "hyper" ) == 0 )
                        interp = 1;
 
+#ifdef USE_QT4
+               // Note - the original qimage is already safe and ready for destruction
+               QImage scaled = interp == 0 ? qimage->scaled( QSize( width, height)) : qimage->scaled( QSize(width, height), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+               QImage temp = scaled.convertToFormat(QImage::Format_ARGB32);
+#endif
+
+#ifdef USE_QT3
                // Note - the original qimage is already safe and ready for destruction
                QImage scaled = interp == 0 ? qimage->scale( width, height, QImage::ScaleFree ) : qimage->smoothScale( width, height, QImage::ScaleFree );
                QImage temp = scaled.convertDepth( 32 );
+#endif
 
                // Store width and height
                current_width = width;
@@ -219,12 +236,20 @@ void refresh_qimage( mlt_frame frame, int width, int height )
                // Allocate the alpha mask
                current_alpha = ( uint8_t * )mlt_pool_alloc( current_width * current_height );
 
+#ifdef USE_QT4
+               if ( QSysInfo::ByteOrder == QSysInfo::BigEndian )
+                       mlt_convert_argb_to_yuv422( temp.bits( ), current_width, current_height, temp.bytesPerLine( ), current_image, current_alpha );
+               else
+                       mlt_convert_bgr24a_to_yuv422( temp.bits( ), current_width, current_height, temp.bytesPerLine( ), current_image, current_alpha );
+#endif
+
+#ifdef USE_QT3
                // Convert the image
                if ( QImage::systemByteOrder( ) == QImage::BigEndian )
                        mlt_convert_argb_to_yuv422( temp.bits( ), current_width, current_height, temp.bytesPerLine( ), current_image, current_alpha );
                else
                        mlt_convert_bgr24a_to_yuv422( temp.bits( ), current_width, current_height, temp.bytesPerLine( ), current_image, current_alpha );
-
+#endif
                assign_buffered_image( producer_props, current_image, current_alpha, current_width, current_height );
 
                // Ensure we update the cache when we need to
index 21368694ff0d532b136f7bb92cb8ccdbc8d3aac2..a8c5e493f5437d1d2e415be257127b6838e7ab3a 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <framework/mlt.h>
 
+#include "config.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -41,7 +43,9 @@ struct producer_qimage_s
 typedef struct producer_qimage_s *producer_qimage;
 
 extern void refresh_qimage( mlt_frame, int width, int height );
+#ifdef USE_KDE
 extern void init_qimage();
+#endif
 
 #ifdef __cplusplus
 }