]> git.sesse.net Git - mlt/commitdiff
first work on kdenlive title producer
authorMarco Gittler <g.marco@freenet.de>
Fri, 10 Jul 2009 17:04:25 +0000 (19:04 +0200)
committerMarco Gittler <g.marco@freenet.de>
Fri, 10 Jul 2009 17:04:25 +0000 (19:04 +0200)
should later read the xml-file from kdenlive
and let the title have scroll and zoom

src/modules/qimage/Makefile
src/modules/qimage/factory.c
src/modules/qimage/kdenlivetitle_wrapper.cpp [new file with mode: 0644]
src/modules/qimage/kdenlivetitle_wrapper.h [new file with mode: 0644]
src/modules/qimage/producer_kdenlivetitle.c [new file with mode: 0644]

index ad3e4fa55604fb2236618d7f8002f65039fbd3f3..d2d7dd8a343894c1b443da9716c1c5d0f8a4a0f5 100644 (file)
@@ -3,8 +3,8 @@ include config.mak
 
 TARGET = ../libmltqimage$(LIBSUF)
 
-OBJS = factory.o producer_qimage.o
-CPPOBJS = qimage_wrapper.o
+OBJS = factory.o producer_qimage.o producer_kdenlivetitle.o
+CPPOBJS = qimage_wrapper.o kdenlivetitle_wrapper.o
 
 CFLAGS += -I../..
 CXXFLAGS += $(CFLAGS) $(QTCXXFLAGS) -Wno-deprecated
index 61cb0ec0ee25a9040a0db607e0d77a194fbf4dd3..fdcec3644558611cb129d3d7cd2a2d346ea0cc74 100644 (file)
@@ -22,8 +22,9 @@
 #include <framework/mlt.h>
 
 extern mlt_producer producer_qimage_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
+extern mlt_producer producer_kdenlivetitle_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg );
 
 MLT_REPOSITORY
 {
-       MLT_REGISTER( producer_type, "qimage", producer_qimage_init );
+       MLT_REGISTER( producer_type, "kdenlivetitle", producer_kdenlivetitle_init );
 }
