]> git.sesse.net Git - mlt/commitdiff
watermark added, minor mods to mlt framework required
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 24 Feb 2004 11:16:51 +0000 (11:16 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 24 Feb 2004 11:16:51 +0000 (11:16 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@166 d19143bc-622f-0410-bfdd-b5b2a6649095

15 files changed:
docs/services.txt
src/framework/mlt_frame.c
src/framework/mlt_producer.h
src/framework/mlt_transition.c
src/framework/mlt_transition.h
src/modules/core/Makefile
src/modules/core/configure
src/modules/core/factory.c
src/modules/core/filter_obscure.c
src/modules/core/filter_resize.c
src/modules/core/filter_watermark.c [new file with mode: 0644]
src/modules/core/filter_watermark.h [new file with mode: 0644]
src/modules/ffmpeg/filter_ffmpeg_dub.c
src/modules/gtk2/filter_rescale.c
src/modules/resample/filter_resample.c

index 2a89586ddf043f918ab965a35d44a8312d0f9c18..6500f5ff831ca600b64f7a965812408c46a6986d 100644 (file)
@@ -28,13 +28,8 @@ Producers
                        ffmpeg must be configured as --enable-shared and installed prior
                        to compilation of mlt.
 
-               Oddities
-
-                       MPEG video remains elusive.
-
                Known Bugs
 
-                       Fixed frame rate.
                        Audio sync discrepancy with some content.
                        Not all libavformat supported formats are seekable.
                        ogg is currently broken.
@@ -558,6 +553,72 @@ Filters
 
                        none
 
+       resample
+
+               Description
+
+                       Adjust an audio stream's sampling rate
+
+               Constructor Argument
+
+                       frequency - a numeric value for the new sample rate
+
+               Initialisation Properties
+
+                       int in - in point
+                       int out - out point
+
+               Mutable Properties
+
+                       int frequency - the target sample rate
+
+               Dependencies
+
+                       libresample
+
+               Known Bugs
+
+                       none
+
+       rescale
+
+               Description
+
+                       Scale the producer video frame size to match the consumer.
+
+               Constructor Argument
+
+                       interpolation - the rescaling method, one of:
+                               nearest (lowest quality, fastest),
+                               tiles,
+                               bilinear (good quality, moderate speed),
+                               hyper (best quality, slowest)
+
+               Initialisation Properties
+
+                       int in - in point
+                       int out - out point
+
+               Mutable Properties
+
+                       string interpolation - see constructor argument above
+
+                       If a property "consumer_aspect_ratio" exists on the frame, then
+                       rescaler normalises the producer's aspect ratio and maximises the
+                       size of the frame, but may not produce the consumer's requested
+                       dimension. Therefore, this option works best in conjunction with the
+                       resize filter. This behavior can be disabled by another service by
+                       either removing the property, setting it to zero, or setting
+                       frame property "distort" to 1.
+
+               Dependencies
+
+                       libgdk_pixbuf-2.0, libglib-2.0, libgobject-2.0, libgmodule-2.0
+
+               Known Bugs
+
+                       none
+
        volume
 
                Description
@@ -614,67 +675,32 @@ Filters
 
                        none
 
-       resample
+       watermark
 
                Description
 
-                       Adjust an audio stream's sampling rate
+                       Add a watermark to the frames.
 
                Constructor Argument
 
-                       frequency - a numeric value for the new sample rate
+                       resource - the producer to use (ie: a .png)
 
                Initialisation Properties
 
+                       string resource - the producer to use
+                       string factory - producer required for the resource ('fezzik')
+                       string geometry - composite geometry
+                       string distort - control scaling
                        int in - in point
                        int out - out point
 
                Mutable Properties
 
-                       int frequency - the target sample rate
-
-               Dependencies
-
-                       libresample
-
-               Known Bugs
-
                        none
 
-       rescale
-
-               Description
-
-                       Scale the producer video frame size to match the consumer.
-
-               Constructor Argument
-
-                       interpolation - the rescaling method, one of:
-                               nearest (lowest quality, fastest),
-                               tiles,
-                               bilinear (good quality, moderate speed),
-                               hyper (best quality, slowest)
-
-               Initialisation Properties
-
-                       int in - in point
-                       int out - out point
-
-               Mutable Properties
-
-                       string interpolation - see constructor argument above
-
-                       If a property "consumer_aspect_ratio" exists on the frame, then
-                       rescaler normalises the producer's aspect ratio and maximises the
-                       size of the frame, but may not produce the consumer's requested
-                       dimension. Therefore, this option works best in conjunction with the
-                       resize filter. This behavior can be disabled by another service by
-                       either removing the property, setting it to zero, or setting
-                       frame property "distort" to 1.
-
                Dependencies
 
-                       libgdk_pixbuf-2.0, libglib-2.0, libgobject-2.0, libgmodule-2.0
+                       mlt core modules and optionally, fezzik
 
                Known Bugs
 
index 6c367e9335e79778f38386855afc4524f90b3b22..04bc9baab41882bf8303490f1be9797f8dc0939c 100644 (file)
@@ -293,10 +293,13 @@ int mlt_frame_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_format *for
 
 void mlt_frame_close( mlt_frame this )
 {
-       mlt_deque_close( this->stack_get_image );
-       mlt_deque_close( this->stack_frame );
-       mlt_properties_close( &this->parent );
-       free( this );
+       if ( this != NULL )
+       {
+               mlt_deque_close( this->stack_get_image );
+               mlt_deque_close( this->stack_frame );
+               mlt_properties_close( &this->parent );
+               free( this );
+       }
 }
 
 /***** convenience functions *****/
index 7e748c0f7b69e0b0c8b18ec042fab2c782ebc279..6d59712474d75e1a12c013c0aa5f3908d7c99ac5 100644 (file)
@@ -43,9 +43,6 @@ struct mlt_producer_s
 /** Public final methods
 */
 
-//extern double mlt_producer_convert_position_to_time( mlt_producer this, int64_t frame );
-//extern mlt_position mlt_producer_convert_time_to_position( mlt_producer this, double time );
-
 extern int mlt_producer_init( mlt_producer this, void *child );
 extern mlt_service mlt_producer_service( mlt_producer this );
 extern mlt_properties mlt_producer_properties( mlt_producer this );
index 10d2aeeeeea16ec52eb2f5e2304731c4a21c7488..12443d7370e4a7cd1958fccb7d66b2d373af7478 100644 (file)
@@ -50,13 +50,23 @@ int mlt_transition_init( mlt_transition this, void *child )
                mlt_properties_set_position( properties, "out", 0 );
                mlt_properties_set_int( properties, "a_track", 0 );
                mlt_properties_set_int( properties, "b_track", 1 );
-               mlt_properties_set( properties, "resource", "<transition>" );
 
                return 0;
        }
        return 1;
 }
 
