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 ) );
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;
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
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
{
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;
}
}
- 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 ) ) )
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 );
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
{
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;
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
}
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;
// 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;
// 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" ) )
{
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 );
}
{
// 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 )
{
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);