filter_luma.c: prevent the first application of the nested luma transition from being...
[melted] / src / modules / dv / producer_libdv.c
index b593b53..10f3d46 100644 (file)
@@ -22,6 +22,8 @@
 #include <framework/mlt_frame.h>
 #include <framework/mlt_deque.h>
 #include <framework/mlt_factory.h>
+#include <framework/mlt_profile.h>
+
 #include <pthread.h>
 #include <stdlib.h>
 #include <string.h>
@@ -132,7 +134,7 @@ struct producer_libdv_s
 static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index );
 static void producer_close( mlt_producer parent );
 
-static int producer_collect_info( producer_libdv this );
+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 )
 {
@@ -175,7 +177,7 @@ mlt_producer producer_libdv_init( mlt_profile profile, mlt_service_type type, co
                        this->fd = open( filename, O_RDONLY );
 
                        // Collect info
-                       if ( this->fd == -1 || !producer_collect_info( this ) )
+                       if ( this->fd == -1 || !producer_collect_info( this, profile ) )
                                destroy = 1;
                }
 
@@ -199,7 +201,6 @@ static int read_frame( int fd, uint8_t* frame_buf, int *isPAL )
        if ( result )
        {
                *isPAL = ( frame_buf[3] & 0x80 );
-
                if ( *isPAL )
                {
                        int diff = FRAME_SIZE_625_50 - FRAME_SIZE_525_60;
@@ -210,7 +211,7 @@ static int read_frame( int fd, uint8_t* frame_buf, int *isPAL )
        return result;
 }
 
-static int producer_collect_info( producer_libdv this )
+static int producer_collect_info( producer_libdv this, mlt_profile profile )
 {
        int valid = 0;
 
@@ -244,8 +245,8 @@ 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.0 / 1001.0;
-                       if ( mlt_producer_get_fps( &this->parent ) == fps )
+                       int fps = 1000 * ( this->is_pal ? 25 : ( 30000.0 / 1001.0 ) );
+                       if ( ( int )( mlt_profile_fps( profile ) * 1000 ) == fps )
                        {
                                if ( this->frames_in_file > 0 )
                                {
@@ -263,6 +264,16 @@ static int producer_collect_info( producer_libdv this )
                        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 ) );
+                       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" );
+                       mlt_properties_set( properties, "meta.media.0.codec.name", "dvvideo" );
+                       mlt_properties_set( properties, "meta.media.0.codec.long_name", "DV (Digital Video)" );
+                       mlt_properties_set_int( properties, "audio_index", 1 );
+                       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" );
 
                        // Return the decoder
                        dv_decoder_return( dv_decoder );
@@ -486,14 +497,18 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
                mlt_properties_set_int( properties, "frequency", dv_decoder->audio->frequency );
                mlt_properties_set_int( properties, "channels", dv_decoder->audio->num_channels );
 
-               // Hmm - register audio callback
-               mlt_frame_push_audio( *frame, producer_get_audio );
-       
-               // Push the quality string
-               mlt_frame_push_service( *frame, mlt_properties_get( MLT_PRODUCER_PROPERTIES( producer ), "quality" ) );
+               // Register audio callback
+               if ( mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( producer ), "audio_index" ) > 0 )
+                       mlt_frame_push_audio( *frame, producer_get_audio );
        
-               // Push the get_image method on to the stack
-               mlt_frame_push_get_image( *frame, producer_get_image );
+               if ( mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( producer ), "video_index" ) > -1 )
+               {
+                       // Push the quality string
+                       mlt_frame_push_service( *frame, mlt_properties_get( MLT_PRODUCER_PROPERTIES( producer ), "quality" ) );
+
+                       // Push the get_image method on to the stack
+                       mlt_frame_push_get_image( *frame, producer_get_image );
+               }
        
                // Return the decoder
                dv_decoder_return( dv_decoder );