RPN clean up for frames
[melted] / src / modules / sdl / consumer_sdl.c
index b06ca48..74cfd28 100644 (file)
@@ -103,6 +103,9 @@ mlt_consumer consumer_sdl_init( char *arg )
                // Default scaler (for now we'll use nearest)
                mlt_properties_set( this->properties, "rescale", "nearest" );
 
+               // Default buffer for low latency
+               mlt_properties_set_int( this->properties, "buffer", 8 );
+
                // Default progressive true
                mlt_properties_set_int( this->properties, "progressive", 1 );
 
@@ -115,9 +118,9 @@ mlt_consumer consumer_sdl_init( char *arg )
                        this->width = mlt_properties_get_int( this->properties, "width" );
                        this->height = mlt_properties_get_int( this->properties, "height" );
                }
-
+               
                // Default window size
-               this->window_width = (int)( (float)this->height * this->aspect_ratio ) + 1;
+               this->window_width = (int)( (float)this->height * 4.0/3.0 + 0.5);
                this->window_height = this->height;
                
                // Set the sdl flags
@@ -331,7 +334,6 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame, int64_t elap
 
        // Set skip
        mlt_properties_set_position( mlt_frame_properties( frame ), "playtime", playtime );
-       mlt_properties_set_double( mlt_frame_properties( frame ), "consumer_scale", ( double )height / mlt_properties_get_double( properties, "height" ) );
 
        // Push this frame to the back of the queue
        mlt_deque_push_back( this->queue, frame );
@@ -347,7 +349,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame, int64_t elap
                // Get the image, width and height
                mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 );
 
-               if ( playtime > elapsed + 20000 )
+               if ( playtime > elapsed + 25000 )
                {
                        struct timespec tm = { ( playtime - elapsed ) / 1000000, ( ( playtime - elapsed ) % 1000000 ) * 1000 };
                        nanosleep( &tm, NULL );
@@ -394,12 +396,12 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame, int64_t elap
 
                if ( this->sdl_screen == NULL || changed )
                {
-                       double aspect_ratio = mlt_frame_get_aspect_ratio( frame );
-                       float display_aspect_ratio = (float)width / (float)height;
+                       double aspect_ratio = ( float )this->aspect_ratio * this->width / this->height;
+                       float display_aspect_ratio = ( float )width / height;
                        SDL_Rect rect;
-
-                       if ( mlt_properties_get_double( properties, "aspect_ratio" ) )
-                               aspect_ratio = mlt_properties_get_double( properties, "aspect_ratio" );
+                       if ( mlt_properties_get( properties, "rescale" ) != NULL &&
+                                       !strcmp( mlt_properties_get( properties, "rescale" ), "none" ) )
+                               aspect_ratio = mlt_frame_get_aspect_ratio( frame ) * mlt_properties_get_int(mlt_frame_properties(frame),"width") / mlt_properties_get_int(mlt_frame_properties(frame),"height");
 
                        if ( aspect_ratio == 1 )
                        {
@@ -409,11 +411,11 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame, int64_t elap
                        else if ( this->window_width < this->window_height * aspect_ratio )
                        {
                                rect.w = this->window_width;
-                               rect.h = this->window_width / aspect_ratio;
+                               rect.h = this->window_width / aspect_ratio + 1;
                        }
                        else
                        {
-                               rect.w = this->window_height * aspect_ratio;
+                               rect.w = this->window_height * aspect_ratio + 1;
                                rect.h = this->window_height;
                        }
 
@@ -498,7 +500,7 @@ static void *consumer_thread( void *arg )
        while( this->running )
        {
                // Get a frame from the attached producer
-               mlt_frame frame = mlt_consumer_rt_frame( consumer, mlt_image_yuv422 );
+               mlt_frame frame = mlt_consumer_rt_frame( consumer );
 
                // Ensure that we have a frame
                if ( frame != NULL )
@@ -601,4 +603,3 @@ static void consumer_close( mlt_consumer parent )
        // Finally clean up this
        free( this );
 }
-