]> git.sesse.net Git - mlt/commitdiff
src/modules/oldfilm/*: add oldfilm module contributed by Marco Gittler
authorddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 8 Jan 2008 07:10:31 +0000 (07:10 +0000)
committerddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 8 Jan 2008 07:10:31 +0000 (07:10 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1048 d19143bc-622f-0410-bfdd-b5b2a6649095

src/modules/oldfilm/Makefile [new file with mode: 0644]
src/modules/oldfilm/configure [new file with mode: 0755]
src/modules/oldfilm/factory.c [new file with mode: 0644]
src/modules/oldfilm/filter_dust.c [new file with mode: 0644]
src/modules/oldfilm/filter_dust.h [new file with mode: 0644]
src/modules/oldfilm/filter_grain.c [new file with mode: 0644]
src/modules/oldfilm/filter_grain.h [new file with mode: 0644]
src/modules/oldfilm/filter_lines.c [new file with mode: 0644]
src/modules/oldfilm/filter_lines.h [new file with mode: 0644]
src/modules/oldfilm/filter_oldfilm.c [new file with mode: 0644]
src/modules/oldfilm/filter_oldfilm.h [new file with mode: 0644]

diff --git a/src/modules/oldfilm/Makefile b/src/modules/oldfilm/Makefile
new file mode 100644 (file)
index 0000000..a4e49bb
--- /dev/null
@@ -0,0 +1,38 @@
+include ../../../config.mak
+
+TARGET = ../libmltoldfilm$(LIBSUF)
+
+OBJS = factory.o \
+          filter_oldfilm.o \
+          filter_dust.o \
+          filter_lines.o \
+          filter_grain.o 
+
+CFLAGS += -I../..
+
+LDFLAGS += -lm
+
+LDFLAGS+=-L../../framework -lmlt
+
+SRCS := $(OBJS:.o=.c)
+
+all:   $(TARGET)
+
+$(TARGET): $(OBJS)
+               $(CC) $(SHFLAGS) -o $@ $(OBJS) $(LDFLAGS)
+
+depend:        $(SRCS)
+               $(CC) -MM $(CFLAGS) $^ 1>.depend
+
+distclean:     clean
+               rm -f .depend
+
+clean: 
+               rm -f $(OBJS) $(TARGET)
+
+install: all
+       install -m 755 $(TARGET) "$(DESTDIR)$(prefix)/share/mlt/modules"
+
+ifneq ($(wildcard .depend),)
+include .depend
+endif
diff --git a/src/modules/oldfilm/configure b/src/modules/oldfilm/configure
new file mode 100755 (executable)
index 0000000..124baa8
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ "$help" != "1" ]
+then
+       echo "grain             libmltoldfilm$LIBSUF" >> ../filters.dat
+       echo "oldfilm           libmltoldfilm$LIBSUF" >> ../filters.dat
+       echo "lines             libmltoldfilm$LIBSUF" >> ../filters.dat
+       echo "dust              libmltoldfilm$LIBSUF" >> ../filters.dat
+fi
diff --git a/src/modules/oldfilm/factory.c b/src/modules/oldfilm/factory.c
new file mode 100644 (file)
index 0000000..893c6d2
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * factory.c -- the factory method interfaces
+ * Copyright (C) 2007 Jean-Baptiste Mardelle
+ *
+ * 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 <string.h>
+
+#include "filter_oldfilm.h"
+#include "filter_grain.h"
+#include "filter_dust.h"
+#include "filter_lines.h"
+
+void *mlt_create_producer( char *id, void *arg )
+{
+       return NULL;
+}
+
+void *mlt_create_filter( char *id, void *arg )
+{
+       if ( !strcmp( id, "oldfilm" ) )
+                return filter_oldfilm_init( arg );
+        if ( !strcmp( id, "dust" ) )
+                return filter_dust_init( arg );
+        if ( !strcmp( id, "lines" ) )
+                return filter_lines_init( arg );
+        if ( !strcmp( id, "grain" ) )
+                return filter_grain_init( arg );
+
+       return NULL;
+}
+
+void *mlt_create_transition( char *id, void *arg )
+{
+       return NULL;
+}
+
+void *mlt_create_consumer( char *id, void *arg )
+{
+       return NULL;
+}
diff --git a/src/modules/oldfilm/filter_dust.c b/src/modules/oldfilm/filter_dust.c
new file mode 100644 (file)
index 0000000..8b6c852
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * filter_dust.c -- dust filter
+ * Copyright (c) 2007 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 "filter_dust.h"
+
+#include <framework/mlt_frame.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+{
+
+       mlt_filter filter = mlt_frame_pop_service( this );
+       int error = mlt_frame_get_image( this, image, format, width, height, 1 );
+
+       if ( error == 0 && *image && *format == mlt_image_yuv422 )
+       {
+
+               int h = *height;
+               int w = *width;
+
+               int maxdia = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "maxdiameter" );
+               int maxcount = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "maxcount" );
+               int im=rand()%maxcount;
+               
+               while (im--){
+                       int type=im%2;
+                       int y1=rand()%h;
+                       int x1=rand()%w;
+                       int dx=rand()%maxdia;
+                       int dy=rand()%maxdia;
+                       int x=0,y=0;//,v=0;
+                       for (x=-dx;x<dx;x++)
+                               for (y=-dy;y<dy;y++){
+                                       if (x1+x<w && x1+x>0 && y1+y<h && y1+y>0 && x!=0 && y!=0){
+                                               //uint8_t *pix=*image+(y+y1)*w*2+(x+x1)*2;
+                                               //v=255*(abs(x)+abs(y))/dx;
+                                               switch(type){
+                                                       case 0:
+                                                               //v=((51*sqrt(y*y+x*x))/255);
+                                                               *(*image+(y+y1)*w*2+(x+x1)*2)=*(*image+(y+y1)*w*2+(x+x1)*2)/((51*sqrt(y*y+x*x))/255);
+                                                               /*if (v!=0)
+                                                                       *pix/=v;
+                                                               else
+                                                                       *pix=0;*/
+                                                               break;
+                                                       case 1:
+                                                               //v=((51*sqrt(y*y+x*x))/255);
+                                                               //v=255*(x+y)/dx;
+                                                               *(*image+(y+y1)*w*2+(x+x1)*2)=*(*image+(y+y1)*w*2+(x+x1)*2)*((51*sqrt(y*y+x*x))/255);
+                                                               /*if ((*pix*v)<255)
+                                                                       *pix*=v;
+                                                               else
+                                                                       *pix=255;*/
+                                                               break;
+                                               }
+                                       }
+                               }
+               }
+       }
+
+       return error;
+}
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+
+       mlt_frame_push_service( frame, this );
+       mlt_frame_push_get_image( frame, filter_get_image );
+       return frame;
+}
+
+
+mlt_filter filter_dust_init( char *arg )
+{
+       mlt_filter this = mlt_filter_new( );
+       if ( this != NULL )
+       {
+               this->process = filter_process;
+               mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "maxdiameter", "10" );
+               mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "maxcount", "10" );
+       }
+       return this;
+}
+
+
diff --git a/src/modules/oldfilm/filter_dust.h b/src/modules/oldfilm/filter_dust.h
new file mode 100644 (file)
index 0000000..5072b19
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * filter_dust.h -- dust filter
+ * Copyright (c) 2007 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
+ */
+
+#ifndef _FILTER_DUST_H_
+#define _FILTER_DUST_H_
+
+#include <framework/mlt_filter.h>
+
+extern mlt_filter filter_dust_init( char *arg );
+
+#endif
diff --git a/src/modules/oldfilm/filter_grain.c b/src/modules/oldfilm/filter_grain.c
new file mode 100644 (file)
index 0000000..1795dac
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * filter_grain.c -- grain filter
+ * Copyright (c) 2007 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 "filter_grain.h"
+
+#include <framework/mlt_frame.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+{
+
+       mlt_filter filter = mlt_frame_pop_service( this );
+       int error = mlt_frame_get_image( this, image, format, width, height, 1 );
+       
+       if ( error == 0 && *image && *format == mlt_image_yuv422 )
+       {
+               int h = *height;
+               int w = *width;
+
+               int noise = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "noise" );
+               int x=0,y=0,pix=0;
+               for (x=0;x<w;x++)
+                       for(y=0;y<h;y++){
+                               uint8_t* pixel=(*image+(y)*w*2+(x)*2);
+                               if (*pixel>20){
+                                       pix=(*pixel)-(rand()%noise-noise);
+                                       if (pix>0 && pix<255)
+                                       *pixel=pix;
+                               }
+                       }
+               
+       }
+
+       return error;
+}
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+       mlt_frame_push_service( frame, this );
+       mlt_frame_push_get_image( frame, filter_get_image );
+       return frame;
+}
+
+mlt_filter filter_grain_init( char *arg )
+{
+       mlt_filter this = mlt_filter_new( );
+       if ( this != NULL )
+       {
+               this->process = filter_process;
+               mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "noise", "40" );
+       }
+       return this;
+}
+
+
diff --git a/src/modules/oldfilm/filter_grain.h b/src/modules/oldfilm/filter_grain.h
new file mode 100644 (file)
index 0000000..2b3d618
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * filter_grain.h -- grain filter
+ * Copyright (c) 2007 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
+ */
+
+#ifndef _FILTER_GRAIN_H_
+#define _FILTER_GRAIN_H_
+
+#include <framework/mlt_filter.h>
+
+extern mlt_filter filter_grain_init( char *arg );
+
+#endif
diff --git a/src/modules/oldfilm/filter_lines.c b/src/modules/oldfilm/filter_lines.c
new file mode 100644 (file)
index 0000000..c840ae0
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * filter_lines.c -- lines filter
+ * Copyright (c) 2007 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 "filter_lines.h"
+
+#include <framework/mlt_frame.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+{
+
+       mlt_filter filter = mlt_frame_pop_service( this );
+       int error = mlt_frame_get_image( this, image, format, width, height, 1 );
+
+       if ( error == 0 && *image && *format == mlt_image_yuv422 )
+       {
+               int h = *height;
+               int w = *width;
+
+               int width = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "width" );
+               int num = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "num" );
+               //int frame = mlt_properties_get_int( this, "_position" );
+               char buf[1024];
+               
+               while (num--){
+                       sprintf(buf,"line%d",num);
+                       
+                       int type=rand()%2;
+                       int x1=rand()%w;;
+                       int dx=rand()%width;
+                       /*int xx=mlt_properties_get_int(MLT_PRODUCER_PROPERTIES(mlt_frame_get_original_producer( this ),buf);
+                       if (xx==0){
+                               mlt_properties_set_int(this,buf,x1);
+                               //x1=100;
+                       }
+                       x1=mlt_properties_get_int(this,buf)+5;
+                       */
+                       int x=0,y=0,pix=0;
+                       for (x=-dx;x<dx;x++)
+                               for(y=0;y<h;y++)
+                                       if (x+x1<w && x+x1>0){
+                                               uint8_t* pixel=(*image+(y)*w*2+(x+x1)*2);
+                                               switch(type){
+                                                       case 0:
+                                                               pix=(*pixel)*abs(x)/dx;
+                                                               *pixel=pix;
+                                                               break;
+                                                       case 1:
+                                                               pix=(*pixel)+((255-*pixel)*abs(x)/dx);
+                                                               *pixel=pix;
+                                                               break;
+                                               }
+                                                       
+                               }
+               }
+       }
+
+       return error;
+}
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+
+       mlt_frame_push_service( frame, this );
+       mlt_frame_push_get_image( frame, filter_get_image );
+       return frame;
+}
+
+mlt_filter filter_lines_init( char *arg )
+{
+       mlt_filter this = mlt_filter_new( );
+       if ( this != NULL )
+       {
+               this->process = filter_process;
+               mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "width", "2" );
+               mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "num", "5" );
+       }
+       return this;
+}
+
+
diff --git a/src/modules/oldfilm/filter_lines.h b/src/modules/oldfilm/filter_lines.h
new file mode 100644 (file)
index 0000000..3f6f3bd
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * filter_lines.h -- lines filter
+ * Copyright (c) 2007 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
+ */
+
+#ifndef _FILTER_LINES_H_
+#define _FILTER_LINES_H_
+
+#include <framework/mlt_filter.h>
+
+extern mlt_filter filter_lines_init( char *arg );
+
+#endif
diff --git a/src/modules/oldfilm/filter_oldfilm.c b/src/modules/oldfilm/filter_oldfilm.c
new file mode 100644 (file)
index 0000000..9935c70
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * filter_oldfilm.c -- oldfilm filter
+ * Copyright (c) 2007 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 "filter_oldfilm.h"
+
+#include <framework/mlt_frame.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+{
+
+       mlt_filter filter = mlt_frame_pop_service( this );
+       int error = mlt_frame_get_image( this, image, format, width, height, 1 );
+       
+       if (  error == 0 && *image && *format == mlt_image_yuv422 )
+       {
+               int h = *height;
+               int w = *width;
+
+               int x=0;
+               int y=0;
+               // Get u and v values
+               int delta = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "delta" );
+               int every = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "every" );
+               int diffpic=rand()%delta*2-delta;
+               if (rand()%100>every)
+                       diffpic=0;
+               int yend,ydiff;
+               if (diffpic<=0){
+                       y=h;
+                       yend=0;
+                       ydiff=-1;
+               }else{
+                       y=0;
+                       yend=h;
+                       ydiff=1;
+               }
+               while(y!=yend){
+                       for (x=0;x<w;x++){
+                                       uint8_t* pic=(*image+y*w*2+x*2);
+                                       if (y+diffpic>0 && y+diffpic<h){
+                                               *pic=*(pic+diffpic*w*2);
+                                               *(pic+1)=*(pic+diffpic*w*2+1);
+                                       }else{
+                                               *pic=0;
+                                               *(pic+1)=127;   
+                                       }
+                       }
+                       y+=ydiff;
+               }
+       }
+
+       return error;
+}
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+
+       mlt_frame_push_service( frame, this );
+       mlt_frame_push_get_image( frame, filter_get_image );
+       return frame;
+}
+
+mlt_filter filter_oldfilm_init( char *arg )
+{
+       mlt_filter this = mlt_filter_new( );
+       if ( this != NULL )
+       {
+               this->process = filter_process;
+               mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "delta", "20" );
+               mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "every", "80" );
+       }
+       return this;
+}
+
diff --git a/src/modules/oldfilm/filter_oldfilm.h b/src/modules/oldfilm/filter_oldfilm.h
new file mode 100644 (file)
index 0000000..af309b3
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * filter_oldfilm.h -- oldfilm filter
+ * Copyright (c) 2007 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
+ */
+
+#ifndef _FILTER_OLDFILM_H_
+#define _FILTER_OLDFILM_H_
+
+#include <framework/mlt_filter.h>
+
+extern mlt_filter filter_oldfilm_init( char *arg );
+
+#endif