]> git.sesse.net Git - mlt/commitdiff
Add service locks for parallelism.
authorDan Dennedy <dan@dennedy.org>
Fri, 5 Mar 2010 06:26:45 +0000 (22:26 -0800)
committerDan Dennedy <dan@dennedy.org>
Mon, 24 Jan 2011 02:09:43 +0000 (18:09 -0800)
12 files changed:
src/modules/motion_est/filter_autotrack_rectangle.c
src/modules/motion_est/filter_crop_detect.c
src/modules/motion_est/filter_motion_est.c
src/modules/normalize/filter_volume.c
src/modules/oldfilm/filter_dust.c
src/modules/oldfilm/filter_lines.c
src/modules/plus/filter_affine.c
src/modules/plus/transition_affine.c
src/modules/qimage/producer_kdenlivetitle.c
src/modules/qimage/producer_qimage.c
src/modules/sox/filter_sox.c
src/modules/vorbis/producer_vorbis.c

index f7db4a68cc289de0416e28dfb5d39f165eef7acc..f9a2e6ec84d613d0af656ba6f854f3752aba738c 100644 (file)
@@ -128,6 +128,8 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        if( error != 0 )
                mlt_properties_debug( frame_properties, "error after mlt_frame_get_image() in autotrack_rectangle", stderr );
 
+       mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
        // Get the geometry object
        mlt_geometry geometry = mlt_properties_get_data(filter_properties, "filter_geometry", NULL);
 
@@ -171,7 +173,9 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                mlt_geometry_insert(geometry, &boundry);
        }
 
