X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fcore%2Fproducer_noise.c;h=7746c0d855afb8f22e559feeb8fc6b10f907049c;hb=5998e04fc78baf161cb12bd0e62254ed570b6b2b;hp=9afe3853602e3cec3fe9d14264821e5a306f1908;hpb=a2b4b63a98cff9bbf979f446d0351d8978365518;p=melted diff --git a/src/modules/core/producer_noise.c b/src/modules/core/producer_noise.c index 9afe385..7746c0d 100644 --- a/src/modules/core/producer_noise.c +++ b/src/modules/core/producer_noise.c @@ -42,6 +42,7 @@ static unsigned inline int fast_rand( ) // Foward declarations static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index ); +static void producer_close( mlt_producer this ); /** Initialise. */ @@ -54,8 +55,14 @@ mlt_producer producer_noise_init( void *arg ) // Initialise the producer if ( this != NULL ) { + int is_pal = mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( this ), "normalised_height" ) == 576; + + // Synthetic - aspect ratio of 1 + mlt_properties_set_double( MLT_PRODUCER_PROPERTIES( this ), "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 ); + // Callback registration this->get_frame = producer_get_frame; + this->close = ( mlt_destructor )producer_close; } return this; @@ -64,7 +71,7 @@ mlt_producer producer_noise_init( void *arg ) static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) { // Obtain properties of frame - mlt_properties properties = mlt_frame_properties( frame ); + mlt_properties properties = MLT_FRAME_PROPERTIES( frame ); // Calculate the size of the image int size = *width * *height * 2; @@ -104,7 +111,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form static int producer_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) { // Get the frame properties - mlt_properties properties = mlt_frame_properties( frame ); + mlt_properties properties = MLT_FRAME_PROPERTIES( frame ); int size = 0; @@ -124,7 +131,7 @@ static int producer_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_form { int16_t *p = *buffer + size / 2; while ( p != *buffer ) - *( -- p ) = fast_rand( ) & 0xff; + *( -- p ) = fast_rand( ) & 0x0f00; } // Set the buffer for destruction @@ -142,10 +149,16 @@ static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index if ( *frame != NULL ) { // Obtain properties of frame - mlt_properties properties = mlt_frame_properties( *frame ); + mlt_properties properties = MLT_FRAME_PROPERTIES( *frame ); + + // Obtain properties of producer + mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( this ); + + // Determine if we're producing PAL or NTSC + int is_pal = mlt_properties_get_double( producer_props, "fps" ) == 25.0; // Aspect ratio is 1? - mlt_properties_set_double( properties, "aspect_ratio", 1.0 ); + mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 ); // Set producer-specific frame properties mlt_properties_set_int( properties, "progressive", 1 ); @@ -166,4 +179,10 @@ static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index return 0; } +static void producer_close( mlt_producer this ) +{ + this->close = NULL; + mlt_producer_close( this ); + free( this ); +}