j++;
}
}
- smoothed /= j;
+ if (j) smoothed /= j;
// fprintf( stderr, "smoothed over %d values, result %f\n", j, smoothed );
return smoothed;
// Get the properties from the filter
mlt_properties filter_props = MLT_FILTER_PROPERTIES( this );
- // Get the properties of the a frame
- mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
-
// Get the frame's filter instance properties
mlt_properties instance_props = mlt_frame_unique_properties( frame, MLT_FILTER_SERVICE( this ) );
static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
{
- mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
mlt_properties filter_props = MLT_FILTER_PROPERTIES( this );
mlt_properties instance_props = mlt_frame_unique_properties( frame, MLT_FILTER_SERVICE( this ) );
// If there is an end adjust gain to the range
if ( mlt_properties_get( filter_props, "end" ) != NULL )
{
- // Determine the time position of this frame in the transition duration
- mlt_position in = mlt_filter_get_in( this );
- mlt_position out = mlt_filter_get_out( this );
- mlt_position time = mlt_frame_get_position( frame );
- double position = ( double )( time - in ) / ( double )( out - in + 1 );
-
double end = -1;
char *p = mlt_properties_get( filter_props, "end" );
if ( strcmp( p, "" ) != 0 )
end = fabs( end );
if ( end != -1 )
- gain += ( end - gain ) * position;
+ gain += ( end - gain ) * mlt_filter_get_progress( this, frame );
}
}
}
// If there is an end adjust gain to the range
if ( mlt_properties_get( filter_props, "end" ) != NULL )
{
- // Determine the time position of this frame in the transition duration
- mlt_position in = mlt_filter_get_in( this );
- mlt_position out = mlt_filter_get_out( this );
- mlt_position time = mlt_frame_get_position( frame );
- double position = ( double )( time - in ) / ( double )( out - in + 1 );
- amplitude *= position;
+ amplitude *= mlt_filter_get_progress( this, frame );
}
mlt_properties_set_int( instance_props, "normalise", 1 );
mlt_properties_set_double( instance_props, "amplitude", amplitude );
mlt_filter filter_volume_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 );
+ mlt_filter this = calloc( 1, sizeof( struct mlt_filter_s ) );
if ( this != NULL && mlt_filter_init( this, NULL ) == 0 )
{
mlt_properties properties = MLT_FILTER_PROPERTIES( this );