]> git.sesse.net Git - mlt/commitdiff
Add mlt_frame_write_ppm to visualize debugging.
authorDan Dennedy <dan@dennedy.org>
Thu, 23 Dec 2010 07:33:41 +0000 (23:33 -0800)
committerDan Dennedy <dan@dennedy.org>
Thu, 23 Dec 2010 07:33:41 +0000 (23:33 -0800)
src/framework/mlt_frame.c
src/framework/mlt_frame.h

index 1a49e74ac1d5094b958d04c31b9325833586b95e..76afc2208c806fab12a65cf05014a65c46d333ba 100644 (file)
@@ -830,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 );
+       }
+}
index 07f834ef129135b8dec63f9aa4088c02db87def5..6aefb3803c87140c3103c043bf32d306281992f4 100644 (file)
@@ -132,6 +132,7 @@ extern int mlt_sample_calculator( float fps, int frequency, int64_t position );
 extern int64_t mlt_sample_calculator_to_now( float fps, int frequency, int64_t position );
 extern const char * mlt_image_format_name( mlt_image_format format );
 extern const char * mlt_audio_format_name( mlt_audio_format format );
+extern void mlt_frame_write_ppm( mlt_frame frame );
 
 /** This macro scales RGB into the YUV gamut - y is scaled by 219/255 and uv by 224/255. */
 #define RGB2YUV_601_SCALED(r, g, b, y, u, v)\