X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Fsdl_image.c;h=bd28da76913d8a73188a64a2c70177cc21456089;hb=f14f66e9882633ac5fb675766d42eeaf208cd51b;hp=258eca2c89793f32905d2b48e6d61b60cb21f229;hpb=f485214f09dd284cbb85674e937fbbb0a6032a2e;p=vlc diff --git a/modules/codec/sdl_image.c b/modules/codec/sdl_image.c index 258eca2c89..bd28da7691 100644 --- a/modules/codec/sdl_image.c +++ b/modules/codec/sdl_image.c @@ -24,10 +24,16 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include -#include SDL_IMAGE_INCLUDE_FILE +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include + +#include /***************************************************************************** * decoder_sys_t : sdl decoder descriptor @@ -48,32 +54,33 @@ static picture_t *DecodeBlock ( decoder_t *, block_t ** ); /***************************************************************************** * Module descriptor *****************************************************************************/ -vlc_module_begin(); - set_category( CAT_INPUT ); - set_subcategory( SUBCAT_INPUT_VCODEC ); - set_description( _("SDL_image video decoder") ); - set_capability( "decoder", 900 ); - set_callbacks( OpenDecoder, CloseDecoder ); - add_shortcut( "sdl_image" ); -vlc_module_end(); +vlc_module_begin () + set_category( CAT_INPUT ) + set_subcategory( SUBCAT_INPUT_VCODEC ) + set_shortname( N_("SDL Image decoder")) + set_description( N_("SDL_image video decoder") ) + set_capability( "decoder", 60 ) + set_callbacks( OpenDecoder, CloseDecoder ) + add_shortcut( "sdl_image" ) +vlc_module_end () static const struct supported_fmt_t { vlc_fourcc_t i_fourcc; - char *psz_sdl_type; + const char *psz_sdl_type; } p_supported_fmt[] = { - { VLC_FOURCC('t','g','a',' '), "TGA" }, - { VLC_FOURCC('b','m','p',' '), "BMP" }, - { VLC_FOURCC('p','n','m',' '), "PNM" }, + { VLC_CODEC_TARGA, "TGA" }, + { VLC_CODEC_BMP, "BMP" }, + { VLC_CODEC_PNM, "PNM" }, { VLC_FOURCC('x','p','m',' '), "XPM" }, { VLC_FOURCC('x','c','f',' '), "XCF" }, - { VLC_FOURCC('p','c','x',' '), "PCX" }, - { VLC_FOURCC('g','i','f',' '), "GIF" }, - { VLC_FOURCC('j','p','e','g'), "JPG" }, - { VLC_FOURCC('t','i','f','f'), "TIF" }, + { VLC_CODEC_PCX, "PCX" }, + { VLC_CODEC_GIF, "GIF" }, + { VLC_CODEC_JPEG, "JPG" }, + { VLC_CODEC_TIFF, "TIF" }, { VLC_FOURCC('l','b','m',' '), "LBM" }, - { VLC_FOURCC('p','n','g',' '), "PNG" } + { VLC_CODEC_PNG, "PNG" } }; /***************************************************************************** @@ -101,15 +108,12 @@ static int OpenDecoder( vlc_object_t *p_this ) /* Allocate the memory needed to store the decoder's structure */ if( ( p_dec->p_sys = p_sys = (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL ) - { - msg_Err( p_dec, "out of memory" ); - return VLC_EGENERIC; - } + return VLC_ENOMEM; p_sys->psz_sdl_type = p_supported_fmt[i].psz_sdl_type; /* Set output properties - this is a decoy and isn't used anywhere */ p_dec->fmt_out.i_cat = VIDEO_ES; - p_dec->fmt_out.i_codec = VLC_FOURCC('R','V','3','2'); + p_dec->fmt_out.i_codec = VLC_CODEC_RGB32; /* Set callbacks */ p_dec->pf_decode_video = DecodeBlock; @@ -133,6 +137,12 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) if( pp_block == NULL || *pp_block == NULL ) return NULL; p_block = *pp_block; + if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY ) + { + block_Release( p_block ); *pp_block = NULL; + return NULL; + } + p_rw = SDL_RWFromConstMem( p_block->p_buffer, p_block->i_buffer ); /* Decode picture. */ @@ -147,14 +157,14 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) switch ( p_surface->format->BitsPerPixel ) { case 16: - p_dec->fmt_out.i_codec = VLC_FOURCC('R','V','1','6'); + p_dec->fmt_out.i_codec = VLC_CODEC_RGB16; break; case 8: case 24: - p_dec->fmt_out.i_codec = VLC_FOURCC('R','V','2','4'); + p_dec->fmt_out.i_codec = VLC_CODEC_RGB24; break; case 32: - p_dec->fmt_out.i_codec = VLC_FOURCC('R','V','3','2'); + p_dec->fmt_out.i_codec = VLC_CODEC_RGB32; break; default: msg_Warn( p_dec, "unknown bits/pixel format (%d)", @@ -163,11 +173,11 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) } p_dec->fmt_out.video.i_width = p_surface->w; p_dec->fmt_out.video.i_height = p_surface->h; - p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_surface->w - / p_surface->h; + p_dec->fmt_out.video.i_sar_num = 1; + p_dec->fmt_out.video.i_sar_den = 1; /* Get a new picture. */ - p_pic = p_dec->pf_vout_buffer_new( p_dec ); + p_pic = decoder_NewPicture( p_dec ); if ( p_pic == NULL ) goto error; switch ( p_surface->format->BitsPerPixel ) @@ -179,7 +189,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) uint8_t r, g, b; for ( i = 0; i < p_surface->h; i++ ) { - p_src = p_surface->pixels + i * p_surface->pitch; + p_src = (uint8_t*)p_surface->pixels + i * p_surface->pitch; p_dst = p_pic->p[0].p_pixels + i * p_pic->p[0].i_pitch; for ( j = 0; j < p_surface->w; j++ ) { @@ -202,7 +212,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) for ( i = 0; i < p_surface->h; i++ ) { - p_dec->p_libvlc->pf_memcpy( p_dst, p_src, i_pitch ); + vlc_memcpy( p_dst, p_src, i_pitch ); p_src += p_surface->pitch; p_dst += p_pic->p[0].i_pitch; } @@ -215,7 +225,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) uint8_t r, g, b; for ( i = 0; i < p_surface->h; i++ ) { - p_src = p_surface->pixels + i * p_surface->pitch; + p_src = (uint8_t*)p_surface->pixels + i * p_surface->pitch; p_dst = p_pic->p[0].p_pixels + i * p_pic->p[0].i_pitch; for ( j = 0; j < p_surface->w; j++ ) { @@ -236,7 +246,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) uint8_t r, g, b, a; for ( i = 0; i < p_surface->h; i++ ) { - p_src = p_surface->pixels + i * p_surface->pitch; + p_src = (uint8_t*)p_surface->pixels + i * p_surface->pitch; p_dst = p_pic->p[0].p_pixels + i * p_pic->p[0].i_pitch; for ( j = 0; j < p_surface->w; j++ ) { @@ -253,6 +263,9 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) } } + p_pic->date = (p_block->i_pts > VLC_TS_INVALID) ? + p_block->i_pts : p_block->i_dts; + SDL_FreeSurface( p_surface ); block_Release( p_block ); *pp_block = NULL; return p_pic;