From: ddennedy Date: Tue, 8 Jan 2008 07:10:31 +0000 (+0000) Subject: src/modules/oldfilm/*: add oldfilm module contributed by Marco Gittler X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=67852388ef853a47d2e4e16a544bb35e8c174d22;p=melted src/modules/oldfilm/*: add oldfilm module contributed by Marco Gittler git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1048 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/modules/oldfilm/Makefile b/src/modules/oldfilm/Makefile new file mode 100644 index 0000000..a4e49bb --- /dev/null +++ b/src/modules/oldfilm/Makefile @@ -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 index 0000000..124baa8 --- /dev/null +++ b/src/modules/oldfilm/configure @@ -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 index 0000000..893c6d2 --- /dev/null +++ b/src/modules/oldfilm/factory.c @@ -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 + +#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 index 0000000..8b6c852 --- /dev/null +++ b/src/modules/oldfilm/filter_dust.c @@ -0,0 +1,105 @@ +/* + * filter_dust.c -- dust filter + * Copyright (c) 2007 Marco Gittler + * + * 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 + +#include +#include +#include + + +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;x0 && y1+y0 && 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 index 0000000..5072b19 --- /dev/null +++ b/src/modules/oldfilm/filter_dust.h @@ -0,0 +1,27 @@ +/* + * filter_dust.h -- dust filter + * Copyright (c) 2007 Marco Gittler + * + * 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 + +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 index 0000000..1795dac --- /dev/null +++ b/src/modules/oldfilm/filter_grain.c @@ -0,0 +1,75 @@ +/* + * filter_grain.c -- grain filter + * Copyright (c) 2007 Marco Gittler + * + * 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 + +#include +#include +#include + + +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;x20){ + 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 index 0000000..2b3d618 --- /dev/null +++ b/src/modules/oldfilm/filter_grain.h @@ -0,0 +1,27 @@ +/* + * filter_grain.h -- grain filter + * Copyright (c) 2007 Marco Gittler + * + * 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 + +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 index 0000000..c840ae0 --- /dev/null +++ b/src/modules/oldfilm/filter_lines.c @@ -0,0 +1,101 @@ +/* + * filter_lines.c -- lines filter + * Copyright (c) 2007 Marco Gittler + * + * 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 + +#include +#include +#include + + +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;x0){ + 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 index 0000000..3f6f3bd --- /dev/null +++ b/src/modules/oldfilm/filter_lines.h @@ -0,0 +1,27 @@ +/* + * filter_lines.h -- lines filter + * Copyright (c) 2007 Marco Gittler + * + * 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 + +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 index 0000000..9935c70 --- /dev/null +++ b/src/modules/oldfilm/filter_oldfilm.c @@ -0,0 +1,95 @@ +/* + * filter_oldfilm.c -- oldfilm filter + * Copyright (c) 2007 Marco Gittler + * + * 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 + +#include +#include +#include + + +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;x0 && y+diffpicprocess = 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 index 0000000..af309b3 --- /dev/null +++ b/src/modules/oldfilm/filter_oldfilm.h @@ -0,0 +1,27 @@ +/* + * filter_oldfilm.h -- oldfilm filter + * Copyright (c) 2007 Marco Gittler + * + * 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 + +extern mlt_filter filter_oldfilm_init( char *arg ); + +#endif