+/** Create a new transition.
+*/
+
+mlt_transition mlt_transition_new( )
+{
+       mlt_transition this = calloc( 1, sizeof( struct mlt_transition_s ) );
+       if ( this != NULL )
+               mlt_transition_init( this, NULL );
+       return this;
+}
+
 /** Get the service associated to the transition.
 */
 
@@ -136,7 +146,7 @@ mlt_position mlt_transition_get_out( mlt_transition this )
        If we have no process method (unlikely), we simply return the a_frame unmolested.
 */
 
-static mlt_frame transition_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame )
+mlt_frame mlt_transition_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame )
 {
        if ( this->process == NULL )
                return a_frame;
@@ -186,7 +196,7 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i
                if ( position >= in && position <= out )
                {
                        // Process the transition
-                       *frame = transition_process( this, this->a_frame, this->b_frame );
+                       *frame = mlt_transition_process( this, this->a_frame, this->b_frame );
                        this->a_held = 0;
                }
                else
index 1dad6c19a88d6cc831b86859c4c29bb9ac081260..e4dd154edae4d60240fe58f385d04297c9bdef42 100644 (file)
@@ -54,6 +54,7 @@ struct mlt_transition_s
 */
 
 extern int mlt_transition_init( mlt_transition this, void *child );
+extern mlt_transition mlt_transition_new( );
 extern mlt_service mlt_transition_service( mlt_transition this );
 extern mlt_properties mlt_transition_properties( mlt_transition this );
 extern int mlt_transition_connect( mlt_transition this, mlt_service producer, int a_track, int b_track );
@@ -62,6 +63,7 @@ extern int mlt_transition_get_a_track( mlt_transition this );
 extern int mlt_transition_get_b_track( mlt_transition this );
 extern mlt_position mlt_transition_get_in( mlt_transition this );
 extern mlt_position mlt_transition_get_out( mlt_transition this );
+extern mlt_frame mlt_transition_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame );
 extern void mlt_transition_close( mlt_transition this );
 
 #endif
