--- /dev/null
+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
--- /dev/null
+#!/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
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
+
+
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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;
+}
+
+
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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;
+}
+
+
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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