From 945cf9233a46d7c47d5030c0efad7561e7245954 Mon Sep 17 00:00:00 2001 From: j-b-m Date: Thu, 10 Jul 2008 13:49:55 +0000 Subject: [PATCH] qimage module: add support for Qt4 (you can force compile against Qt3 with --force-qt3) git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1158 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/modules/qimage/configure | 73 ++++++++++++++++++++++++--------- src/modules/qimage/producer_qimage.c | 4 +- src/modules/qimage/qimage_wrapper.cpp | 37 ++++++++++++++--- src/modules/qimage/qimage_wrapper.h | 4 ++ 4 files changed, 91 insertions(+), 27 deletions(-) diff --git a/src/modules/qimage/configure b/src/modules/qimage/configure index 559404d..bde70b0 100755 --- a/src/modules/qimage/configure +++ b/src/modules/qimage/configure @@ -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" diff --git a/src/modules/qimage/producer_qimage.c b/src/modules/qimage/producer_qimage.c index 6008b7e..70c8d18 100644 --- a/src/modules/qimage/producer_qimage.c +++ b/src/modules/qimage/producer_qimage.c @@ -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 diff --git a/src/modules/qimage/qimage_wrapper.cpp b/src/modules/qimage/qimage_wrapper.cpp index 63cff87..e3b84c9 100644 --- a/src/modules/qimage/qimage_wrapper.cpp +++ b/src/modules/qimage/qimage_wrapper.cpp @@ -22,16 +22,24 @@ */ #include "qimage_wrapper.h" -#include - -#include "config.h" +#ifdef USE_QT3 +#include #ifdef USE_KDE #include #include #endif +#endif + + +#ifdef USE_QT4 +#include +#include +#endif + + #include 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 diff --git a/src/modules/qimage/qimage_wrapper.h b/src/modules/qimage/qimage_wrapper.h index 2136869..a8c5e49 100644 --- a/src/modules/qimage/qimage_wrapper.h +++ b/src/modules/qimage/qimage_wrapper.h @@ -26,6 +26,8 @@ #include +#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 } -- 1.7.4.4