diff --git a/src/modules/qimage/kdenlivetitle_wrapper.cpp b/src/modules/qimage/kdenlivetitle_wrapper.cpp
new file mode 100644 (file)
index 0000000..f7d6beb
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * kdenlivetitle_wrapper.cpp -- kdenlivetitle wrapper
+ * Copyright (c) 2009 Marco Gittler <g.marco@freenet.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <QtGui/QImage>
+#include <QtGui/QPainter>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
+#include "kdenlivetitle_wrapper.h"
+#include <framework/mlt_producer.h>
+extern "C" {
+void init_qt (const char* c){
+    titleclass=new Title(QString(c));
+}
+void refresh_kdenlivetitle( void* buffer, int width, int height , double position){
+   titleclass->drawKdenliveTitle(buffer,width,height,position);
+}
+}
+Title::Title(const QString& filename){
+    int argc=0;
+    char* argv[1];
+    argv[0]=0; 
+    app=new QCoreApplication(argc,argv);
+}
+void Title::drawKdenliveTitle(void * buffer ,int width,int height,double position){
+    //qDebug() << "ja" << width << height << buffer << position << endl;
+    QImage img((uchar*)buffer,width,height,width*4,QImage::Format_ARGB32);
+    img.fill(0x22);
+    QPainter p;
+    p.begin(&img);
+    p.setFont(QFont("Arial",40));
+    p.setPen(QPen(QColor(255,255,255)));
+    p.drawText(width*.2+width*20*position,height/2,"test");
+    p.end();
+}
diff --git a/src/modules/qimage/kdenlivetitle_wrapper.h b/src/modules/qimage/kdenlivetitle_wrapper.h
new file mode 100644 (file)
index 0000000..dd7690a
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * kdenlivetitle_wrapper.h -- kdenlivetitle wrapper
+ * Copyright (c) 2009 Marco Gittler <g.marco@freenet.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <QtCore/QObject>
+#include <framework/mlt_frame.h>
+class QCoreApplication;
+class QObject;
+class Title;
+QCoreApplication *app;
+Title* titleclass;
+
+class Title: public QObject {
+
+    public:
+            Title(const QString &);
+            void drawKdenliveTitle(void*,int,int,double);
+};
diff --git a/src/modules/qimage/producer_kdenlivetitle.c b/src/modules/qimage/producer_kdenlivetitle.c
new file mode 100644 (file)
index 0000000..f20e03d
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * producer_kdenlivetitle.c -- kdenlive producer
+ * Copyright (c) 2009 Marco Gittler <g.marco@freenet.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <framework/mlt.h>
+//#include "frei0r_helper.h"
+#include <stdlib.h>
+#include <string.h>
+//#include <QtCore/QCoreApplication>
+//#include <QtGui/QImage>
+extern init_qt();
+extern refresh_kdenlivetitle(void*,int,int,double);
+
+static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable )
+{
+       
+       // Obtain properties of frame
+       mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
+
+       // Obtain the producer for this frame
+       mlt_producer producer = mlt_properties_get_data( properties, "producer_kdenlivetitle", NULL );
+
+       // Obtain properties of producer
+       mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer );
+
+       // Allocate the image
+       int size = *width * ( *height + 1 ) * 4;
+
+       // Allocate the image
+       *buffer = mlt_pool_alloc( size );
+
+       // Update the frame
+       mlt_properties_set_data( properties, "image", *buffer, size, mlt_pool_release, NULL );
+       mlt_properties_set_int( properties, "width", *width );
+       mlt_properties_set_int( properties, "height", *height );
+
+       *format = mlt_image_rgb24a;
+       if ( *buffer != NULL )
+       {
+               mlt_position in = mlt_producer_get_in( producer );
+               mlt_position out = mlt_producer_get_out( producer );
+               mlt_position time = mlt_frame_get_position( frame );
+               double position = ( double )( time - in ) / ( double )( out - in + 1 );
+        refresh_kdenlivetitle(*buffer,*width,*height,position);
+       }
+
+    return 0;
+}
+
+int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index )
+{
+       // Generate a frame
+       *frame = mlt_frame_init( MLT_PRODUCER_SERVICE( producer ) );
+
+       if ( *frame != NULL )
+       {
+               // Obtain properties of frame and producer
+               mlt_properties properties = MLT_FRAME_PROPERTIES( *frame );
+
+               // Obtain properties of producer
+               mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer );
+
+               // Set the producer on the frame properties
+               mlt_properties_set_data( properties, "producer_kdenlivetitle", producer, 0, NULL, NULL );
+
+               // Update timecode on the frame we're creating
+               mlt_frame_set_position( *frame, mlt_producer_position( producer ) );
+
+               // Set producer-specific frame properties
+               mlt_properties_set_int( properties, "progressive", 1 );
+               mlt_properties_set_double( properties, "aspect_ratio", mlt_properties_get_double( producer_props, "aspect_ratio" ) );
+
+               // Push the get_image method
+               mlt_frame_push_get_image( *frame, producer_get_image );
+       }
+
+       // Calculate the next timecode
+       mlt_producer_prepare_next( producer );
+
+       return 0;
+}
+
+void producer_close( mlt_producer producer )
+{
+       producer->close = NULL;
+       mlt_producer_close( producer );
+       free( producer );
+}
+mlt_producer producer_kdenlivetitle_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
+{
+   // Create a new producer object
+   mlt_producer this = mlt_producer_new( );
+
+   // Initialise the producer
+   if ( this != NULL )
+   {
+      // Callback registration
+      this->get_frame = producer_get_frame;
+      this->close = ( mlt_destructor )producer_close;
+   }
+    init_qt();
+   return this;
+}
+