]> git.sesse.net Git - mlt/commitdiff
add mlt_frame_clone()
authorDan Dennedy <dan@dennedy.org>
Fri, 11 Nov 2011 03:42:13 +0000 (19:42 -0800)
committerDan Dennedy <dan@dennedy.org>
Sat, 12 Nov 2011 20:07:39 +0000 (12:07 -0800)
src/framework/mlt_frame.c
src/framework/mlt_frame.h

index 42d23f95a3d12c23d7a9d1dbf00395104f14ef86..fec200edd40969aa95c698f24376a91d58c76dfb 100644 (file)
@@ -977,3 +977,37 @@ mlt_properties mlt_frame_unique_properties( mlt_frame self, mlt_service service
 
        return instance_props;
 }
+
+/** Make a copy of a frame.
+ *
+ * This does not copy the get_image/get_audio processing stacks or any
+ * data properties other than the audio and image.
+ *
+ * \public \memberof mlt_frame_s
+ * \param self the frame to clone
+ * \return a almost-complete copy of the frame
+ * \todo copy the processing deques
+ */
+
+mlt_frame mlt_frame_clone( mlt_frame self )
+{
+       mlt_frame new_frame = mlt_frame_init( NULL );
+       mlt_properties properties = MLT_FRAME_PROPERTIES( self );
+       mlt_properties new_props = MLT_FRAME_PROPERTIES( new_frame );
+       void *data;
+       int size;
+
+       // This frame takes a reference on the original frame since the data is a shallow copy.
+       mlt_properties_inc_ref( properties );
+       mlt_properties_set_data( new_props, "_cloned_frame", self, 0,
+               (mlt_destructor) mlt_frame_close, NULL );
+
+       // Copy properties
+       mlt_properties_inherit( new_props, properties );
+       data = mlt_properties_get_data( properties, "audio", &size );
+       mlt_properties_set_data( new_props, "audio", data, size, NULL, NULL );
+       data = mlt_properties_get_data( properties, "image", &size );
+       mlt_properties_set_data( new_props, "image", data, size, NULL, NULL );
+
+       return new_frame;
+}
index 01ccb084e369f3fd2bba00b3590d72af1ffcab56..226f6148604045b84256693261ee66d605bc1793 100644 (file)
@@ -138,6 +138,7 @@ extern mlt_deque mlt_frame_service_stack( mlt_frame self );
 extern mlt_producer mlt_frame_get_original_producer( mlt_frame self );
 extern void mlt_frame_close( mlt_frame self );
 extern mlt_properties mlt_frame_unique_properties( mlt_frame self, mlt_service service );
+extern mlt_frame mlt_frame_clone( mlt_frame self );
 
 /* convenience functions */
 extern int mlt_sample_calculator( float fps, int frequency, int64_t position );