X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fsdl%2Fproducer_sdl_image.c;h=ee881023f83defdfbfd955778e0023cf32fda5f1;hb=16b6d374cf80004b192aae74a55b0452c7ee809d;hp=d1c13f97f9462247fe939745303482500480bcb1;hpb=97e801a4bf29374230eb4025997e7ddde0650ac2;p=melted diff --git a/src/modules/sdl/producer_sdl_image.c b/src/modules/sdl/producer_sdl_image.c index d1c13f9..ee88102 100644 --- a/src/modules/sdl/producer_sdl_image.c +++ b/src/modules/sdl/producer_sdl_image.c @@ -3,22 +3,22 @@ * Copyright (C) 2005 Visual Media FX * Author: Charles Yates * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "producer_sdl_image.h" +#include #include #include @@ -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 ); @@ -154,7 +174,7 @@ static SDL_Surface *load_image( mlt_producer producer ) static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ) { // Generate a frame - *frame = mlt_frame_init( ); + *frame = mlt_frame_init( MLT_PRODUCER_SERVICE( producer ) ); if ( *frame != NULL ) { @@ -197,7 +217,7 @@ static void producer_close( mlt_producer producer ) free( producer ); } -mlt_producer producer_sdl_image_init( char *file ) +mlt_producer producer_sdl_image_init( mlt_profile profile, mlt_service_type type, const char *id, char *file ) { mlt_producer producer = calloc( 1, sizeof( struct mlt_producer_s ) ); if ( producer != NULL && mlt_producer_init( producer, NULL ) == 0 )