ffmpeg fixed date for cvs checkout
[melted] / src / modules / avformat / producer_avformat.c
index b936ff3..3889e3e 100644 (file)
@@ -418,7 +418,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                        // Fast forward - seeking is inefficient for small distances - just ignore following frames
                        ignore = position - expected;
                }
-               else
+               else if ( position < expected || position - expected >= 12 )
                {
                        // Set to the real timecode
                        av_seek_frame( context, -1, mlt_properties_get_double( properties, "start_time" ) + real_timecode * 1000000.0 );
@@ -636,14 +636,21 @@ static void producer_set_up_video( mlt_producer this, mlt_frame frame )
                // No codec, no show...
                if ( codec != NULL )
                {
-                       double aspect_ratio = 1;
                        double source_fps = 0;
 
-                       // Set aspect ratio
+                       // XXX: We won't know the real aspect ratio until an image is decoded
+                       // but we do need it now (to satisfy filter_resize) - take a guess based
+                       // on pal/ntsc
                        if ( codec_context->sample_aspect_ratio.num > 0 )
-                               aspect_ratio = av_q2d( codec_context->sample_aspect_ratio );
+                       {
+                               mlt_properties_set_double( properties, "aspect_ratio", av_q2d( codec_context->sample_aspect_ratio ) );
+                       }
+                       else
+                       {
+                               int is_pal = mlt_properties_get_double( properties, "fps" ) == 25.0;
+                               mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 128.0/117.0 : 72.0/79.0 );
+                       }
 
-                       mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio );
                        //fprintf( stderr, "AVFORMAT: sample aspect %f %dx%d\n", av_q2d( codec_context->sample_aspect_ratio ), codec_context->width, codec_context->height );
 
                        // Determine the fps
@@ -765,7 +772,7 @@ static int producer_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_form
                        // Fast forward - seeking is inefficient for small distances - just ignore following frames
                        ignore = position - expected;
                }
-               else
+               else if ( position < expected || position - expected >= 12 )
                {
                        // Set to the real timecode
                        if ( av_seek_frame( context, -1, mlt_properties_get_double( properties, "start_time" ) + real_timecode * 1000000.0 ) != 0 )