]> git.sesse.net Git - mlt/blobdiff - src/modules/dv/producer_libdv.c
Merge branch 'master' of git://github.com/mltframework/mlt.git
[mlt] / src / modules / dv / producer_libdv.c
index 3d9eaf4edfc261d241510880e0701d19e56d2dab..59e8c5f7c3a4fc23bbbe219bc02af1bc17646b06 100644 (file)
@@ -138,7 +138,7 @@ static int producer_collect_info( producer_libdv this, mlt_profile profile );
 
 mlt_producer producer_libdv_init( mlt_profile profile, mlt_service_type type, const char *id, char *filename )
 {
-       producer_libdv this = calloc( sizeof( struct producer_libdv_s ), 1 );
+       producer_libdv this = calloc( 1, sizeof( struct producer_libdv_s ) );
 
        if ( filename != NULL && this != NULL && mlt_producer_init( &this->parent, this ) == 0 )
        {
@@ -225,6 +225,8 @@ static int producer_collect_info( producer_libdv this, mlt_profile profile )
                // If it looks like a valid frame, the get stats
                if ( valid )
                {
+                       double aspect_ratio;
+
                        // Get the properties
                        mlt_properties properties = MLT_PRODUCER_PROPERTIES( &this->parent );
 
@@ -262,9 +264,21 @@ static int producer_collect_info( producer_libdv this, mlt_profile profile )
 
                        // Parse the header for meta info
                        dv_parse_header( dv_decoder, dv_data );
-                       mlt_properties_set_double( properties, "aspect_ratio", 
-                               dv_format_wide( dv_decoder ) ? ( this->is_pal ? 118.0/81.0 : 40.0/33.0 ) : ( this->is_pal ? 59.0/54.0 : 10.0/11.0 ) );
-                       mlt_properties_set_double( properties, "source_fps", this->is_pal ? 25 : ( 30000.0 / 1001.0 ) );
+                       if ( this->is_pal )
+                       {
+                               if ( dv_format_wide( dv_decoder ) )
+                                       aspect_ratio = 64.0 / 45.0;
+                               else
+                                       aspect_ratio = 16.0 / 15.0;
+                       }
+                       else
+                       {
+                               if ( dv_format_wide( dv_decoder ) )
+                                       aspect_ratio = 32.0 / 27.0;
+                               else
+                                       aspect_ratio = 8 / 9;
+                       }
+                       mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio);
                        mlt_properties_set_int( properties, "meta.media.nb_streams", 2 );
                        mlt_properties_set_int( properties, "video_index", 0 );
                        mlt_properties_set( properties, "meta.media.0.stream.type", "video" );
@@ -274,6 +288,10 @@ static int producer_collect_info( producer_libdv this, mlt_profile profile )
                        mlt_properties_set( properties, "meta.media.1.stream.type", "audio" );
                        mlt_properties_set( properties, "meta.media.1.codec.name", "pcm_s16le" );
                        mlt_properties_set( properties, "meta.media.1.codec.long_name", "signed 16-bit little-endian PCM" );
+                       mlt_properties_set_int( properties, "meta.media.width", 720 );
+                       mlt_properties_set_int( properties, "meta.media.height", this->is_pal ? 576 : 480 );
+                       mlt_properties_set_int( properties, "meta.media.frame_rate_num", this->is_pal? 25 : 30000 );
+                       mlt_properties_set_int( properties, "meta.media.frame_rate_den", this->is_pal?  1 :  1001 );
 
                        // Return the decoder
                        dv_decoder_return( dv_decoder );
@@ -320,7 +338,7 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma
        *height = dv_data[ 3 ] & 0x80 ? 576 : 480;
 
        // Extract an image of the format requested
-       if ( *format == mlt_image_yuv422 || *format == mlt_image_yuv420p )
+       if ( *format != mlt_image_rgb24 )
        {
                // Allocate an image
                uint8_t *image = mlt_pool_alloc( *width * ( *height + 1 ) * 2 );
@@ -488,8 +506,6 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                // Update other info on the frame
                mlt_properties_set_int( properties, "width", 720 );
                mlt_properties_set_int( properties, "height", this->is_pal ? 576 : 480 );
-               mlt_properties_set_int( properties, "real_width", 720 );
-               mlt_properties_set_int( properties, "real_height", this->is_pal ? 576 : 480 );
                mlt_properties_set_int( properties, "top_field_first", !this->is_pal ? 0 : ( data[ 5 ] & 0x07 ) == 0 ? 0 : 1 );
                mlt_properties_set_int( properties, "colorspace", 601 );
        
@@ -500,8 +516,8 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                                dv_format_wide( dv_decoder ) ? ( this->is_pal ? 118.0/81.0 : 40.0/33.0 ) : ( this->is_pal ? 59.0/54.0 : 10.0/11.0 ) );
        
 
-               mlt_properties_set_int( properties, "frequency", dv_decoder->audio->frequency );
-               mlt_properties_set_int( properties, "channels", dv_decoder->audio->num_channels );
+               mlt_properties_set_int( properties, "audio_frequency", dv_decoder->audio->frequency );
+               mlt_properties_set_int( properties, "audio_channels", dv_decoder->audio->num_channels );
 
                // Register audio callback
                if ( mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( producer ), "audio_index" ) > 0 )
@@ -521,7 +537,8 @@ 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_position( *frame, mlt_producer_position( producer ) );
+       if ( *frame != NULL )
+               mlt_frame_set_position( *frame, mlt_producer_position( producer ) );
 
        // Calculate the next timecode
        mlt_producer_prepare_next( producer );