]> git.sesse.net Git - vlc/blobdiff - modules/codec/png.c
png comes with an alpha plane (RV32 isn't assumed to have a usable alpha plane in...
[vlc] / modules / codec / png.c
index 34e9dd44e4c752d31a198f6bb4fa365926408ace..bac19f5af8ed0d216ff0577c8b39bd8939ae8055 100644 (file)
@@ -28,7 +28,8 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_codec.h>
 #include <vlc_vout.h>
 #include <png.h>
@@ -55,7 +56,7 @@ static picture_t *DecodeBlock  ( decoder_t *, block_t ** );
 vlc_module_begin();
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_VCODEC );
-    set_description( _("PNG video decoder") );
+    set_description( N_("PNG video decoder") );
     set_capability( "decoder", 1000 );
     set_callbacks( OpenDecoder, CloseDecoder );
     add_shortcut( "png" );
@@ -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;
@@ -108,13 +106,13 @@ 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 = true;
-    msg_Err( p_dec, error_msg );
+    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 );
 }
 
 /****************************************************************************
@@ -180,7 +178,7 @@ 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;
@@ -216,6 +214,8 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
     /* 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;