X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fcore%2Ffilter_luma.c;h=f05d6c405d06502080116b73c9ac9374db690052;hb=f4963a6aa07644399b273b5d2b1f9299c9047414;hp=878fb6a4cde0108452c9ae808016313febd3b118;hpb=eccf04749681f70957f34fdd6742224774e72d15;p=melted diff --git a/src/modules/core/filter_luma.c b/src/modules/core/filter_luma.c index 878fb6a..f05d6c4 100644 --- a/src/modules/core/filter_luma.c +++ b/src/modules/core/filter_luma.c @@ -3,23 +3,22 @@ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited * Author: Charles Yates * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * 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 program is distributed in the hope that it will be useful, + * 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 General Public License for more details. + * 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 General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * 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_luma.h" - +#include #include #include #include @@ -39,15 +38,23 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * mlt_properties properties = MLT_FILTER_PROPERTIES( filter ); mlt_transition luma = mlt_properties_get_data( properties, "luma", NULL ); mlt_frame b_frame = mlt_properties_get_data( properties, "frame", NULL ); + mlt_properties b_frame_props = b_frame ? MLT_FRAME_PROPERTIES( b_frame ) : NULL; int out = mlt_properties_get_int( properties, "period" ); if ( out == 0 ) out = 24; + if ( b_frame == NULL || mlt_properties_get_int( b_frame_props, "width" ) != *width || mlt_properties_get_int( b_frame_props, "height" ) != *height ) + { + b_frame = mlt_frame_init( MLT_FILTER_SERVICE( filter ) ); + mlt_properties_set_data( properties, "frame", b_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); + } + if ( luma == NULL ) { char *resource = mlt_properties_get( properties, "resource" ); - luma = mlt_factory_transition( "luma", resource ); + mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( filter ) ); + luma = mlt_factory_transition( profile, "luma", resource ); if ( luma != NULL ) { mlt_properties luma_properties = MLT_TRANSITION_PROPERTIES( luma ); @@ -56,12 +63,27 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * mlt_properties_set_int( luma_properties, "reverse", 1 ); mlt_properties_set_data( properties, "luma", luma, 0, ( mlt_destructor )mlt_transition_close, NULL ); } - } - if ( b_frame == NULL ) - { - b_frame = mlt_frame_init( ); - mlt_properties_set_data( properties, "frame", b_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); + // Prime the filter with the first image to prevent a transition from the white + // of a test card. + error = mlt_frame_get_image( this, image, format, width, height, 1 ); + if ( error == 0 ) + { + mlt_properties a_props = MLT_FRAME_PROPERTIES( this ); + int size = 0; + uint8_t *src = mlt_properties_get_data( a_props, "image", &size ); + uint8_t *dst = mlt_pool_alloc( size ); + + if ( dst != NULL ) + { + mlt_properties b_props = MLT_FRAME_PROPERTIES( b_frame ); + memcpy( dst, src, size ); + mlt_properties_set_data( b_props, "image", dst, size, mlt_pool_release, NULL ); + mlt_properties_set_int( b_props, "width", *width ); + mlt_properties_set_int( b_props, "height", *height ); + mlt_properties_set_int( b_props, "format", *format ); + } + } } if ( luma != NULL && @@ -113,7 +135,7 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) /** Constructor for the filter. */ -mlt_filter filter_luma_init( void *arg ) +mlt_filter filter_luma_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg ) { mlt_filter this = mlt_filter_new( ); if ( this != NULL )