index d1d05d79182c33dba3e32ecec8676123c9e3aefd..41f7b347b61b84f2af4f333bdf0dfa75343da45a 100644 (file)
@@ -3,16 +3,17 @@ TARGET = ../libmltcore.so
 
 OBJS = factory.o \
           producer_ppm.o \
+          filter_brightness.o \
           filter_deinterlace.o \
           filter_greyscale.o \
           filter_gamma.o \
           filter_obscure.o \
           filter_resize.o \
           filter_volume.o \
+          filter_watermark.o \
           transition_composite.o \
           transition_luma.o \
-          transition_mix.o \
-          filter_brightness.o
+          transition_mix.o 
 
 CFLAGS = -O3 -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread
 
index e6ef26326681ec68b51a050badff792a438cf939..dec3e775e56d87b9cf7d81d9764397868f72a205 100755 (executable)
@@ -8,13 +8,14 @@ ppm                           libmltcore.so
 EOF
 
 cat << EOF >> ../filters.dat
+brightness             libmltcore.so
 deinterlace            libmltcore.so
 gamma                  libmltcore.so
 greyscale              libmltcore.so
+obscure                        libmltcore.so
 resize                 libmltcore.so
 volume                 libmltcore.so
-obscure                        libmltcore.so
-brightness             libmltcore.so
+watermark              libmltcore.so
 EOF
 
 cat << EOF >> ../transitions.dat
index 5096656709160abb208e46a49c3815028dc16d30..650cca8476b6a1ac7026f794392d6375991725fb 100644 (file)
 #include <string.h>
 
 #include "producer_ppm.h"
+#include "filter_brightness.h"
 #include "filter_deinterlace.h"
 #include "filter_gamma.h"
 #include "filter_greyscale.h"
 #include "filter_obscure.h"
 #include "filter_resize.h"
 #include "filter_volume.h"
+#include "filter_watermark.h"
 #include "transition_composite.h"
 #include "transition_luma.h"
 #include "transition_mix.h"
-#include "filter_brightness.h"
 
 void *mlt_create_producer( char *id, void *arg )
 {
@@ -41,6 +42,8 @@ void *mlt_create_producer( char *id, void *arg )
 
 void *mlt_create_filter( char *id, void *arg )
 {
+       if ( !strcmp( id, "brightness" ) )
+               return filter_brightness_init( arg );
        if ( !strcmp( id, "deinterlace" ) )
                return filter_deinterlace_init( arg );
        if ( !strcmp( id, "gamma" ) )
@@ -53,8 +56,8 @@ void *mlt_create_filter( char *id, void *arg )
                return filter_resize_init( arg );
        if ( !strcmp( id, "volume" ) )
                return filter_volume_init( arg );
-       if ( !strcmp( id, "brightness" ) )
-               return filter_brightness_init( arg );
+       if ( !strcmp( id, "watermark" ) )
+               return filter_watermark_init( arg );
        return NULL;
 }
 
index b3c1622930306880bcd154e6fc2bff0790b9d3e8..ed06492999cb3bf746fe4c6bffc8d15a6db0400f 100644 (file)
@@ -230,7 +230,10 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        mlt_filter this = mlt_deque_pop_back( deque );
 
        // Get the image from the frame
-       if ( mlt_frame_get_image( frame, image, format, width, height, 1 ) == 0 )
+       int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
+
+       // Get the image from the frame
+       if ( error == 0 && *format == mlt_image_yuv422 )
        {
                if ( this != NULL )
                {
@@ -261,7 +264,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                }
        }
 
-       return 0;
+       return error;
 }
 
 /** Filter processing.
index 60a288722442761a7af180470eda655db3206ddb..a511eb222c009001cacf119b008b7e6f1eef1ae5 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 
-static int get_value( mlt_properties properties, char *preferred, char *fallback )
-{
-       int value = mlt_properties_get_int( properties, preferred );
-       if ( value == 0 )
-               value = mlt_properties_get_int( properties, fallback );
-       return value;
-}
-
 /** Do it :-).
 */
 
