X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Foldfilm%2Ffilter_lines.c;h=7d3e415ee16c57035e954f055406c9ec761ad4d0;hb=f4963a6aa07644399b273b5d2b1f9299c9047414;hp=c840ae0eb6fc01b983c263b7c87826fb88da48f4;hpb=67852388ef853a47d2e4e16a544bb35e8c174d22;p=melted diff --git a/src/modules/oldfilm/filter_lines.c b/src/modules/oldfilm/filter_lines.c index c840ae0..7d3e415 100644 --- a/src/modules/oldfilm/filter_lines.c +++ b/src/modules/oldfilm/filter_lines.c @@ -17,15 +17,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "filter_lines.h" - +#include #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 ) { @@ -37,42 +35,75 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * int h = *height; int w = *width; - int width = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "width" ); + int width_line = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "width" ); int num = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "num" ); + double maxdarker= (double)mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "darker" ) ; + double maxlighter=(double)mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "lighter" ) ; //int frame = mlt_properties_get_int( this, "_position" ); - char buf[1024]; + char buf[256]; + char typebuf[256]; + + mlt_position in = mlt_filter_get_in( filter ); + mlt_position out = mlt_filter_get_out( filter ); + mlt_position time = mlt_frame_get_position( this ); + double position = ( double )( time - in ) / ( double )( out - in + 1 ); + srand(position*10000); + if (!width_line) + return 0; while (num--){ + int type=(rand()%3)+1; + int x1=(double)w*rand()/RAND_MAX; + int dx=rand()%width_line; + int x=0,y=0; + int ystart=rand()%h; + int yend=rand()%h; + sprintf(buf,"line%d",num); + sprintf(typebuf,"typeline%d",num); + maxlighter+=rand()%30-15; + maxdarker+=rand()%30-15; + + if (mlt_properties_get_int(MLT_FILTER_PROPERTIES( filter ),buf)==0){ + mlt_properties_set_int(MLT_FILTER_PROPERTIES( filter ),buf,x1); + } - 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; + if (mlt_properties_get_int(MLT_FILTER_PROPERTIES( filter ),typebuf)==0 ){ + mlt_properties_set_int(MLT_FILTER_PROPERTIES( filter ),typebuf,type); } - 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); + double diff=1.0-fabs(x)/dx; switch(type){ - case 0: - pix=(*pixel)*abs(x)/dx; - *pixel=pix; + case 1: //blackline + *pixel-=((double)*pixel*diff*maxdarker/100.0); break; - case 1: - pix=(*pixel)+((255-*pixel)*abs(x)/dx); - *pixel=pix; + case 2: //whiteline + *pixel+=((255.0-(double)*pixel)*diff*maxlighter/100.0); break; + case 3: //greenline + *(pixel+1)-=((*(pixel+1))*diff*maxlighter/100.0); + break; } } + mlt_properties_set_int(MLT_FILTER_PROPERTIES( filter ),buf,x1); } + mlt_properties_set_double(MLT_FILTER_PROPERTIES( filter ),"last_oldfilm_line_pos",position); } return error; @@ -86,7 +117,7 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) return frame; } -mlt_filter filter_lines_init( char *arg ) +mlt_filter filter_lines_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg ) { mlt_filter this = mlt_filter_new( ); if ( this != NULL ) @@ -94,6 +125,8 @@ mlt_filter filter_lines_init( char *arg ) this->process = filter_process; mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "width", "2" ); mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "num", "5" ); + mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "darker" , 40 ) ; + mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "lighter" , 40 ) ; } return this; }