]> git.sesse.net Git - mlt/commitdiff
+ A mono filter for mask generation (not v. useful)
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 14 Aug 2006 09:32:53 +0000 (09:32 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 14 Aug 2006 09:32:53 +0000 (09:32 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@925 d19143bc-622f-0410-bfdd-b5b2a6649095

src/modules/vmfx/Makefile
src/modules/vmfx/configure
src/modules/vmfx/factory.c
src/modules/vmfx/filter_mono.c [new file with mode: 0644]

index afb164fcb36525aa352b6b327b5ddd1eafb831d8..0ee264fd54dcd5b8b1807dd1bb3c3e84cb9fbf68 100644 (file)
@@ -5,6 +5,7 @@ TARGET = ../libmltvmfx$(LIBSUF)
 OBJS = factory.o \
           filter_chroma.o \
           filter_chroma_hold.o \
+          filter_mono.o \
           filter_shape.o \
           producer_pgm.o
 
index a19463290766e0fa3ecf9f995dfaeefa61ef0894..561f3bddc6f5979ab5a23740f627cf5788882011 100755 (executable)
@@ -10,6 +10,7 @@ EOF
 cat << EOF >> ../filters.dat
 chroma                 libmltvmfx$LIBSUF
 chroma_hold            libmltvmfx$LIBSUF
+mono                   libmltvmfx$LIBSUF
 shape                  libmltvmfx$LIBSUF
 EOF
 
index 35bb78f719e2388a44ab4e3e3e7e3f53f4b33d09..518ae8c1d213446614f8b9e2bbb8f179ec8fef99 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "filter_chroma.h"
 #include "filter_chroma_hold.h"
+#include "filter_mono.h"
 #include "filter_shape.h"
 #include "producer_pgm.h"
 
@@ -38,6 +39,8 @@ void *mlt_create_filter( char *id, void *arg )
                return filter_chroma_init( arg );
        if ( !strcmp( id, "chroma_hold" ) )
                return filter_chroma_hold_init( arg );
+       if ( !strcmp( id, "mono" ) )
+               return filter_mono_init( arg );
        if ( !strcmp( id, "shape" ) )
                return filter_shape_init( arg );
        return NULL;
diff --git a/src/modules/vmfx/filter_mono.c b/src/modules/vmfx/filter_mono.c
new file mode 100644 (file)
index 0000000..88467ce
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * filter_mono.c -- Arbitrary alpha channel shaping
+ * Copyright (C) 2005 Visual Media Fx Inc.
+ * 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 Lesser 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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_mono.h"
+#include <string.h>
+#include <framework/mlt_factory.h>
+#include <framework/mlt_frame.h>
+#include <framework/mlt_producer.h>
+#include <framework/mlt_geometry.h>
+
+/** Get the images and apply the luminance of the mask to the alpha of the frame.
+*/
+
+static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+{
+       int use_alpha = mlt_deque_pop_back_int( MLT_FRAME_IMAGE_STACK( this ) );
+       int midpoint = mlt_deque_pop_back_int( MLT_FRAME_IMAGE_STACK( this ) );
+
+       // Render the frame
+       if ( mlt_frame_get_image( this, image, format, width, height, writable ) == 0 )
+       {
+               uint8_t *p = *image;
+               int size = *width * *height;
+
+               if ( !use_alpha )
+               {
+                       while( size -- )
+                       {
+                               if ( *p >= midpoint )
+                                       *p ++ = 16;
+                               else
+                                       *p ++ = 235;
+                               *p ++ = 128;
+                       }
+               }
+               else
+               {
+                       uint8_t *alpha = mlt_frame_get_alpha_mask( this );
+                       while( size -- )
+                       {
+                               if ( *alpha ++ < midpoint )
+                                       *p ++ = 16;
+                               else
+                                       *p ++ = 235;
+                               *p ++ = 128;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+/** Filter processing.
+*/
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+       int midpoint = mlt_properties_get_int( MLT_FILTER_PROPERTIES( this ), "midpoint" );
+       int use_alpha = mlt_properties_get_int( MLT_FILTER_PROPERTIES( this ), "use_alpha" );
+       mlt_deque_push_back_int( MLT_FRAME_IMAGE_STACK( frame ), midpoint );
+       mlt_deque_push_back_int( MLT_FRAME_IMAGE_STACK( frame ), use_alpha );
+       mlt_frame_push_get_image( frame, filter_get_image );
+       return frame;
+}
+
+/** Constructor for the filter.
+*/
+
+mlt_filter filter_mono_init( char *arg )
+{
+       mlt_filter this = mlt_filter_new( );
+       if ( this != NULL )
+       {
+               mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "midpoint", 128 );
+               mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "use_alpha", 0 );
+               this->process = filter_process;
+       }
+       return this;
+}
+