-               if( mlt_properties_get_int( filter_properties, "debug" ) == 1 )
+       mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
+
+       if( mlt_properties_get_int( filter_properties, "debug" ) == 1 )
        {
                init_arrows( format, *width, *height );
                draw_rectangle_outline(*image, boundry.x, boundry.y, boundry.w, boundry.h, 100);
@@ -213,6 +217,8 @@ static int attach_boundry_to_frame( mlt_frame frame, uint8_t **image, mlt_image_
        // Get the frame position
        mlt_position position = mlt_frame_get_position( frame );
        
+       mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
        // Get the geometry object
        mlt_geometry geometry = mlt_properties_get_data(filter_properties, "filter_geometry", NULL);
        if (geometry == NULL) {
@@ -232,6 +238,8 @@ static int attach_boundry_to_frame( mlt_frame frame, uint8_t **image, mlt_image_
                geometry = mlt_properties_get_data(filter_properties, "filter_geometry", NULL);
        }
 
+       mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
+
        // Get the current geometry item
        mlt_geometry_item geometry_item = mlt_pool_alloc( sizeof( struct mlt_geometry_item_s ) );
        mlt_geometry_fetch(geometry, geometry_item, position);
index c1f91071e0fac7c16313d52d31581d3c34970840..902b66cb586de4bdf948b5781376284c9789405a 100644 (file)
@@ -63,6 +63,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        // Producers may start with blank footage, by default we will skip, oh, 5 frames unless overridden
        int skip = mlt_properties_get_int( properties, "skip");
 
+       mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
        // The result
        mlt_geometry_item bounds = mlt_properties_get_data( properties, "bounds", NULL );
 
@@ -191,6 +193,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        /* inject into frame */
        mlt_properties_set_data( MLT_FRAME_PROPERTIES(this), "bounds", bounds, sizeof( struct mlt_geometry_item_s ), NULL, NULL );
 
+       mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
+
        return error;
 }
 
index 25cfe524dd9da9bb4d0629190fcbe1b484a878f5..d2dff28402960da64f61e99e35495ee8accf21ed 100644 (file)
@@ -782,10 +782,11 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        // Get the filter
        mlt_filter filter = mlt_frame_pop_service( frame );
 
+       mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
        // Get the motion_est context object
        struct motion_est_context_s *c = mlt_properties_get_data( MLT_FILTER_PROPERTIES( filter ), "context", NULL);
 
-
        // Get the new image and frame number
        *format = mlt_image_yuv422;
        int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
@@ -1030,7 +1031,6 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        // Remember which frame this is
        c->former_frame_position = c->current_frame_position;
 
-
        mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.macroblock_width", c->mb_w );
        mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.macroblock_height", c->mb_h );
        mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.left_mb", c->left_mb );
@@ -1043,6 +1043,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        fprintf(stderr, " in frame %d:%d usec\n", c->current_frame_position, difference);
        #endif
 
+       mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
 
        return error;
 }
index 5a03f8555bc6886c7807fd867ffda0c6d9268db1..663d1522ccd5c183d37436b4786fda7aab8387fe 100644 (file)
@@ -201,6 +201,8 @@ static int filter_get_audio( mlt_frame frame, void **buffer, mlt_audio_format *f
        int samplemax = (1 << (bytes_per_samp * 8 - 1)) - 1;
        int samplemin = -samplemax - 1;
 
+       mlt_service_lock( MLT_FILTER_SERVICE( this ) );
+
        if ( normalise )
        {
                int window = mlt_properties_get_int( filter_props, "window" );
@@ -252,6 +254,8 @@ static int filter_get_audio( mlt_frame frame, void **buffer, mlt_audio_format *f
        mlt_properties_set_double( filter_props, "_previous_gain", gain );
        mlt_properties_set_position( filter_props, "_last_position", current_position );
 
+       mlt_service_unlock( MLT_FILTER_SERVICE( this ) );
+
        // Ramp from the previous gain to the current
        gain = previous_gain;
 
index 140b759d369288c24d8c780140c5c0b51cb54564..d48ad87874779f49e3b9a2060f70f33eb5225d62 100644 (file)
@@ -86,6 +86,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                return 0;
        srand(position*10000);
 
+       mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
        int im=rand()%maxcount;
        int piccount=mlt_properties_count(direntries);
        while (im-- && piccount){
@@ -155,6 +157,9 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                        overlay_image ( *image , *width, *height , luma_image , dx , mlt_properties_get_int ( properties , cachedy ) , alpha , x1 , y1 , updown , mirror );
                }
        }
+
+       mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
+
        if (piccount>0 )
                return 0;
        if ( error == 0 && *image )
index bd77c2397d7e56ec26b2952a117deefd3c0045cf..d4a9bdfc79347d2510d6560bd07333b215d699db 100644 (file)
@@ -52,6 +52,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                if (!width_line)
                        return 0;
                
+               mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
                while (num--){
                        int type=(rand()%3)+1;
                        int x1=(double)w*rand()/RAND_MAX;
@@ -105,6 +107,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                        mlt_properties_set_int(MLT_FILTER_PROPERTIES( filter ),buf,x1);
                }
                mlt_properties_set_double(MLT_FILTER_PROPERTIES( filter ),"last_oldfilm_line_pos",position);
+               mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
        }
 
        return error;
index c2b256f6321a7bf6be501fc157ee6ca7d22be8ef..a59ba86a464ea9ebdea16b8ea601bd03da48a3f3 100644 (file)
@@ -44,6 +44,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        // Only process if we have no error and a valid colour space
        if ( error == 0 )
        {
+               mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
                mlt_producer producer = mlt_properties_get_data( properties, "producer", NULL );
                mlt_transition transition = mlt_properties_get_data( properties, "transition", NULL );
                mlt_frame a_frame = NULL;
@@ -106,6 +107,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                        mlt_properties_set_data( frame_properties, "image", *image, *width * *height * 4, NULL, NULL );
                        mlt_properties_set_data( frame_properties, "alpha", mlt_frame_get_alpha_mask( a_frame ), *width * *height, NULL, NULL );
                }
+               mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
        }
 
        return error;
index 04723ca430d5b4d95e47d22a86afa0e444af1133..3616e18391f6014b393fba6c3e74c5b274da03c6 100644 (file)
@@ -412,7 +412,9 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
        mlt_frame_get_image( a_frame, image, format, width, height, 1 );
 
        // Calculate the region now
+       mlt_service_lock( MLT_TRANSITION_SERVICE( this ) );
        composite_calculate( this, &result, normalised_width, normalised_height, ( float )position );
+       mlt_service_unlock( MLT_TRANSITION_SERVICE( this ) );
 
        // Fetch the b frame image
        result.w = ( result.w * *width / normalised_width );
index caf82d90a44f72767468db3204287b26eadcfcc9..6a90abde67730964e9d57492e3ee5fdc49848e2c 100644 (file)
@@ -63,6 +63,8 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        /* Allocate the image */
        int size = *width * ( *height ) * 4;
 
+       mlt_service_lock( MLT_PRODUCER_SERVICE( &this->parent ) );
+
        /* Allocate the image */
        *format = mlt_image_rgb24a;
        mlt_position time = mlt_producer_position( &this->parent ) + mlt_producer_get_in( &this->parent );
@@ -94,6 +96,8 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                mlt_log_debug( MLT_PRODUCER_SERVICE( &this->parent ), "width:%d height:%d %s\n", *width, *height, mlt_image_format_name( *format ) );
        }
 
