]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_frame.c
Fix underlinking python binding (3082761).
[mlt] / src / framework / mlt_frame.c
index 3b644d1330babb7ea61e5ef4082c27677789c12c..76afc2208c806fab12a65cf05014a65c46d333ba 100644 (file)
@@ -493,9 +493,6 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for
                mlt_properties_set_int( properties, "test_image", 1 );
        }
 
-       mlt_properties_set_int( properties, "scaled_width", *width );
-       mlt_properties_set_int( properties, "scaled_height", *height );
-
        return error;
 }
 
@@ -517,7 +514,7 @@ uint8_t *mlt_frame_get_alpha_mask( mlt_frame this )
                        alpha = mlt_properties_get_data( &this->parent, "alpha", NULL );
                if ( alpha == NULL )
                {
-                       int size = mlt_properties_get_int( &this->parent, "scaled_width" ) * mlt_properties_get_int( &this->parent, "scaled_height" );
+                       int size = mlt_properties_get_int( &this->parent, "width" ) * mlt_properties_get_int( &this->parent, "height" );
                        alpha = mlt_pool_alloc( size );
                        memset( alpha, 255, size );
                        mlt_properties_set_data( &this->parent, "alpha", alpha, size, mlt_pool_release, NULL );
@@ -698,6 +695,13 @@ unsigned char *mlt_frame_get_waveform( mlt_frame this, int w, int h )
        double fps = mlt_producer_get_fps( mlt_producer_cut_parent( producer ) );
        int samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( this ) );
 
+       // Increase audio resolution proportional to requested image size
+       while ( samples < w )
+       {
+               frequency += 16000;
+               samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( this ) );
+       }
+
        // Get the pcm data
        mlt_frame_get_audio( this, (void**)&pcm, &format, &frequency, &channels, &samples );
 
@@ -711,8 +715,7 @@ unsigned char *mlt_frame_get_waveform( mlt_frame this, int w, int h )
        // Render vertical lines
        int16_t *ubound = pcm + samples * channels;
        int skip = samples / w;
-       if ( !skip )
-               return NULL;
+       skip = !skip ? 1 : skip;
        unsigned char gray = 0xFF / skip;
        int i, j, k;
 
@@ -827,3 +830,25 @@ int64_t mlt_sample_calculator_to_now( float fps, int frequency, int64_t position
 
        return samples;
 }
+
+void mlt_frame_write_ppm( mlt_frame frame )
+{
+       int width;
+       int height;
+       mlt_image_format format = mlt_image_rgb24;
+       uint8_t *image;
+       
+       if ( mlt_frame_get_image( frame, &image, &format, &width, &height, 0 ) == 0 )
+       {
+               FILE *file;
+               char filename[16];
+               
+               sprintf( filename, "frame-%05d.ppm", mlt_frame_get_position( frame ) );
+               file = fopen( filename, "wb" );
+               if ( !file )
+                       return;
+               fprintf( file, "P6\n%d %d\n255\n", width, height);
+               fwrite( image, width * height * 3, 1, file );
+               fclose( file );
+       }
+}