mlt_properties_set_int( properties, "height", 480 );
mlt_properties_set_int( properties, "progressive", 0 );
}
+
+ // Default aspect ratio
mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 );
// Default rescaler for all consumers
mlt_properties_set( properties, "rescale", "bilinear" );
+
+ // Default read ahead buffer size
+ mlt_properties_set_int( properties, "buffer", 25 );
+
+ // Hmm - default all consumers to yuv422 :-/
+ this->format = mlt_image_yuv422;
}
return error;
}
int width = mlt_properties_get_int( properties, "width" );
int height = mlt_properties_get_int( properties, "height" );
+ // Get the maximum size of the buffer
+ int buffer = mlt_properties_get_int( properties, "buffer" );
+
// General frame variable
mlt_frame frame = NULL;
uint8_t *image = NULL;
{
// Put the current frame into the queue
pthread_mutex_lock( &this->mutex );
- while( this->ahead && mlt_deque_count( this->queue ) >= 25 )
+ while( this->ahead && mlt_deque_count( this->queue ) >= buffer )
pthread_cond_wait( &this->cond, &this->mutex );
mlt_deque_push_back( this->queue, frame );
pthread_cond_broadcast( &this->cond );
}
}
-mlt_frame mlt_consumer_rt_frame( mlt_consumer this, mlt_image_format format )
+mlt_frame mlt_consumer_rt_frame( mlt_consumer this )
{
// Frame to return
mlt_frame frame = NULL;
int size = 1;
-
// Is the read ahead running?
if ( this->ahead == 0 )
{
- this->format = format;
+ int buffer = mlt_properties_get_int( mlt_consumer_properties( this ), "buffer" );
consumer_read_ahead_start( this );
- size = 12;
+ if ( buffer > 1 )
+ size = buffer / 2;
}
// Get frame from queue
extern int mlt_consumer_connect( mlt_consumer this, mlt_service producer );
extern int mlt_consumer_start( mlt_consumer this );
extern mlt_frame mlt_consumer_get_frame( mlt_consumer this );
-extern mlt_frame mlt_consumer_rt_frame( mlt_consumer this, mlt_image_format format );
+extern mlt_frame mlt_consumer_rt_frame( mlt_consumer this );
extern int mlt_consumer_stop( mlt_consumer this );
extern int mlt_consumer_is_stopped( mlt_consumer this );
extern void mlt_consumer_close( mlt_consumer );
mlt_position out = mlt_transition_get_out( this );
// Get the position of the frame
- mlt_position position = mlt_frame_get_position( frame );
+ char *name = mlt_properties_get( mlt_transition_properties( this ), "_unique_id" );
+ mlt_position position = mlt_properties_get_position( mlt_frame_properties( frame ), name );
// Now do the calcs
return ( float )( position - in ) / ( float )( out - in + 1 );
// This will hold the size of the dv frame
int size = 0;
+ // Is the image rendered
+ int rendered = mlt_properties_get_int( mlt_frame_properties( frame ), "rendered" );
+
+ // Get width and height
+ int width = mlt_properties_get_int( this_properties, "width" );
+ int height = mlt_properties_get_int( this_properties, "height" );
+
// If we get an encoder, then encode the image
- if ( encoder != NULL )
+ if ( rendered && encoder != NULL )
{
// Specify desired image properties
mlt_image_format fmt = mlt_image_yuv422;
- int width = mlt_properties_get_int( this_properties, "width" );
- int height = mlt_properties_get_int( this_properties, "height" );
uint8_t *image = NULL;
// Get the image
dv_encode_full_frame( encoder, &image, e_dv_color_yuv, dv_frame );
}
}
+ else if ( encoder != NULL )
+ {
+ // Calculate the size of the dv frame (duplicate of previous)
+ size = height == 576 ? frame_size_625_50 : frame_size_525_60;
+ }
return size;
}
while( mlt_properties_get_int( properties, "running" ) )
{
// Get the frame
- mlt_frame frame = mlt_consumer_rt_frame( this, mlt_image_yuv422 );
+ mlt_frame frame = mlt_consumer_rt_frame( this );
// Check that we have a frame to work with
if ( frame != NULL )
// Default scaler (for now we'll use nearest)
mlt_properties_set( this->properties, "rescale", "nearest" );
+ // Default buffer for low latency
+ mlt_properties_set_int( this->properties, "buffer", 8 );
+
// Default progressive true
mlt_properties_set_int( this->properties, "progressive", 1 );
// Get the image, width and height
mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 );
- if ( playtime > elapsed + 20000 )
+ if ( playtime > elapsed + 25000 )
{
struct timespec tm = { ( playtime - elapsed ) / 1000000, ( ( playtime - elapsed ) % 1000000 ) * 1000 };
nanosleep( &tm, NULL );
while( this->running )
{
// Get a frame from the attached producer
- mlt_frame frame = mlt_consumer_rt_frame( consumer, mlt_image_yuv422 );
+ mlt_frame frame = mlt_consumer_rt_frame( consumer );
// Ensure that we have a frame
if ( frame != NULL )