X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fvmfx%2Ffilter_mono.c;h=f7ea11d0088ad7c3f492957ba3bc69dbf24ef1f1;hb=f4d4669b66a9f23be85527f65dec19a566db561c;hp=88467ce28fc5db91dd278c277a845002ba8c3deb;hpb=ae88b80055e4a40af0e272ac682a43eed0c8df57;p=melted diff --git a/src/modules/vmfx/filter_mono.c b/src/modules/vmfx/filter_mono.c index 88467ce..f7ea11d 100644 --- a/src/modules/vmfx/filter_mono.c +++ b/src/modules/vmfx/filter_mono.c @@ -18,7 +18,7 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "filter_mono.h" +#include #include #include #include @@ -32,21 +32,24 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * { int use_alpha = mlt_deque_pop_back_int( MLT_FRAME_IMAGE_STACK( this ) ); int midpoint = mlt_deque_pop_back_int( MLT_FRAME_IMAGE_STACK( this ) ); + int invert = mlt_deque_pop_back_int( MLT_FRAME_IMAGE_STACK( this ) ); // Render the frame if ( mlt_frame_get_image( this, image, format, width, height, writable ) == 0 ) { uint8_t *p = *image; + uint8_t A = invert? 235 : 16; + uint8_t B = invert? 16 : 235; int size = *width * *height; if ( !use_alpha ) { while( size -- ) { - if ( *p >= midpoint ) - *p ++ = 16; + if ( *p < midpoint ) + *p ++ = A; else - *p ++ = 235; + *p ++ = B; *p ++ = 128; } } @@ -56,9 +59,9 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * while( size -- ) { if ( *alpha ++ < midpoint ) - *p ++ = 16; + *p ++ = A; else - *p ++ = 235; + *p ++ = B; *p ++ = 128; } } @@ -74,6 +77,8 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) { int midpoint = mlt_properties_get_int( MLT_FILTER_PROPERTIES( this ), "midpoint" ); int use_alpha = mlt_properties_get_int( MLT_FILTER_PROPERTIES( this ), "use_alpha" ); + int invert = mlt_properties_get_int( MLT_FILTER_PROPERTIES( this ), "invert" ); + mlt_deque_push_back_int( MLT_FRAME_IMAGE_STACK( frame ), invert ); mlt_deque_push_back_int( MLT_FRAME_IMAGE_STACK( frame ), midpoint ); mlt_deque_push_back_int( MLT_FRAME_IMAGE_STACK( frame ), use_alpha ); mlt_frame_push_get_image( frame, filter_get_image ); @@ -83,13 +88,14 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) /** Constructor for the filter. */ -mlt_filter filter_mono_init( char *arg ) +mlt_filter filter_mono_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg ) { mlt_filter this = mlt_filter_new( ); if ( this != NULL ) { mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "midpoint", 128 ); mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "use_alpha", 0 ); + mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "invert", 0 ); this->process = filter_process; } return this;