]> git.sesse.net Git - mlt/commitdiff
+ Changed license of plugins to LGPL
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 1 Sep 2005 07:08:50 +0000 (07:08 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 1 Sep 2005 07:08:50 +0000 (07:08 +0000)
+ Added a chroma hold filter
+ Small optimisation/correction to chroma filter

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

12 files changed:
src/modules/vmfx/Makefile
src/modules/vmfx/configure
src/modules/vmfx/factory.c
src/modules/vmfx/filter_chroma.c
src/modules/vmfx/filter_chroma.h
src/modules/vmfx/filter_chroma_hold.c [new file with mode: 0644]
src/modules/vmfx/filter_chroma_hold.h [new file with mode: 0644]
src/modules/vmfx/filter_shape.c
src/modules/vmfx/filter_shape.h
src/modules/vmfx/gpl [deleted file]
src/modules/vmfx/producer_pgm.c
src/modules/vmfx/producer_pgm.h

index 98eb547462a539fc26355427c152cc4fc11a73ba..13f59ad82a52d372f5af2b161e40620ef5944eea 100644 (file)
@@ -4,6 +4,7 @@ TARGET = ../libmltvmfx$(LIBSUF)
 
 OBJS = factory.o \
           filter_chroma.o \
+          filter_chroma_hold.o \
           filter_shape.o \
           producer_pgm.o
 
index 37230f95697b316e8f546bc0c13bc630ddb01ef9..a19463290766e0fa3ecf9f995dfaeefa61ef0894 100755 (executable)
@@ -9,6 +9,7 @@ EOF
 
 cat << EOF >> ../filters.dat
 chroma                 libmltvmfx$LIBSUF
+chroma_hold            libmltvmfx$LIBSUF
 shape                  libmltvmfx$LIBSUF
 EOF
 
index cd67d5ceba5d6ef836ca93e420bcc2faaeb35df0..35bb78f719e2388a44ab4e3e3e7e3f53f4b33d09 100644 (file)
@@ -4,16 +4,16 @@
  * Author: Charles Yates <charles.yates@gmail.com>
  *
  * 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
+ * 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 General Public License for more details.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * 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.
  */
@@ -21,6 +21,7 @@
 #include <string.h>
 
 #include "filter_chroma.h"
+#include "filter_chroma_hold.h"
 #include "filter_shape.h"
 #include "producer_pgm.h"
 
@@ -35,6 +36,8 @@ void *mlt_create_filter( char *id, void *arg )
 {
        if ( !strcmp( id, "chroma" ) )
                return filter_chroma_init( arg );
+       if ( !strcmp( id, "chroma_hold" ) )
+               return filter_chroma_hold_init( arg );
        if ( !strcmp( id, "shape" ) )
                return filter_shape_init( arg );
        return NULL;
index 565ac029964a7a9547f3a5f8d1612f093bf7c8f9..6d9384c5d05b179b6144c5d6bc3f8e12b531a6e6 100644 (file)
@@ -4,16 +4,16 @@
  * 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
+ * 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 General Public License for more details.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * 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.
  */
@@ -27,7 +27,7 @@
 
 static inline int in_range( uint8_t v, uint8_t c, int var )
 {
-       return ( v >= c - var ) && ( v <= c + var );
+       return ( ( int )v >= c - var ) && ( ( int )v <= c + var );
 }
 
 static inline uint8_t alpha_value( uint8_t a, uint8_t *p, uint8_t u, uint8_t v, int var )
@@ -42,7 +42,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
 {
        mlt_filter this = mlt_frame_pop_service( frame );
        char *key = mlt_properties_get( MLT_FILTER_PROPERTIES( this ), "key" );
-       int variance = 255 * mlt_properties_get_double( MLT_FILTER_PROPERTIES( this ), "variance" ) + 0.5;
+       int variance = 200 * mlt_properties_get_double( MLT_FILTER_PROPERTIES( this ), "variance" );
        int32_t key_val = strtol( key, &key, 0 );
        uint8_t b = key_val & 0xff;
        uint8_t g = ( key_val >> 8 ) & 0xff;
@@ -55,14 +55,15 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        {
                uint8_t *alpha = mlt_frame_get_alpha_mask( frame );
                uint8_t *p = *image;
-               int size = *width * *height;
-               int odd = 0;
+               int size = *width * *height / 2;
                while ( size -- )
                {
                        *alpha = alpha_value( *alpha, p, u, v, variance );
-                       if ( odd ) p += 4;
-                       odd = !odd;
+                       *alpha ++;
+                       p += 2;
+                       *alpha = alpha_value( *alpha, p, v, u, variance );
                        alpha ++;
+                       p += 2;
                }
        }
 
index 13c7a13c2ec6f54293c8f8d37c64a9f95e56f50b..7d87857697a60ae11f892fdecec33ed72e82704f 100644 (file)
@@ -4,16 +4,16 @@
  * Author: Charles Yates <charles.yates@gmail.com>
  *
  * 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
+ * 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 General Public License for more details.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * 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.
  */
diff --git a/src/modules/vmfx/filter_chroma_hold.c b/src/modules/vmfx/filter_chroma_hold.c
new file mode 100644 (file)
index 0000000..2992ceb
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * filter_chroma.c -- Maps a chroma key to the alpha channel
+ * 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_chroma.h"
+#include <stdlib.h>
+#include <framework/mlt_factory.h>
+#include <framework/mlt_frame.h>
+#include <framework/mlt_producer.h>
+#include <framework/mlt_geometry.h>
+
+static inline int in_range( uint8_t v, uint8_t c, int var )
+{
+       return ( ( int )v >= c - var ) && ( ( int )v <= c + var );
+}
+
+static inline uint8_t alpha_value( uint8_t a, uint8_t *p, uint8_t u, uint8_t v, int var )
+{
+       return ( in_range( *( p + 1 ), u, var ) && in_range( *( p + 3 ), v, var ) ) ? 0 : a;
+}
+
+/** Get the images and map the chroma to the alpha of the frame.
+*/
+
+static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+{
+       mlt_filter this = mlt_frame_pop_service( frame );
+       char *key = mlt_properties_get( MLT_FILTER_PROPERTIES( this ), "key" );
+       int variance = 200 * mlt_properties_get_double( MLT_FILTER_PROPERTIES( this ), "variance" );
+       int32_t key_val = strtol( key, &key, 0 );
+       uint8_t b = key_val & 0xff;
+       uint8_t g = ( key_val >> 8 ) & 0xff;
+       uint8_t r = ( key_val >> 16 ) & 0xff;
+       uint8_t y, u, v;
+
+       RGB2YUV( r, g, b, y, u, v );
+
+       if ( mlt_frame_get_image( frame, image, format, width, height, writable ) == 0 )
+       {
+               uint8_t alpha = 0;
+               uint8_t *p = *image;
+               int size = *width * *height / 2;
+               while ( size -- )
+               {
+                       alpha = alpha_value( 255, p, u, v, variance );
+                       p ++;
+                       if ( alpha ) 
+                               *p ++ = 128;
+                       else
+                               p ++;
+                       alpha = alpha_value( 255, p, v, u, variance );
+                       p ++;
+                       if ( alpha ) 
+                               *p ++ = 128;
+                       else
+                               p ++;
+               }
+       }
+
+       return 0;
+}
+
+/** Filter processing.
+*/
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+       mlt_frame_push_service( frame, this );
+       mlt_frame_push_service( frame, filter_get_image );
+       return frame;
+}
+
+/** Constructor for the filter.
+*/
+
+mlt_filter filter_chroma_hold_init( char *arg )
+{
+       mlt_filter this = mlt_filter_new( );
+       if ( this != NULL )
+       {
+               mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "key", arg == NULL ? "0xc00000" : arg );
+               mlt_properties_set_double( MLT_FILTER_PROPERTIES( this ), "variance", 0.3 );
+               this->process = filter_process;
+       }
+       return this;
+}
+
diff --git a/src/modules/vmfx/filter_chroma_hold.h b/src/modules/vmfx/filter_chroma_hold.h
new file mode 100644 (file)
index 0000000..5f39360
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * filter_chroma.h -- Maps a chroma key to the alpha channel
+ * Copyright (C) 2005 Visual Media Fx Inc.
+ * Author: Charles Yates <charles.yates@gmail.com>
+ *
+ * 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.
+ */
+
+#ifndef _FILTER_CHROMA_HOLD_H_
+#define _FILTER_CHROMA_HOLD_H_
+
+#include <framework/mlt_filter.h>
+
+extern mlt_filter filter_chroma_hold_init( char *arg );
+
+#endif
index 630194746a15b92b9555266004b28ee420adbc63..1edaa1c1a0bcd1079fa03319971b972c07815c93 100644 (file)
@@ -4,16 +4,16 @@
  * 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
+ * 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 General Public License for more details.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * 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.
  */
index 57bfc08b1b12d9e7465784bc0df4f92b3f06fe20..1cc347dc1f4619095417d0b08136b873e1177fa9 100644 (file)
@@ -4,16 +4,16 @@
  * Author: Charles Yates <charles.yates@gmail.com>
  *
  * 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
+ * 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 General Public License for more details.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * 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.
  */
diff --git a/src/modules/vmfx/gpl b/src/modules/vmfx/gpl
deleted file mode 100644 (file)
index e69de29..0000000
index 369f6d9e21e0e7244eac0bdc8ca9269e600eb631..e9d333be4b0d8cd97c02cefb402024ec72d095e8 100644 (file)
@@ -4,16 +4,16 @@
  * Author: Charles Yates <charles.yates@gmail.com>
  *
  * 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
+ * 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 General Public License for more details.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * 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.
  */
index 3c97dddc09e696b609c1d96200cba26e92cff968..29836c4e0219cf0252f4ebde0db4c7ca7213aa2b 100644 (file)
@@ -4,16 +4,16 @@
  * Author: Charles Yates <charles.yates@gmail.com>
  *
  * 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
+ * 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 General Public License for more details.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
+ * 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.
  */