annotate libmpcodecs/vd_mpng.c @ 34114:113156bc1137

Ensure that filename related config will always be loaded. Currently, filename related config will only be loaded if MPlayer knows the filename when it gets called, which isn't the case if either MPlayer is called in slave mode or the GUI is called without file argument. In either case, the file to be played is known only later. If filename related config hasn't yet been read, do it after leaving the idle mode loop.
author ib
date Sat, 15 Oct 2011 11:07:29 +0000
parents 9981c24b59bd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
19 #include <stdio.h>
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
20 #include <stdlib.h>
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
21
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
22 #include "config.h"
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
23 #include "mp_msg.h"
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
24
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
25 #include <png.h>
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
26
21372
1767c271d710 Remove bswap.h, use libavutil/bswap.h instead.
diego
parents: 18879
diff changeset
27 #include "libavutil/common.h"
21507
fa99b3d31d13 Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents: 21372
diff changeset
28 #include "mpbswap.h"
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
29 #include "libvo/fastmemcpy.h"
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
30
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
31 #include "vd_internal.h"
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
32
30504
cc27da5d7286 Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents: 30421
diff changeset
33 static const vd_info_t info = {
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
34 "PNG Images decoder",
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
35 "mpng",
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
36 "A'rpi",
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
37 ".so, based on mpng.c",
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
38 "uses libpng, 8bpp modes not supported yet"
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
39 };
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
40
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
41 LIBVD_EXTERN(mpng)
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
42
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
43 static unsigned int out_fmt=0;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
44
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
45 static int last_w=-1;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
46 static int last_h=-1;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
47 static int last_c=-1;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
48
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
49 // to set/get/query special features/parameters
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
50 static int control(sh_video_t *sh,int cmd,void* arg,...){
11566
a9448dd2430c query_format support by Matthias Goerner <m.goerner@iu-bremen.de>
alex
parents: 7472
diff changeset
51 switch (cmd)
a9448dd2430c query_format support by Matthias Goerner <m.goerner@iu-bremen.de>
alex
parents: 7472
diff changeset
52 {
a9448dd2430c query_format support by Matthias Goerner <m.goerner@iu-bremen.de>
alex
parents: 7472
diff changeset
53 case VDCTRL_QUERY_FORMAT:
a9448dd2430c query_format support by Matthias Goerner <m.goerner@iu-bremen.de>
alex
parents: 7472
diff changeset
54 if (*((int *) arg) == out_fmt) return CONTROL_TRUE;
a9448dd2430c query_format support by Matthias Goerner <m.goerner@iu-bremen.de>
alex
parents: 7472
diff changeset
55 return CONTROL_FALSE;
a9448dd2430c query_format support by Matthias Goerner <m.goerner@iu-bremen.de>
alex
parents: 7472
diff changeset
56 }
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
57 return CONTROL_UNKNOWN;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
58 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
59
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
60 // init driver
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
61 static int init(sh_video_t *sh){
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
62 last_w=-1;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
63 return 1;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
64 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
65
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
66 // uninit driver
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
67 static void uninit(sh_video_t *sh){
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
68 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
69
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
70 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
71
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
72 static int pngPointer;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
73 static int pngLength;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
74
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
75 static void pngReadFN( png_structp pngstr,png_bytep buffer,png_size_t size )
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
76 {
32753
9981c24b59bd Use color type getter instead of direct access to private member.
cboesch
parents: 30702
diff changeset
77 char * p = png_get_io_ptr(pngstr);
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
78 if(size>pngLength-pngPointer && pngLength>=pngPointer) size=pngLength-pngPointer;
23457
a124f3abc1ec Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents: 21507
diff changeset
79 fast_memcpy( buffer,(char *)&p[pngPointer],size );
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
80 pngPointer+=size;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
81 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
82
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
83 // decode a frame
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
84 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
85 png_structp png;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
86 png_infop info;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
87 png_infop endinfo;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
88 // png_bytep data;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
89 png_bytep * row_p;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
90 png_uint_32 png_width=0,png_height=0;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
91 int depth,color;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
92 png_uint_32 i;
32753
9981c24b59bd Use color type getter instead of direct access to private member.
cboesch
parents: 30702
diff changeset
93 png_byte color_type;
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
94 mp_image_t* mpi;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
95
15502
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
96 int cols;
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
97 png_colorp pal;
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
98 unsigned char *p;
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
99
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
100 if(len<=0) return NULL; // skipped frame
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 23457
diff changeset
101
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
102 png=png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
103 info=png_create_info_struct( png );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
104 endinfo=png_create_info_struct( png );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
105
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
106 pngPointer=8;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
107 pngLength=len;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
108 png_set_read_fn( png,data,pngReadFN );
17552
3469899beb42 Fix mpng to work correctly with 16 bit png's. don't have any files to test
ods15
parents: 15502
diff changeset
109 png_set_strip_16( png );
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
110 png_set_sig_bytes( png,8 );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
111 png_read_info( png,info );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
112 png_get_IHDR( png,info,&png_width,&png_height,&depth,&color,NULL,NULL,NULL );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
113 png_set_bgr( png );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
114
32753
9981c24b59bd Use color type getter instead of direct access to private member.
cboesch
parents: 30702
diff changeset
115 color_type=png_get_color_type(png, info);
9981c24b59bd Use color type getter instead of direct access to private member.
cboesch
parents: 30702
diff changeset
116
9981c24b59bd Use color type getter instead of direct access to private member.
cboesch
parents: 30702
diff changeset
117 switch( color_type ) {
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
118 case PNG_COLOR_TYPE_GRAY_ALPHA:
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
119 mp_msg( MSGT_DECVIDEO,MSGL_INFO,"Sorry gray scaled png with alpha channel not supported at moment.\n" );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
120 break;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
121 case PNG_COLOR_TYPE_GRAY:
15502
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
122 out_fmt=IMGFMT_Y800;
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
123 break;
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
124 case PNG_COLOR_TYPE_PALETTE:
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
125 out_fmt=IMGFMT_BGR8;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
126 break;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
127 case PNG_COLOR_TYPE_RGB_ALPHA:
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
128 out_fmt=IMGFMT_BGR32;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
129 break;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
130 case PNG_COLOR_TYPE_RGB:
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
131 out_fmt=IMGFMT_BGR24;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
132 break;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
133 default:
32753
9981c24b59bd Use color type getter instead of direct access to private member.
cboesch
parents: 30702
diff changeset
134 mp_msg( MSGT_DECVIDEO,MSGL_INFO,"Sorry, unsupported PNG colorspace: %d.\n" ,color_type);
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
135 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
136
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
137 // (re)init libvo if image parameters changed (width/height/colorspace)
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
138 if(last_w!=png_width || last_h!=png_height || last_c!=out_fmt){
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
139 last_w=png_width; last_h=png_height; last_c=out_fmt;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
140 if(!out_fmt) return NULL;
5124
3dcbf67c0de0 handle error from mpcodecs_config_vo()
arpi
parents: 4998
diff changeset
141 if(!mpcodecs_config_vo(sh,png_width,png_height,out_fmt)) return NULL;
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
142 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
143
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
144 #if 0
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
145 switch( info->color_type )
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
146 {
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
147 case PNG_COLOR_TYPE_GRAY_ALPHA: printf( "[png] used GrayA -> stripping alpha channel\n" ); break;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
148 case PNG_COLOR_TYPE_GRAY: printf( "[png] used Gray -> rgb\n" ); break;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
149 case PNG_COLOR_TYPE_PALETTE: printf( "[png] used palette -> rgb\n" ); break;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
150 case PNG_COLOR_TYPE_RGB_ALPHA: printf( "[png] used RGBA -> stripping alpha channel\n" ); break;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
151 case PNG_COLOR_TYPE_RGB: printf( "[png] read rgb datas.\n" ); break;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
152 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
153 #endif
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
154
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 23457
diff changeset
155 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
156 png_width,png_height);
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
157 if(!mpi) return NULL;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
158
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
159 // Let's DECODE!
18879
cc65a585fdcc rm unnecesary casts from void* - part 3
reynaldo
parents: 18771
diff changeset
160 row_p=malloc( sizeof( png_bytep ) * png_height );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 23457
diff changeset
161 //png_get_rowbytes( png,info )
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
162 for ( i=0; i < png_height; i++ ) row_p[i]=mpi->planes[0] + mpi->stride[0]*i;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
163 png_read_image( png,row_p );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
164 free( row_p );
15502
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
165
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
166 if (out_fmt==IMGFMT_BGR8) {
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
167 png_get_PLTE( png,info,&pal,&cols );
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30504
diff changeset
168 mpi->planes[1] = realloc(mpi->planes[1], 4*cols);
15502
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
169 p = mpi->planes[1];
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
170 for (i = 0; i < cols; i++) {
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
171 *p++ = pal[i].blue;
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
172 *p++ = pal[i].green;
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
173 *p++ = pal[i].red;
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
174 *p++ = 0;
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
175 }
ef7349907cf4 8bit palette mode support (and spurious ^M removal)
henry
parents: 11566
diff changeset
176 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 23457
diff changeset
177
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
178 png_read_end( png,endinfo );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
179 png_destroy_read_struct( &png,&info,&endinfo );
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
180
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
181 return mpi;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
182 }