]> git.sesse.net Git - mlt/blobdiff - src/modules/core/filter_watermark.c
Remove unused string.h include
[mlt] / src / modules / core / filter_watermark.c
index 2e88e082adc7ff6a82ce11cfbc8568acf234ed72..b5adba315b159e22ad61d41b3d2a89167cc50f31 100644 (file)
@@ -42,6 +42,8 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        // Get the properties of the filter
        mlt_properties properties = MLT_FILTER_PROPERTIES( this );
 
+       mlt_service_lock( MLT_FILTER_SERVICE( this ) );
+
        // Get the producer from the filter
        mlt_producer producer = mlt_properties_get_data( properties, "producer", NULL );
 
@@ -115,6 +117,8 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                mlt_properties_pass( producer_properties, properties, "producer." );
        }
 
+       mlt_service_unlock( MLT_FILTER_SERVICE( this ) );
+
        // Only continue if we have both producer and composite
        if ( composite != NULL && producer != NULL )
        {
@@ -124,11 +128,8 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                // We will get the 'b frame' from the producer
                mlt_frame b_frame = NULL;
 
-               // Get the unique id of the filter (used to reacquire the producer position)
-               char *name = mlt_properties_get( properties, "_unique_id" );
-
                // Get the original producer position
-               mlt_position position = mlt_properties_get_position( MLT_FRAME_PROPERTIES( frame ), name );
+               mlt_position position = mlt_filter_get_position( this, frame );
 
                // Make sure the producer is in the correct position
                mlt_producer_seek( producer, position );
@@ -142,21 +143,17 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                        // Get the a and b frame properties
                        mlt_properties a_props = MLT_FRAME_PROPERTIES( frame );
                        mlt_properties b_props = MLT_FRAME_PROPERTIES( b_frame );
+                       mlt_profile profile = mlt_service_profile( service );
 
                        // Set the b frame to be in the same position and have same consumer requirements
                        mlt_frame_set_position( b_frame, position );
-                       mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) );
                        mlt_properties_set_int( b_props, "consumer_deinterlace", mlt_properties_get_int( a_props, "consumer_deinterlace" ) || mlt_properties_get_int( properties, "deinterlace" ) );
-                       mlt_properties_set_double( b_props, "output_ratio", mlt_properties_get_double( a_props, "output_ratio" ) );
 
                        // Check for the special case - no aspect ratio means no problem :-)
                        if ( mlt_frame_get_aspect_ratio( b_frame ) == 0 )
-                               mlt_properties_set_double( b_props, "aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) );
+                               mlt_frame_set_aspect_ratio( b_frame, mlt_profile_sar( profile ) );
                        if ( mlt_frame_get_aspect_ratio( frame ) == 0 )
-                               mlt_properties_set_double( a_props, "aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) );
-
-                       mlt_properties_set_int( b_props, "normalised_width", mlt_properties_get_int( a_props, "normalised_width" ) );
-                       mlt_properties_set_int( b_props, "normalised_height", mlt_properties_get_int( a_props, "normalised_height" ) );
+                               mlt_frame_set_aspect_ratio( frame, mlt_profile_sar( profile ) );
 
                        if ( mlt_properties_get_int( properties, "distort" ) )
                        {
@@ -165,6 +162,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                                mlt_properties_set_int( b_props, "distort", 1 );
                        }
 
+                       *format = mlt_image_yuv422;
                        if ( mlt_properties_get_int( properties, "reverse" ) == 0 )
                        {
                                // Apply all filters that are attached to this filter to the b frame
@@ -192,8 +190,8 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                                mlt_service_apply_filters( MLT_FILTER_SERVICE( this ), b_frame, 0 );
                                error = mlt_frame_get_image( b_frame, image, format, width, height, 1 );
                                alpha = mlt_frame_get_alpha_mask( b_frame );
-                               mlt_properties_set_data( a_props, "image", *image, *width * *height * 2, NULL, NULL );
-                               mlt_properties_set_data( a_props, "alpha", alpha, *width * *height, NULL, NULL );
+                               mlt_frame_set_image( frame, *image, *width * *height * 2, NULL );
+                               mlt_frame_set_alpha( frame, alpha, *width * *height, NULL );
                                mlt_properties_set_int( a_props, "width", *width );
                                mlt_properties_set_int( a_props, "height", *height );
                                mlt_properties_set_int( a_props, "progressive", 1 );
@@ -225,15 +223,9 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
        // Get the properties of the frame
        mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
 
-       // Get a unique name to store the frame position
-       char *name = mlt_properties_get( MLT_FILTER_PROPERTIES( this ), "_unique_id" );
-
        // Assign the frame out point to the filter (just in case we need it later)
        mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "_out", mlt_properties_get_int( properties, "out" ) );
 
-       // Assign the current position to the name
-       mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) - mlt_filter_get_in( this ) );
-
        // Push the filter on to the stack
        mlt_frame_push_service( frame, this );
 
@@ -253,7 +245,7 @@ mlt_filter filter_watermark_init( mlt_profile profile, mlt_service_type type, co
        {
                mlt_properties properties = MLT_FILTER_PROPERTIES( this );
                this->process = filter_process;
-               mlt_properties_set( properties, "factory", "fezzik" );
+               mlt_properties_set( properties, "factory", mlt_environment( "MLT_PRODUCER" ) );
                if ( arg != NULL )
                        mlt_properties_set( properties, "resource", arg );
                // Ensure that attached filters are handled privately