X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fdv%2Fproducer_libdv.c;h=b82a0e66ef2f90e8382f6869b8eec4db5d6355a4;hb=73345685f05e06c7b2c6a9d2b5c6bcf1c642d82b;hp=05218cf3fe6d29445ff0af57bbac969e48070116;hpb=3e0edf239fc98d1180f73ff3ba4a0c1331147fae;p=melted diff --git a/src/modules/dv/producer_libdv.c b/src/modules/dv/producer_libdv.c index 05218cf..b82a0e6 100644 --- a/src/modules/dv/producer_libdv.c +++ b/src/modules/dv/producer_libdv.c @@ -51,9 +51,10 @@ mlt_producer producer_libdv_init( char *filename ) { producer_libdv this = calloc( sizeof( struct producer_libdv_s ), 1 ); - if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 ) + if ( filename != NULL && this != NULL && mlt_producer_init( &this->parent, this ) == 0 ) { mlt_producer producer = &this->parent; + mlt_properties properties = mlt_producer_properties( producer ); // Register transport implementation with the producer producer->close = producer_close; @@ -68,11 +69,11 @@ mlt_producer producer_libdv_init( char *filename ) dv_set_audio_correction( this->dv_decoder, DV_AUDIO_CORRECT_AVERAGE ); // Open the file if specified - if ( filename != NULL ) - { - this->fd = open( filename, O_RDONLY ); - producer_collect_info( this ); - } + this->fd = open( filename, O_RDONLY ); + producer_collect_info( this ); + + // Set the resource property (required for all producers) + mlt_properties_set( properties, "resource", filename ); // Return the producer return producer; @@ -128,13 +129,16 @@ static int producer_collect_info( producer_libdv this ) this->frames_in_file = this->file_size / this->frame_size; // Calculate default in/out points - double fps = this->is_pal ? 25 : 30000 / 1001; - mlt_timecode length = ( mlt_timecode )( this->frames_in_file ) / fps; + double fps = this->is_pal ? 25 : 30000.0 / 1001.0; mlt_properties_set_double( properties, "fps", fps ); - mlt_properties_set_timecode( properties, "length", length ); - mlt_properties_set_timecode( properties, "in", 0.0 ); - mlt_properties_set_timecode( properties, "out", length ); + mlt_properties_set_position( properties, "length", this->frames_in_file ); + mlt_properties_set_position( properties, "in", 0 ); + mlt_properties_set_position( properties, "out", this->frames_in_file - 1 ); + // Parse the header for meta info + dv_parse_header( this->dv_decoder, dv_data ); + mlt_properties_set_double( properties, "aspect_ratio", dv_format_wide( this->dv_decoder ) ? 16.0/9.0 : 4.0/3.0 ); + // Set the speed to normal mlt_properties_set_double( properties, "speed", 1 ); } @@ -159,6 +163,9 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma // Get the dv data uint8_t *dv_data = mlt_properties_get_data( properties, "dv_data", NULL ); + // Parse the header for meta info + dv_parse_header( decoder, dv_data ); + // Assign width and height from properties *width = mlt_properties_get_int( properties, "width" ); *height = mlt_properties_get_int( properties, "height" ); @@ -215,6 +222,9 @@ static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_forma // Get the dv data uint8_t *dv_data = mlt_properties_get_data( properties, "dv_data", NULL ); + // Parse the header for meta info + dv_parse_header( decoder, dv_data ); + // Obtain required values *frequency = decoder->audio->frequency; *samples = decoder->audio->samples_this_frame; @@ -282,7 +292,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Parse the header for meta info dv_parse_header( this->dv_decoder, data ); mlt_properties_set_int( properties, "progressive", dv_is_progressive( this->dv_decoder ) ); - mlt_properties_set_double( properties, "display_aspect", dv_format_wide( this->dv_decoder ) ? 16.0/9.0 : 4.0/3.0 ); + mlt_properties_set_double( properties, "aspect_ratio", dv_format_wide( this->dv_decoder ) ? 16.0/9.0 : 4.0/3.0 ); // Hmm - register audio callback ( *frame )->get_audio = producer_get_audio; @@ -296,7 +306,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i } // Update timecode on the frame we're creating - mlt_frame_set_timecode( *frame, mlt_producer_position( producer ) ); + mlt_frame_set_position( *frame, mlt_producer_position( producer ) ); // Calculate the next timecode mlt_producer_prepare_next( producer ); @@ -310,7 +320,7 @@ static void producer_close( mlt_producer parent ) producer_libdv this = parent->child; // Free the dv deconder - dv_decoder_free( this->dv_decoder ); + //dv_decoder_free( this->dv_decoder ); // Close the file if ( this->fd != 0 )