]> git.sesse.net Git - mlt/commitdiff
make mlt_position type double
authorMaksym Veremeyenko <verem@m1stereo.tv>
Tue, 14 May 2013 08:28:10 +0000 (11:28 +0300)
committerDan Dennedy <dan@dennedy.org>
Sat, 25 May 2013 19:54:25 +0000 (12:54 -0700)
src/framework/mlt_consumer.c
src/framework/mlt_frame.c
src/framework/mlt_types.h
src/modules/avformat/producer_avformat.c
src/modules/avsync/consumer_blipflash.c
src/modules/core/filter_luma.c
src/modules/dgraft/filter_telecide.c
src/modules/gtk2/producer_count.c
src/modules/kdenlive/producer_framebuffer.c
src/modules/xine/filter_deinterlace.c

index f9eb80651338ede8a5bd8c870dba7b14314b89d4..2791a0171b18148c5b2b49c13072e4d87ce545e3 100644 (file)
@@ -990,7 +990,7 @@ static void *consumer_worker_thread( void *arg )
                frame = mlt_deque_peek( priv->queue, index );
                if ( frame )
                {
-                       mlt_log_debug( MLT_CONSUMER_SERVICE(self), "worker processing index = %d frame %d queue count = %d\n",
+                       mlt_log_debug( MLT_CONSUMER_SERVICE(self), "worker processing index = %d frame " MLT_POSITION_FMT " queue count = %d\n",
                                index, mlt_frame_get_position(frame), mlt_deque_count( priv->queue ) );
                        frame->is_processing = 1;
                        mlt_properties_inc_ref( MLT_FRAME_PROPERTIES( frame ) );
index 988b31097f172b7a945051b111ebea6d1992e7df..7c8b5f83145a30a26cf429b223d955f9ea3c5905 100644 (file)
@@ -982,7 +982,7 @@ void mlt_frame_write_ppm( mlt_frame frame )
                FILE *file;
                char filename[16];
                
-               sprintf( filename, "frame-%05d.ppm", mlt_frame_get_position( frame ) );
+               sprintf( filename, "frame-%05d.ppm", (int)mlt_frame_get_position( frame ) );
                file = fopen( filename, "wb" );
                if ( !file )
                        return;
index c1574d4471481d80ceca65fcb4223167d4886cf5..764c0c4d1bdefa5a62d48e387f474a95eeca88e2 100644 (file)
@@ -103,10 +103,14 @@ typedef enum
 mlt_service_type;
 
 /* I don't want to break anyone's applications without warning. -Zach */
-#undef DOUBLE_MLT_POSITION
+#define DOUBLE_MLT_POSITION
 #ifdef DOUBLE_MLT_POSITION
+#define MLT_POSITION_FMT "%f"
+#define MLT_POSITION_MOD(A, B) (A - B * ((int)(A / B)))
 typedef double mlt_position;
 #else
+#define MLT_POSITION_MOD(A, B) A % B
+#define MLT_POSITION_FMT "%d"
 typedef int32_t mlt_position;
 #endif
 
index d7a34e83eebbbb18bd646ca588cba83f6e6fdac0..89d59b7ea39434b72f30eed0301d461a13db2034 100644 (file)
@@ -959,7 +959,7 @@ static int seek_video( producer_avformat self, mlt_position position,
                                timestamp -= 2 / av_q2d( self->video_time_base );
                        if ( timestamp < 0 )
                                timestamp = 0;
-                       mlt_log_debug( MLT_PRODUCER_SERVICE(producer), "seeking timestamp %"PRId64" position %d expected %d last_pos %"PRId64"\n",
+                       mlt_log_debug( MLT_PRODUCER_SERVICE(producer), "seeking timestamp %"PRId64" position " MLT_POSITION_FMT " expected "MLT_POSITION_FMT" last_pos %"PRId64"\n",
                                timestamp, position, self->video_expected, self->last_position );
 
                        // Seek to the timestamp
index 5de8a55934bd6674039ec53f82514841a1b48440..8c8faa58e60711826221c8b1d6bb6928151115ce 100644 (file)
@@ -324,13 +324,13 @@ static void report_results( avsync_stats* stats, mlt_position pos )
        {
                if( stats->sample_offset == INT_MAX )
                {
-                       fprintf( stats->out_file, "%d\t??\n", pos );
+                       fprintf( stats->out_file, MLT_POSITION_FMT "\t??\n", pos );
                }
                else
                {
                        // Convert to milliseconds.
                        double ms_offset = (double)stats->sample_offset * 1000.0 / (double)SAMPLE_FREQ;
-                       fprintf( stats->out_file, "%d\t%02.02f\n", pos, ms_offset );
+                       fprintf( stats->out_file, MLT_POSITION_FMT "\t%02.02f\n", pos, ms_offset );
                }
        }
        stats->blip = 0;
index 71af8367cb01509e94beb781d12a6defdd020ce3..37ceeb44ff679b1328a37fbe613d3ce3dac37189 100644 (file)
@@ -76,8 +76,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                }
        }
 
-       mlt_position modulo_pos = position % out;
-       mlt_log_debug( MLT_FILTER_SERVICE(filter), "pos %d mod period %d\n", position, modulo_pos );
+       mlt_position modulo_pos = MLT_POSITION_MOD(position, out);
+       mlt_log_debug( MLT_FILTER_SERVICE(filter), "pos " MLT_POSITION_FMT " mod period " MLT_POSITION_FMT "\n", position, modulo_pos );
        if ( luma != NULL &&
             ( mlt_properties_get( properties, "blur" ) != NULL ||
                   ( position >= duration && modulo_pos < duration - 1 ) ) )
@@ -103,7 +103,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
 
                if ( dst != NULL )
                {
-                       mlt_log_debug( MLT_FILTER_SERVICE(filter), "copying frame %d\n", modulo_pos );
+                       mlt_log_debug( MLT_FILTER_SERVICE(filter), "copying frame " MLT_POSITION_FMT "\n", modulo_pos );
                        mlt_properties b_props = MLT_FRAME_PROPERTIES( b_frame );
                        memcpy( dst, src, size );
                        mlt_frame_set_image( b_frame, dst, size, mlt_pool_release );
index 545def2416ea0d4fcfb6406fb6de296f710bd323..ab63b877593eac72ecffddb882f1b88c429476d8 100644 (file)
@@ -786,7 +786,7 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format
                uint8_t *image_copy = mlt_pool_alloc( image_size );
                memcpy( image_copy, *image, image_size );
                char key[20];
-               sprintf( key, "%d", pos );
+               sprintf( key, MLT_POSITION_FMT, pos );
                mlt_properties_set_data( cx->image_cache, key, image_copy, image_size, (mlt_destructor)mlt_pool_release, NULL );
                
                // Only if we have enough frame images cached
@@ -794,7 +794,7 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format
                {
                        pos -= cx->cycle + 1;
                        // Get the current frame image
-                       sprintf( key, "%d", pos );
+                       sprintf( key, MLT_POSITION_FMT, pos );
                        cx->fcrp = mlt_properties_get_data( cx->image_cache, key, NULL );
                        if (!cx->fcrp) return error;
                         
@@ -1148,7 +1148,7 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format
 
 final:                 
                        // Flush frame at tail of period from the cache
-                       sprintf( key, "%d", pos - 1 );
+                       sprintf( key, MLT_POSITION_FMT, pos - 1 );
                        mlt_properties_set_data( cx->image_cache, key, NULL, 0, NULL, NULL );
                }
                else
@@ -1159,7 +1159,7 @@ final:
        }
        else if ( error == 0 && *format == mlt_image_yuv420p )
        {
-               fprintf(stderr,"%s: %d pos %d\n", __FUNCTION__, *width * *height * 3/2, mlt_frame_get_position(frame) );
+               fprintf(stderr,"%s: %d pos " MLT_POSITION_FMT "\n", __FUNCTION__, *width * *height * 3/2, mlt_frame_get_position(frame) );
        }
 
        return error;
index 7e8c2c99fba153ef660144ab53fef084950948e7..40ee1a4db4bd1fb962164c9b1c0aa3dab95fa19b 100644 (file)
@@ -217,7 +217,7 @@ static mlt_frame get_text_frame( mlt_producer producer, mlt_position position )
 
                // Calculate clock values
                int seconds = position / fps;
-               int frames = position % fps;
+               int frames = MLT_POSITION_MOD(position, fps);
                int minutes = seconds / 60;
                seconds = seconds % 60;
                int hours = minutes / 60;
@@ -226,7 +226,7 @@ static mlt_frame get_text_frame( mlt_producer producer, mlt_position position )
                // Apply the time style
                if( !strcmp( style, "frames" ) )
                {
-                       snprintf( text, MAX_TEXT_LEN - 1, "%d", position );
+                       snprintf( text, MAX_TEXT_LEN - 1, MLT_POSITION_FMT, position );
                }
                else if( !strcmp( style, "timecode" ) )
                {
@@ -464,12 +464,12 @@ static void add_clock_to_frame( mlt_producer producer, mlt_frame frame, mlt_posi
        if( !strcmp( direction, "down" ) )
        {
                int out = mlt_producer_get_out( producer );
-               int frames = fps - (( out - position ) % fps);
+               int frames = fps - MLT_POSITION_MOD(out - position, fps);
                clock_angle = lrint( (frames + 1) * 360 / fps );
        }
        else
        {
-               int frames = position % fps;
+               int frames = MLT_POSITION_MOD(position, fps);
                clock_angle = lrint( (frames + 1) * 360 / fps );
        }
 
index bad5005a0612c55086e298944454bb4cb1963eca..e4780721ec99688275c9d3e972e2a0bb01d039a3 100644 (file)
@@ -74,7 +74,7 @@ static int framebuffer_get_image( mlt_frame frame, uint8_t **image, mlt_image_fo
                {
                        // Strobe effect wanted, calculate frame position
                        need_first = floor( actual_position );
-                       need_first -= need_first % strobe;
+                       need_first -= MLT_POSITION_MOD(need_first, strobe);
                }
                if ( freeze )
                {
index 34e763c3608d92e928a57f94d08427847c4b2156..70457e96dcc084eb2863f30d52f5f1d2972bc6f1 100644 (file)
@@ -111,7 +111,7 @@ static int deinterlace_yadif( mlt_frame frame, mlt_filter filter, uint8_t **imag
        int next_width = *width;
        int next_height = *height;
        
-       mlt_log_debug( MLT_FILTER_SERVICE(filter), "previous %d current %d next %d\n",
+       mlt_log_debug( MLT_FILTER_SERVICE(filter), "previous " MLT_POSITION_FMT " current " MLT_POSITION_FMT " next " MLT_POSITION_FMT "\n",
                previous_frame? mlt_frame_original_position(previous_frame) : -1,
                mlt_frame_original_position(frame),
                next_frame?  mlt_frame_original_position(next_frame) : -1);