Merge ../mlt
[melted] / mlt++ / src / MltFrame.cpp
index 0595a68..643f419 100644 (file)
  */
 
 #include "MltFrame.h"
+#include "MltProducer.h"
 using namespace Mlt;
 
 Frame::Frame( mlt_frame frame ) :
-       destroy( true ),
        instance( frame )
 {
+       inc_ref( );
 }
 
 Frame::Frame( Frame &frame ) :
-       destroy( false ),
+       Mlt::Properties( frame ),
        instance( frame.get_frame( ) )
 {
+       inc_ref( );
 }
 
 Frame::~Frame( )
 {
-       if ( destroy )
-               mlt_frame_close( instance );
+       mlt_frame_close( instance );
 }
 
 mlt_frame Frame::get_frame( )
@@ -52,8 +53,8 @@ mlt_properties Frame::get_properties( )
 uint8_t *Frame::get_image( mlt_image_format &format, int &w, int &h, int writable )
 {
        uint8_t *image = NULL;
-       if ( mlt_properties_get_int( get_properties( ), "consumer_aspect_ratio" ) == 0 )
-               mlt_properties_set_int( get_properties( ), "consumer_aspect_ratio", 1 );
+       if ( get_double( "consumer_aspect_ratio" ) == 0.0 )
+               set( "consumer_aspect_ratio", 1.0 );
        mlt_frame_get_image( get_frame( ), &image, &format, &w, &h, writable );
        set( "format", format );
        set( "writable", writable );
@@ -63,8 +64,8 @@ uint8_t *Frame::get_image( mlt_image_format &format, int &w, int &h, int writabl
 unsigned char *Frame::fetch_image( mlt_image_format f, int w, int h, int writable )
 {
        uint8_t *image = NULL;
-       if ( mlt_properties_get_int( get_properties( ), "consumer_aspect_ratio" ) == 0 )
-               mlt_properties_set_int( get_properties( ), "consumer_aspect_ratio", 1 );
+       if ( get_double( "consumer_aspect_ratio" ) == 0.0 )
+               set( "consumer_aspect_ratio", 1.0 );
        mlt_frame_get_image( get_frame( ), &image, &f, &w, &h, writable );
        set( "format", f );
        set( "writable", writable );
@@ -78,4 +79,12 @@ int16_t *Frame::get_audio( mlt_audio_format &format, int &frequency, int &channe
        return audio;
 }
 
+unsigned char *Frame::get_waveform( int w, int h )
+{
+       return mlt_frame_get_waveform( get_frame( ), w, h );
+}
 
+Producer *Frame::get_original_producer( )
+{
+       return new Producer( mlt_frame_get_original_producer( get_frame( ) ) );
+}