* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include "filter_chroma.h"
+#include <framework/mlt_filter.h>
#include <stdlib.h>
#include <framework/mlt_factory.h>
#include <framework/mlt_frame.h>
return ( ( int )v >= c - var ) && ( ( int )v <= c + var );
}
-static inline uint8_t alpha_value( uint8_t a, uint8_t *p, uint8_t u, uint8_t v, int var )
+static inline uint8_t alpha_value( uint8_t a, uint8_t *p, uint8_t u, uint8_t v, int var, int odd )
{
- return ( in_range( *( p + 1 ), u, var ) && in_range( *( p + 3 ), v, var ) ) ? 0 : a;
+ if ( odd == 0 )
+ return ( in_range( *( p + 1 ), u, var ) && in_range( *( p + 3 ), v, var ) ) ? 0 : a;
+ else
+ return ( in_range( ( *( p + 1 ) + *( p + 5 ) ) / 2, u, var ) && in_range( ( *( p + 3 ) + *( p + 7 ) ) / 2, v, var ) ) ? 0 : a;
}
/** Get the images and map the chroma to the alpha of the frame.
int size = *width * *height / 2;
while ( size -- )
{
- alpha = alpha_value( 255, p, u, v, variance );
- p ++;
+ alpha = alpha_value( 255, p, u, v, variance, 0 );
if ( alpha )
- *p ++ = 128;
- else
- p ++;
- alpha = alpha_value( 255, p, v, u, variance );
- p ++;
+ *( p + 1 )= 128;
+ alpha = alpha_value( 255, p, u, v, variance, 1 );
if ( alpha )
- *p ++ = 128;
- else
- p ++;
+ *( p + 3 ) = 128;
+ p += 4;
}
}
/** Constructor for the filter.
*/
-mlt_filter filter_chroma_hold_init( char *arg )
+mlt_filter filter_chroma_hold_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( MLT_FILTER_PROPERTIES( this ), "key", arg == NULL ? "0xc00000" : arg );
- mlt_properties_set_double( MLT_FILTER_PROPERTIES( this ), "variance", 0.3 );
+ mlt_properties_set_double( MLT_FILTER_PROPERTIES( this ), "variance", 0.15 );
this->process = filter_process;
}
return this;