@@ -148,10 +140,7 @@ mlt_filter filter_resize_init( char *arg )
        if ( mlt_filter_init( this, this ) == 0 )
        {
                this->process = filter_process;
-               if ( arg != NULL )
-                       mlt_properties_set( mlt_filter_properties( this ), "scale", arg );
-               else
-                       mlt_properties_set( mlt_filter_properties( this ), "scale", "off" );
+               mlt_properties_set( mlt_filter_properties( this ), "scale", arg == NULL ? "off" : arg );
        }
        return this;
 }
diff --git a/src/modules/core/filter_watermark.c b/src/modules/core/filter_watermark.c
new file mode 100644 (file)
index 0000000..a7d0b0b
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * filter_watermark.c -- watermark filter
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "filter_watermark.h"
+
+#include <framework/mlt_factory.h>
+#include <framework/mlt_frame.h>
+#include <framework/mlt_producer.h>
+#include <framework/mlt_transition.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/** Do it :-).
+*/
+
+static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+{
+       int error = 0;
+       mlt_properties frame_properties = mlt_frame_properties( this );
+       mlt_filter filter = mlt_properties_get_data( frame_properties, "watermark", NULL );
+       mlt_properties properties = mlt_filter_properties( filter );
+       mlt_producer producer = mlt_properties_get_data( properties, "producer", NULL );
+       mlt_transition composite = mlt_properties_get_data( properties, "composite", NULL );
+
+       if ( composite == NULL )
+       {
+               char *geometry = mlt_properties_get( properties, "geometry" );
+               composite = mlt_factory_transition( "composite", geometry == NULL ? "85%,5%:10%x10%" : geometry );
+               if ( composite != NULL )
+               {
+                       mlt_properties composite_properties = mlt_transition_properties( composite );
+                       char *distort = mlt_properties_get( properties, "distort" );
+                       if ( distort != NULL )
+                               mlt_properties_set( composite_properties, "distort", distort );
+                       mlt_properties_set_data( properties, "composite", composite, 0, ( mlt_destructor )mlt_transition_close, NULL );
+               }
+       }
+
+       if ( producer == NULL )
+       {
+               char *resource = mlt_properties_get( properties, "resource" );
+               char *factory = mlt_properties_get( properties, "factory" );
+               producer = mlt_factory_producer( factory, resource );
+               if ( producer != NULL )
+               {
+                       mlt_properties producer_properties = mlt_producer_properties( producer );
+                       mlt_properties_set( producer_properties, "eof", "loop" );
+                       mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL );
+               }
+       }
+
+       if ( composite != NULL && producer != NULL )
+       {
+               mlt_service service = mlt_producer_service( producer );
+               mlt_frame b_frame = NULL;
+
+               if ( mlt_service_get_frame( service, &b_frame, 0 ) == 0 )
+                       mlt_transition_process( composite, this, b_frame );
+
+               error = mlt_frame_get_image( this, image, format, width, height, 1 );
+
+               mlt_frame_close( b_frame );
+       }
+       else
+       {
+               error = mlt_frame_get_image( this, image, format, width, height, 1 );
+       }
+
+       return error;
+}
+
+/** Filter processing.
+*/
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+       mlt_properties properties = mlt_frame_properties( frame );
+       mlt_properties_set_data( properties, "watermark", this, 0, NULL, NULL );
+       mlt_frame_push_get_image( frame, filter_get_image );
+       return frame;
+}
+
+/** Constructor for the filter.
+*/
+
+mlt_filter filter_watermark_init( void *arg )
+{
+       mlt_filter this = mlt_filter_new( );
+       if ( this != NULL )
+       {
+               mlt_properties properties = mlt_filter_properties( this );
+               this->process = filter_process;
+               mlt_properties_set( properties, "factory", "fezzik" );
+               if ( arg != NULL )
+                       mlt_properties_set( properties, "resource", arg );
+       }
+       return this;
+}
+
diff --git a/src/modules/core/filter_watermark.h b/src/modules/core/filter_watermark.h
new file mode 100644 (file)
index 0000000..bf844b0
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * filter_watermark.h -- watermark filter
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _FILTER_WATERMARK_H_
+#define _FILTER_WATERMARK_H_
+
+#include <framework/mlt_filter.h>
+
+extern mlt_filter filter_watermark_init( void *arg );
+
+#endif
index 0d678af208ea9720e96eca0499af70f085002eb5..c46dcd859951cde2caecb242076cb75506751725 100644 (file)
@@ -117,25 +117,27 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 mlt_filter filter_ffmpeg_dub_init( char *file )
 {
        // Create the filter object
-       mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+       mlt_filter this = mlt_filter_new( );
 
        // Initialise it
-       mlt_filter_init( this, NULL );
-
-       // Overide the filter process method
-       this->process = filter_process;
+       if ( this != NULL )
+       {
+               // Obtain the properties
+               mlt_properties properties = mlt_filter_properties( this );
 
-       // Obtain the properties
-       mlt_properties properties = mlt_filter_properties( this );
+               // Create an ffmpeg producer
+               // TODO: THIS SHOULD NOT BE HERE....
+               mlt_producer producer = mlt_factory_producer( "ffmpeg", file );
 
-       // Create an ffmpeg producer
-       mlt_producer producer = mlt_factory_producer( "ffmpeg", file );
+               // Overide the filter process method
+               this->process = filter_process;
 
-       // Pass the producer 
-       mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL );
+               // Pass the producer 
+               mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL );
 
