pgm scaling in transition_composite.
[melted] / src / modules / dv / producer_libdv.c
index b277313..3d4f243 100644 (file)
@@ -64,7 +64,7 @@ mlt_producer producer_libdv_init( char *filename )
 
                // Create the dv_decoder
                this->dv_decoder = dv_decoder_new( FALSE, FALSE, FALSE );
-               this->dv_decoder->quality = DV_QUALITY_BEST;
+               this->dv_decoder->quality = DV_QUALITY_COLOR | DV_QUALITY_AC_1;
                this->dv_decoder->audio->arg_audio_emphasis = 2;
                dv_set_audio_correction( this->dv_decoder, DV_AUDIO_CORRECT_AVERAGE );
 
@@ -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/351 : 96/79 ) : ( this->is_pal ? 128/117 : 72/79 ) );
                }
 
                mlt_pool_release( dv_data );
@@ -239,7 +240,6 @@ static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_forma
        dv_parse_header( decoder, dv_data );
 
        // Obtain required values
-       //fprintf( stderr, "libdv: frequency %d\n", decoder->audio->frequency );
        *frequency = decoder->audio->frequency;
        *samples = decoder->audio->samples_this_frame;
        *channels = decoder->audio->num_channels;
@@ -302,11 +302,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;
@@ -334,7 +346,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 )
@@ -347,4 +359,3 @@ static void producer_close( mlt_producer parent )
        // Free the memory
        free( this );
 }
-