X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Fpng.c;h=acd569481013008c063b7054009e9f721979eafb;hb=2a100fcd186304e600d6d896325855836fa899e6;hp=7fe5f0794d53a40f7640d58b60ef3445ba7b2033;hpb=4e797456664930fab817a373c20728e32239de55;p=vlc diff --git a/modules/codec/png.c b/modules/codec/png.c index 7fe5f0794d..acd5694810 100644 --- a/modules/codec/png.c +++ b/modules/codec/png.c @@ -31,7 +31,6 @@ #include #include #include -#include #include /***************************************************************************** @@ -53,14 +52,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( N_("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 @@ -68,22 +67,20 @@ vlc_module_end(); static int OpenDecoder( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t*)p_this; - decoder_sys_t *p_sys; - if( p_dec->fmt_in.i_codec != VLC_FOURCC('p','n','g',' ') && + if( p_dec->fmt_in.i_codec != VLC_CODEC_PNG && p_dec->fmt_in.i_codec != VLC_FOURCC('M','P','N','G') ) { return VLC_EGENERIC; } /* 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 ) + if( ( p_dec->p_sys = malloc(sizeof(decoder_sys_t)) ) == NULL ) return VLC_ENOMEM; /* Set output properties */ p_dec->fmt_out.i_cat = VIDEO_ES; - p_dec->fmt_out.i_codec = VLC_FOURCC('R','G','B','A'); + p_dec->fmt_out.i_codec = VLC_CODEC_RGBA; /* Set callbacks */ p_dec->pf_decode_video = DecodeBlock; @@ -139,17 +136,23 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) p_block = *pp_block; p_sys->b_error = false; + if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY ) + { + block_Release( p_block ); *pp_block = NULL; + return NULL; + } + p_png = png_create_read_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 ); if( p_png == NULL ) { block_Release( p_block ); *pp_block = NULL; return NULL; } - + p_info = png_create_info_struct( p_png ); if( p_info == NULL ) { - png_destroy_read_struct( &p_png, png_infopp_NULL, png_infopp_NULL ); + png_destroy_read_struct( &p_png, NULL, NULL ); block_Release( p_block ); *pp_block = NULL; return NULL; } @@ -157,11 +160,11 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) p_end_info = png_create_info_struct( p_png ); if( p_end_info == NULL ) { - png_destroy_read_struct( &p_png, &p_info, png_infopp_NULL ); + png_destroy_read_struct( &p_png, &p_info, NULL ); block_Release( p_block ); *pp_block = NULL; return NULL; } - + /* libpng longjmp's there in case of error */ if( setjmp( png_jmpbuf( p_png ) ) ) goto error; @@ -178,10 +181,11 @@ 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','G','B','A'); + p_dec->fmt_out.i_codec = VLC_CODEC_RGBA; 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_sar_num = 1; + p_dec->fmt_out.video.i_sar_den = 1; p_dec->fmt_out.video.i_rmask = 0x000000ff; p_dec->fmt_out.video.i_gmask = 0x0000ff00; p_dec->fmt_out.video.i_bmask = 0x00ff0000; @@ -202,7 +206,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) } else if( !(i_color_type & PNG_COLOR_MASK_ALPHA) ) { - p_dec->fmt_out.i_codec = VLC_FOURCC('R','V','2','4'); + p_dec->fmt_out.i_codec = VLC_CODEC_RGB24; } /* Get a new picture */ @@ -224,7 +228,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) png_destroy_read_struct( &p_png, &p_info, &p_end_info ); free( p_row_pointers ); - p_pic->date = p_block->i_pts > 0 ? p_block->i_pts : p_block->i_dts; + p_pic->date = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : p_block->i_dts; block_Release( p_block ); *pp_block = NULL; return p_pic;