]> git.sesse.net Git - mlt/commitdiff
+ Surface conversion
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 3 Oct 2005 07:54:05 +0000 (07:54 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 3 Oct 2005 07:54:05 +0000 (07:54 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@840 d19143bc-622f-0410-bfdd-b5b2a6649095

src/modules/sdl/producer_sdl_image.c

index d1c13f97f9462247fe939745303482500480bcb1..576ce6fee5ff52c669e4db238815ed20a3297996 100644 (file)
@@ -37,6 +37,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **image, mlt_image_forma
 {
        mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
        SDL_Surface *surface = mlt_properties_get_data( properties, "surface", NULL );
+       SDL_Surface *converted = NULL;
        uint8_t *alpha;
 
        *width = surface->w;
@@ -45,6 +46,20 @@ static int producer_get_image( mlt_frame frame, uint8_t **image, mlt_image_forma
        *image = mlt_pool_alloc( *width * *height * 2 );
        alpha = mlt_pool_alloc( *width * *height );
 
+       if ( surface->format->BitsPerPixel != 32 && surface->format->BitsPerPixel != 24 )
+       {
+               SDL_PixelFormat fmt;
+               fmt.BitsPerPixel = 24;
+               fmt.BytesPerPixel = 3;
+               fmt.Rshift = 16;
+               fmt.Gshift = 8;
+               fmt.Bshift = 0;
+               fmt.Rmask = 0xff << 16;
+               fmt.Gmask = 0xff << 8;
+               fmt.Bmask = 0xff;
+               converted = SDL_ConvertSurface( surface, &fmt, 0 );
+       }
+
        switch( surface->format->BitsPerPixel )
        {
                case 32:
@@ -55,9 +70,14 @@ static int producer_get_image( mlt_frame frame, uint8_t **image, mlt_image_forma
                        memset( alpha, 255, *width * *height );
                        break;
                default:
+                       mlt_convert_rgb24_to_yuv422( converted->pixels, *width, *height, converted->pitch, *image );
+                       memset( alpha, 255, *width * *height );
                        break;
        }
-       
+
+       if ( converted )
+               SDL_FreeSurface( converted );
+
        // Update the frame
        mlt_properties_set_data( properties, "image", *image, *width * *height * 2, mlt_pool_release, NULL );
        mlt_properties_set_data( properties, "alpha", alpha, *width * *height, mlt_pool_release, NULL );
@@ -67,7 +87,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **image, mlt_image_forma
        return 0;
 }
 
-static int filter_files( const struct dirent *de )
+static int filter_files( struct dirent *de )
 {
        return de->d_name[ 0 ] != '.';
 }