[MPlayer-cvslog] CVS: main/libmpcodecs vd_mpng.c,1.6,1.7
Jindrich Makovicka CVS
syncmail at mplayerhq.hu
Wed May 18 12:44:48 CEST 2005
CVS change done by Jindrich Makovicka CVS
Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var2/tmp/cvs-serv9946
Modified Files:
vd_mpng.c
Log Message:
8bit palette mode support (and spurious ^M removal)
Index: vd_mpng.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_mpng.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- vd_mpng.c 7 Dec 2003 15:18:39 -0000 1.6
+++ vd_mpng.c 18 May 2005 10:44:45 -0000 1.7
@@ -76,6 +76,10 @@
png_uint_32 i;
mp_image_t* mpi;
+ int cols;
+ png_colorp pal;
+ unsigned char *p;
+
if(len<=0) return NULL; // skipped frame
png=png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL );
@@ -88,13 +92,15 @@
png_set_sig_bytes( png,8 );
png_read_info( png,info );
png_get_IHDR( png,info,&png_width,&png_height,&depth,&color,NULL,NULL,NULL );
-
png_set_bgr( png );
+ png_set_bgr( png );
switch( info->color_type ) {
case PNG_COLOR_TYPE_GRAY_ALPHA:
mp_msg( MSGT_DECVIDEO,MSGL_INFO,"Sorry gray scaled png with alpha channel not supported at moment.\n" );
break;
case PNG_COLOR_TYPE_GRAY:
+ out_fmt=IMGFMT_Y800;
+ break;
case PNG_COLOR_TYPE_PALETTE:
out_fmt=IMGFMT_BGR8;
break;
@@ -136,8 +142,18 @@
for ( i=0; i < png_height; i++ ) row_p[i]=mpi->planes[0] + mpi->stride[0]*i;
png_read_image( png,row_p );
free( row_p );
-
- //png_get_PLTE( png,info,(png_colorp*)&pal,&cols );
+
+ if (out_fmt==IMGFMT_BGR8) {
+ png_get_PLTE( png,info,&pal,&cols );
+ mpi->planes[1] = (char*)realloc(mpi->planes[1], 4*cols);
+ p = mpi->planes[1];
+ for (i = 0; i < cols; i++) {
+ *p++ = pal[i].blue;
+ *p++ = pal[i].green;
+ *p++ = pal[i].red;
+ *p++ = 0;
+ }
+ }
png_read_end( png,endinfo );
png_destroy_read_struct( &png,&info,&endinfo );
More information about the MPlayer-cvslog
mailing list