X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Fpng.c;h=b6c0f4ea2380865c886e3554a4698a1a2058c340;hb=b5c81d3d419e117085c569cbb22e3376f7118134;hp=d91168c14800682ea31ba9b14ec9968bfe5771e0;hpb=6339478fe9c686d0c527a785fb6c66efe0f17e85;p=vlc diff --git a/modules/codec/png.c b/modules/codec/png.c index d91168c148..b6c0f4ea23 100644 --- a/modules/codec/png.c +++ b/modules/codec/png.c @@ -28,7 +28,8 @@ # include "config.h" #endif -#include +#include +#include #include #include #include @@ -38,7 +39,7 @@ *****************************************************************************/ struct decoder_sys_t { - vlc_bool_t b_error; + bool b_error; }; /***************************************************************************** @@ -52,14 +53,14 @@ static picture_t *DecodeBlock ( decoder_t *, block_t ** ); /***************************************************************************** * Module descriptor *****************************************************************************/ -vlc_module_begin(); - set_category( CAT_INPUT ); - set_subcategory( SUBCAT_INPUT_VCODEC ); - set_description( _("PNG video decoder") ); - set_capability( "decoder", 1000 ); - set_callbacks( OpenDecoder, CloseDecoder ); - add_shortcut( "png" ); -vlc_module_end(); +vlc_module_begin () + set_category( CAT_INPUT ) + set_subcategory( SUBCAT_INPUT_VCODEC ) + set_description( N_("PNG video decoder") ) + set_capability( "decoder", 1000 ) + set_callbacks( OpenDecoder, CloseDecoder ) + add_shortcut( "png" ) +vlc_module_end () /***************************************************************************** * OpenDecoder: probe the decoder and return score @@ -78,14 +79,11 @@ 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; /* Set output properties */ 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_FOURCC('R','G','B','A'); /* Set callbacks */ p_dec->pf_decode_video = DecodeBlock; @@ -107,14 +105,14 @@ static void user_read( png_structp p_png, png_bytep data, png_size_t i_length ) static void user_error( png_structp p_png, png_const_charp error_msg ) { decoder_t *p_dec = (decoder_t *)png_get_error_ptr( p_png ); - p_dec->p_sys->b_error = VLC_TRUE; - msg_Err( p_dec, error_msg ); + p_dec->p_sys->b_error = true; + msg_Err( p_dec, "%s", error_msg ); } static void user_warning( png_structp p_png, png_const_charp warning_msg ) { decoder_t *p_dec = (decoder_t *)png_get_error_ptr( p_png ); - msg_Warn( p_dec, warning_msg ); + msg_Warn( p_dec, "%s", warning_msg ); } /**************************************************************************** @@ -139,7 +137,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) if( !pp_block || !*pp_block ) return NULL; p_block = *pp_block; - p_sys->b_error = VLC_FALSE; + p_sys->b_error = false; p_png = png_create_read_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 ); if( p_png == NULL ) @@ -180,10 +178,13 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) if( p_sys->b_error ) goto error; /* Set output properties */ - p_dec->fmt_out.i_codec = VLC_FOURCC('R','V','3','2'); + p_dec->fmt_out.i_codec = VLC_FOURCC('R','G','B','A'); p_dec->fmt_out.video.i_width = i_width; p_dec->fmt_out.video.i_height = i_height; p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * i_width / i_height; + p_dec->fmt_out.video.i_rmask = 0x000000ff; + p_dec->fmt_out.video.i_gmask = 0x0000ff00; + p_dec->fmt_out.video.i_bmask = 0x00ff0000; if( i_color_type == PNG_COLOR_TYPE_PALETTE ) png_set_palette_to_rgb( p_png ); @@ -203,19 +204,15 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) { p_dec->fmt_out.i_codec = VLC_FOURCC('R','V','2','4'); } - if( i_color_type & PNG_COLOR_MASK_COLOR && - p_dec->fmt_out.i_codec != VLC_FOURCC('R','V','2','4') ) - { - /* Invert colors */ - png_set_bgr( p_png ); - } /* Get a new picture */ - p_pic = p_dec->pf_vout_buffer_new( p_dec ); + p_pic = decoder_NewPicture( p_dec ); if( !p_pic ) goto error; /* Decode picture */ p_row_pointers = malloc( sizeof(png_bytep) * i_height ); + if( !p_row_pointers ) + goto error; for( i = 0; i < (int)i_height; i++ ) p_row_pointers[i] = p_pic->p->p_pixels + p_pic->p->i_pitch * i;