modules/frei0r: added missing producer_frei0r.c
authorblendamedt <blendamedt@d19143bc-622f-0410-bfdd-b5b2a6649095>
Fri, 20 Feb 2009 12:34:57 +0000 (12:34 +0000)
committerblendamedt <blendamedt@d19143bc-622f-0410-bfdd-b5b2a6649095>
Fri, 20 Feb 2009 12:34:57 +0000 (12:34 +0000)
-This line, and those below, will be ignored--

A    producer_frei0r.c

git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1361 d19143bc-622f-0410-bfdd-b5b2a6649095

src/modules/frei0r/producer_frei0r.c [new file with mode: 0644]

diff --git a/src/modules/frei0r/producer_frei0r.c b/src/modules/frei0r/producer_frei0r.c
new file mode 100644 (file)
index 0000000..4f9c3e8
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * producer_frei0r.c -- frei0r producer
+ * Copyright (c) 2009 Jean-Baptiste Mardelle <jb@kdenlive.org>
+ *
+ * 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 <string.h>
+
+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_frei0r", NULL );
+
+       // Obtain properties of producer
+       mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer );
+
+       // Allocate the image
+       int size = *width * ( *height + 1 ) * 2;
+
+       // 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_yuv422;
+       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 );
+               process_frei0r_item( producer_type , position, producer_props, frame , buffer, format , width , height , writable );
+       }
+
+    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_frei0r", 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 );
+}