-       // Initialise the audio frame position
-       mlt_properties_set_position( properties, "dub_position", 0 );
+               // Initialise the audio frame position
+               mlt_properties_set_position( properties, "dub_position", 0 );
+       }
 
        return this;
 }
index f70c039cfa4563476be1827efa021e05630e7e7c..f4c69ace4575162e48749b60ae1d44014db36ce6 100644 (file)
@@ -205,14 +205,11 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 
 mlt_filter filter_rescale_init( char *arg )
 {
-       mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
-       if ( mlt_filter_init( this, this ) == 0 )
+       mlt_filter this = mlt_filter_new( );
+       if ( this != NULL )
        {
                this->process = filter_process;
-               if ( arg != NULL )
-                       mlt_properties_set( mlt_filter_properties( this ), "interpolation", arg );
-               else
-                       mlt_properties_set( mlt_filter_properties( this ), "interpolation", "bilinear" );
+               mlt_properties_set( mlt_filter_properties( this ), "interpolation", arg == NULL ? "bilinear" : arg );
        }
        return this;
 }
index f40384c1b97dcf9345fa8ae3de8263c56cc25945..b8da7605d04672ffa1e639bb2e8f140a6c503bbd 100644 (file)
@@ -134,8 +134,8 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 
 mlt_filter filter_resample_init( char *arg )
 {
-       mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
-       if ( this != NULL && mlt_filter_init( this, NULL ) == 0 )
+       mlt_filter this = mlt_filter_new( );
+       if ( this != NULL )
        {
                int error;
                SRC_STATE *state = src_new( RESAMPLE_TYPE, 2 /* channels */, &error );