]> git.sesse.net Git - mlt/blobdiff - src/modules/sdl/consumer_sdl_still.c
Revert new image types.
[mlt] / src / modules / sdl / consumer_sdl_still.c
index b08a4cb8df12a86e9c98841aba447f7cf3a35c11..95cceaed0929c6f34b26fb52eb30e84c492af69c 100644 (file)
@@ -257,7 +257,7 @@ static inline void display_1( SDL_Surface *screen, SDL_Rect rect, uint8_t *image
        if ( rect.w == 0 || rect.h == 0 ) return;
        int scale_width = ( width << 16 ) / rect.w;
        int scale_height = ( height << 16 ) / rect.h;
-       int stride = width * 3;
+       int stride = width * 4;
        int x, y, row_index;
        uint8_t *q, *row;
 
@@ -274,7 +274,7 @@ static inline void display_1( SDL_Surface *screen, SDL_Rect rect, uint8_t *image
                row = image + stride * row_index;
                for ( x = 0; x < rect.w; x ++ )
                {
-                       q = row + ( ( ( 32768 + scale_width * x ) >> 16 ) * 3 );
+                       q = row + ( ( ( 32768 + scale_width * x ) >> 16 ) * 4 );
                        *p ++ = SDL_MapRGB( screen->format, *q, *( q + 1 ), *( q + 2 ) );
                }
                start += scanlength;
@@ -287,7 +287,7 @@ static inline void display_2( SDL_Surface *screen, SDL_Rect rect, uint8_t *image
        if ( rect.w == 0 || rect.h == 0 ) return;
        int scale_width = ( width << 16 ) / rect.w;
        int scale_height = ( height << 16 ) / rect.h;
-       int stride = width * 3;
+       int stride = width * 4;
        int x, y, row_index;
        uint8_t *q, *row;
 
@@ -304,7 +304,7 @@ static inline void display_2( SDL_Surface *screen, SDL_Rect rect, uint8_t *image
                row = image + stride * row_index;
                for ( x = 0; x < rect.w; x ++ )
                {
-                       q = row + ( ( ( 32768 + scale_width * x ) >> 16 ) * 3 );
+                       q = row + ( ( ( 32768 + scale_width * x ) >> 16 ) * 4 );
                        *p ++ = SDL_MapRGB( screen->format, *q, *( q + 1 ), *( q + 2 ) );
                }
                start += scanlength;
@@ -317,7 +317,7 @@ static inline void display_3( SDL_Surface *screen, SDL_Rect rect, uint8_t *image
        if ( rect.w == 0 || rect.h == 0 ) return;
        int scale_width = ( width << 16 ) / rect.w;
        int scale_height = ( height << 16 ) / rect.h;
-       int stride = width * 3;
+       int stride = width * 4;
        int x, y, row_index;
        uint8_t *q, *row;
 
@@ -335,7 +335,7 @@ static inline void display_3( SDL_Surface *screen, SDL_Rect rect, uint8_t *image
                row = image + stride * row_index;
                for ( x = 0; x < rect.w; x ++ )
                {
-                       q = row + ( ( ( 32768 + scale_width * x ) >> 16 ) * 3 );
+                       q = row + ( ( ( 32768 + scale_width * x ) >> 16 ) * 4 );
                        pixel = SDL_MapRGB( screen->format, *q, *( q + 1 ), *( q + 2 ) );
                        *p ++ = (pixel & 0xFF0000) >> 16;
                        *p ++ = (pixel & 0x00FF00) >> 8;
@@ -351,7 +351,7 @@ static inline void display_4( SDL_Surface *screen, SDL_Rect rect, uint8_t *image
        if ( rect.w == 0 || rect.h == 0 ) return;
        int scale_width = ( width << 16 ) / rect.w;
        int scale_height = ( height << 16 ) / rect.h;
-       int stride = width * 3;
+       int stride = width * 4;
        int x, y, row_index;
        uint8_t *q, *row;
 
@@ -368,7 +368,7 @@ static inline void display_4( SDL_Surface *screen, SDL_Rect rect, uint8_t *image
                row = image + stride * row_index;
                for ( x = 0; x < rect.w; x ++ )
                {
-                       q = row + ( ( ( 32768 + scale_width * x ) >> 16 ) * 3 );
+                       q = row + ( ( ( 32768 + scale_width * x ) >> 16 ) * 4 );
                        *p ++ = SDL_MapRGB( screen->format, *q, *( q + 1 ), *( q + 2 ) );
                }
                start += scanlength;
@@ -380,7 +380,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
        // Get the properties of this consumer
        mlt_properties properties = this->properties;
 
-       mlt_image_format vfmt = mlt_image_rgb24;
+       mlt_image_format vfmt = mlt_image_rgb24a;
        int height = this->height;
        int width = this->width;
        uint8_t *image = NULL;
@@ -440,11 +440,14 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
                if ( consumer_get_dimensions( &this->window_width, &this->window_height ) )
                        this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
-               pthread_mutex_unlock( &mlt_sdl_mutex );
 
                uint32_t color = mlt_properties_get_int( this->properties, "window_background" );
-               SDL_FillRect( this->sdl_screen, NULL, color >> 8 );
-               changed = 1;
+               if ( this->sdl_screen )
+               {
+                       SDL_FillRect( this->sdl_screen, NULL, color >> 8 );
+                       changed = 1;
+               }
+               pthread_mutex_unlock( &mlt_sdl_mutex );
        }
 
        if ( changed == 0 &&