]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_frame.c
rc/framework/mlt_frame.c
[mlt] / src / framework / mlt_frame.c
index 12a66d6bbb25c839081ec9b25e5a9a25367e0a43..0f54d4dfbae552235175f04059cc62f20c95166e 100644 (file)
@@ -267,6 +267,7 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for
        
        if ( get_image != NULL )
        {
+               mlt_properties_set_int( properties, "image_count", mlt_properties_get_int( properties, "image_count" ) - 1 );
                mlt_position position = mlt_frame_get_position( this );
                error = get_image( this, buffer, format, width, height, writable );
                mlt_frame_set_position( this, position );
@@ -312,7 +313,7 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for
 
                mlt_properties_set_int( properties, "width", *width );
                mlt_properties_set_int( properties, "height", *height );
-               mlt_properties_set_int( properties, "aspect_ratio", 1 );
+               mlt_properties_set_int( properties, "aspect_ratio", 0 );
 
                switch( *format )
                {
@@ -971,8 +972,8 @@ int mlt_frame_mix_audio( mlt_frame this, mlt_frame that, float weight_start, flo
        int i, j;
        double d = 0, s = 0;
 
-       mlt_frame_get_audio( this, &dest, format, &frequency_dest, &channels_dest, &samples_dest );
        mlt_frame_get_audio( that, &src, format, &frequency_src, &channels_src, &samples_src );
+       mlt_frame_get_audio( this, &dest, format, &frequency_dest, &channels_dest, &samples_dest );
 
        int silent = mlt_properties_get_int( MLT_FRAME_PROPERTIES( this ), "silent_audio" );
        mlt_properties_set_int( MLT_FRAME_PROPERTIES( this ), "silent_audio", 0 );
@@ -1065,3 +1066,32 @@ int mlt_sample_calculator( float fps, int frequency, int64_t position )
 
        return samples;
 }
+
+int64_t mlt_sample_calculator_to_now( float fps, int frequency, int64_t frame )
+{
+       int64_t samples = 0;
+
+       // TODO: Correct rules for NTSC and drop the * 100 hack
+       if ( ( int )( fps * 100 ) == 2997 )
+       {
+               samples = ( ( double )( frame * frequency ) / 30 );
+               switch( frequency )
+               {
+                       case 48000:
+                               samples += 2 * ( frame / 5 );
+                               break;
+                       case 44100:
+                               samples += frame + ( frame / 2 ) - ( frame / 30 ) + ( frame / 300 );
+                               break;
+                       case 32000:
+                               samples += ( 2 * frame ) - ( frame / 4 ) - ( frame / 29 );
+                               break;
+               }
+       }
+       else if ( fps != 0 )
+       {
+               samples = ( ( frame * frequency ) / ( int )fps );
+       }
+
+       return samples;
+}