+       mlt_service_unlock( MLT_PRODUCER_SERVICE( &this->parent ) );
+
        return 0;
 }
 
index 9ed5c1eed6339d3b75e9fc08b67e67cdc752aad1..561eef9f58187892397eb228245352a065c070f6 100644 (file)
@@ -161,6 +161,8 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        *width = mlt_properties_get_int( properties, "rescale_width" );
        *height = mlt_properties_get_int( properties, "rescale_height" );
 
+       mlt_service_lock( MLT_PRODUCER_SERVICE( &this->parent ) );
+
        // Refresh the image
        refresh_qimage( this, frame, *width, *height );
 
@@ -192,6 +194,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        // Release references and locks
        pthread_mutex_unlock( &this->mutex );
        mlt_cache_item_close( this->image_cache );
+       mlt_service_unlock( MLT_PRODUCER_SERVICE( &this->parent ) );
 
        return error;
 }
index 9dfe1bd5d16792c58cabee6b426ae89a90bbb280..34504bf9047a2e366f3b2fcc9cd8f096ae0eec0d 100644 (file)
@@ -195,6 +195,8 @@ static int filter_get_audio( mlt_frame frame, void **buffer, mlt_audio_format *f
        // Get the filter properties
        mlt_properties filter_properties = MLT_FILTER_PROPERTIES( filter );
 
+       mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
        // Get the properties
        st_sample_t *input_buffer;// = mlt_properties_get_data( filter_properties, "input_buffer", NULL );
        st_sample_t *output_buffer = mlt_properties_get_data( filter_properties, "output_buffer", NULL );
@@ -364,6 +366,8 @@ static int filter_get_audio( mlt_frame frame, void **buffer, mlt_audio_format *f
                }
        }
 
+       mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
+
        return 0;
 }
 
index b5a12c4e365a85e685122397c61911c3038821b7..99499b28f9e69e6abe908aa29bfabd1ba7c4fa04 100644 (file)
@@ -220,6 +220,8 @@ static int producer_get_audio( mlt_frame frame, void **buffer, mlt_audio_format
        // Get the producer properties
        mlt_properties properties = MLT_PRODUCER_PROPERTIES( this );
 
+       mlt_service_lock( MLT_PRODUCER_SERVICE( this ) );
+
        // Get the ogg vorbis file
        OggVorbis_File *ov = mlt_properties_get_data( properties, "ogg_vorbis_file", NULL );
 
@@ -342,6 +344,8 @@ static int producer_get_audio( mlt_frame frame, void **buffer, mlt_audio_format
        // Regardless of speed, we expect to get the next frame (cos we ain't too bright)
        mlt_properties_set_position( properties, "audio_expected", position + 1 );
 
+       mlt_service_unlock( MLT_PRODUCER_SERVICE( this ) );
+
        return 0;
 }