X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fdv%2Fproducer_libdv.c;h=30111dad2fc9e67a7612d1c7513623b64b36cddd;hb=1d3ab5568258841b1741b8c2fc88ce4e958e6fc6;hp=3249cd07441e22437ec4eaa349611cd0fd556849;hpb=f0a20dae7fddfce0b3992bb6942145a3640315ba;p=melted diff --git a/src/modules/dv/producer_libdv.c b/src/modules/dv/producer_libdv.c index 3249cd0..30111da 100644 --- a/src/modules/dv/producer_libdv.c +++ b/src/modules/dv/producer_libdv.c @@ -153,7 +153,8 @@ static int producer_collect_info( producer_libdv this ) // 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 ); + mlt_properties_set_double( properties, "aspect_ratio", + dv_format_wide( this->dv_decoder ) ? ( this->is_pal ? 512.0/351.0 : 96.0/79.0 ) : ( this->is_pal ? 128.0/117.0 : 72.0/79.0 ) ); } mlt_pool_release( dv_data ); @@ -238,33 +239,43 @@ static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_forma // 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; - *channels = decoder->audio->num_channels; - - // Create a temporary workspace - for ( i = 0; i < 4; i++ ) - audio_channels[ i ] = mlt_pool_alloc( DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) ); - - // Create a workspace for the result - *buffer = mlt_pool_alloc( *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) ); - - // Pass the allocated audio buffer as a property - mlt_properties_set_data( properties, "audio", *buffer, *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ), ( mlt_destructor )mlt_pool_release, NULL ); - - // Decode the audio - dv_decode_full_audio( decoder, dv_data, audio_channels ); + // Check that we have audio + if ( decoder->audio->num_channels > 0 ) + { + // Obtain required values + *frequency = decoder->audio->frequency; + *samples = decoder->audio->samples_this_frame; + *channels = decoder->audio->num_channels; + + // Create a temporary workspace + for ( i = 0; i < 4; i++ ) + audio_channels[ i ] = mlt_pool_alloc( DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) ); - // Interleave the audio - p = *buffer; - for ( i = 0; i < *samples; i++ ) - for ( j = 0; j < *channels; j++ ) - *p++ = audio_channels[ j ][ i ]; - - // Free the temporary work space - for ( i = 0; i < 4; i++ ) - mlt_pool_release( audio_channels[ i ] ); + // Create a workspace for the result + *buffer = mlt_pool_alloc( *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) ); + + // Pass the allocated audio buffer as a property + mlt_properties_set_data( properties, "audio", *buffer, *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ), ( mlt_destructor )mlt_pool_release, NULL ); + + // Decode the audio + dv_decode_full_audio( decoder, dv_data, audio_channels ); + + // Interleave the audio + p = *buffer; + for ( i = 0; i < *samples; i++ ) + for ( j = 0; j < *channels; j++ ) + *p++ = audio_channels[ j ][ i ]; + + // Free the temporary work space + for ( i = 0; i < 4; i++ ) + mlt_pool_release( audio_channels[ i ] ); + } + else + { + // No audio available on the frame, so get test audio (silence) + this->get_audio = NULL; + mlt_frame_get_audio( this, buffer, format, frequency, channels, samples ); + } return 0; } @@ -301,11 +312,23 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i mlt_properties_set_int( properties, "width", 720 ); mlt_properties_set_int( properties, "height", this->is_pal ? 576 : 480 ); mlt_properties_set_int( properties, "top_field_first", 0 ); + + char *quality = mlt_properties_get( mlt_producer_properties( producer ), "quality" ); + if ( quality != NULL ) + { + if ( strncmp( quality, "fast", 4 ) == 0 ) + this->dv_decoder->quality = ( DV_QUALITY_COLOR | DV_QUALITY_DC ); + else if ( strncmp( quality, "best", 4 ) == 0 ) + this->dv_decoder->quality = ( DV_QUALITY_COLOR | DV_QUALITY_AC_2 ); + else + this->dv_decoder->quality = ( DV_QUALITY_COLOR | DV_QUALITY_AC_1 ); + } // 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, "aspect_ratio", 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 ) ? ( this->is_pal ? 512.0/351.0 : 96.0/79.0 ) : ( this->is_pal ? 128.0/117.0 : 72.0/79.0 ) ); // Hmm - register audio callback ( *frame )->get_audio = producer_get_audio; @@ -346,4 +369,3 @@ static void producer_close( mlt_producer parent ) // Free the memory free( this ); } -