X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fcore%2Fproducer_noise.c;h=54d0474dc8882964360452b8c211b034c74c9353;hb=95f429b56026f5897ebad9060608b6631dcf7515;hp=9c586c1046a34176baaaf922d233506ad90f518f;hpb=5b59ce704d4f317e845afa30c5ade12c0fd22d43;p=melted diff --git a/src/modules/core/producer_noise.c b/src/modules/core/producer_noise.c index 9c586c1..54d0474 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,12 @@ mlt_producer producer_noise_init( void *arg ) // Initialise the producer if ( this != NULL ) { + // Synthetic - aspect ratio of 1 + mlt_properties_set_double( mlt_producer_properties( this ), "aspect_ratio", 1 ); + // Callback registration this->get_frame = producer_get_frame; + this->close = ( mlt_destructor )producer_close; } return this; @@ -92,11 +97,9 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form // Generate random noise while ( p != *buffer ) { - value = fast_rand( ); - *( -- p ) = 128; - *( -- p ) = value & 0xff; + value = fast_rand( ) & 0xff; *( -- p ) = 128; - *( -- p ) = ( ( value & 0xff00 ) >> 8 ) & 0xf0; + *( -- p ) = value < 16 ? 16 : value > 240 ? 240 : value; } } @@ -126,7 +129,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 @@ -146,8 +149,14 @@ static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index // Obtain properties of 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 ? 128.0/117.0 : 72.0/79.0 ); // Set producer-specific frame properties mlt_properties_set_int( properties, "progressive", 1 ); @@ -168,4 +177,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 ); +}