Mercurial > mplayer.hg
annotate libvo/vo_png.c @ 30028:9ad7756adfa8
Fix a broken indentation.
author | reimar |
---|---|
date | Sat, 19 Dec 2009 20:45:34 +0000 |
parents | 0f1b5b68af32 |
children | 1772a5171ac7 |
rev | line source |
---|---|
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
1 /* |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
2 * Portable Network Graphics renderer |
527 | 3 * |
530 | 4 * Copyright 2001 by Felix Buenemann <atmosfear@users.sourceforge.net> |
527 | 5 * |
530 | 6 * Uses libpng (which uses zlib), so see according licenses. |
527 | 7 * |
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
8 * This file is part of MPlayer. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
9 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
10 * MPlayer is free software; you can redistribute it and/or modify |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
13 * (at your option) any later version. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
14 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
15 * MPlayer is distributed in the hope that it will be useful, |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
18 * GNU General Public License for more details. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
19 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
20 * You should have received a copy of the GNU General Public License along |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
21 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28092
diff
changeset
|
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
527 | 23 */ |
24 | |
25 #include <stdio.h> | |
26 #include <stdlib.h> | |
27 #include <string.h> | |
612 | 28 #include <errno.h> |
27618 | 29 #include <sys/stat.h> |
30 #include <sys/types.h> | |
31 #include <unistd.h> | |
527 | 32 |
33 #include <png.h> | |
34 | |
26203 | 35 #include "config.h" |
17932 | 36 #include "mp_msg.h" |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
37 #include "mp_msg.h" |
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
38 #include "help_mp.h" |
527 | 39 #include "video_out.h" |
40 #include "video_out_internal.h" | |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
41 #include "subopt-helper.h" |
27655
710704af0926
Add missing #include for mplayer.h, fixes the warning:
diego
parents:
27618
diff
changeset
|
42 #include "mplayer.h" |
527 | 43 |
27618 | 44 #define BUFLENGTH 512 |
45 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
46 static const vo_info_t info = |
527 | 47 { |
48 "PNG file", | |
49 "png", | |
50 "Felix Buenemann <atmosfear@users.sourceforge.net>", | |
51 "" | |
52 }; | |
53 | |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
54 const LIBVO_EXTERN (png) |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7926
diff
changeset
|
55 |
24669 | 56 static int z_compression = Z_NO_COMPRESSION; |
27618 | 57 static char *png_outdir = NULL; |
527 | 58 static int framenum = 0; |
28092
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
59 static int use_alpha; |
527 | 60 |
61 struct pngdata { | |
62 FILE * fp; | |
63 png_structp png_ptr; | |
64 png_infop info_ptr; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
65 enum {OK,ERROR} status; |
527 | 66 }; |
3950
e92653caf5d7
osd support, zlib range fix. by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2732
diff
changeset
|
67 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
68 static void png_mkdir(char *buf, int verbose) { |
27618 | 69 struct stat stat_p; |
70 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
71 #ifndef __MINGW32__ |
27618 | 72 if ( mkdir(buf, 0755) < 0 ) { |
73 #else | |
74 if ( mkdir(buf) < 0 ) { | |
75 #endif | |
76 switch (errno) { /* use switch in case other errors need to be caught | |
77 and handled in the future */ | |
78 case EEXIST: | |
79 if ( stat(buf, &stat_p ) < 0 ) { | |
80 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, | |
81 MSGTR_VO_GenericError, strerror(errno) ); | |
82 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, | |
83 MSGTR_VO_UnableToAccess,buf); | |
84 exit_player(MSGTR_Exit_error); | |
85 } | |
86 if ( !S_ISDIR(stat_p.st_mode) ) { | |
87 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, | |
88 buf, MSGTR_VO_ExistsButNoDirectory); | |
89 exit_player(MSGTR_Exit_error); | |
90 } | |
91 if ( !(stat_p.st_mode & S_IWUSR) ) { | |
92 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, | |
93 buf, MSGTR_VO_DirExistsButNotWritable); | |
94 exit_player(MSGTR_Exit_error); | |
95 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
96 |
27618 | 97 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, |
98 buf, MSGTR_VO_DirExistsAndIsWritable); | |
99 break; | |
100 | |
101 default: | |
102 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, | |
103 MSGTR_VO_GenericError, strerror(errno) ); | |
104 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, | |
105 buf, MSGTR_VO_CantCreateDirectory); | |
106 exit_player(MSGTR_Exit_error); | |
107 } /* end switch */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
108 } else if ( verbose ) { |
27618 | 109 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, |
110 buf, MSGTR_VO_DirectoryCreateSuccess); | |
111 } /* end if */ | |
112 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
113 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
114 static int |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14451
diff
changeset
|
115 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
527 | 116 { |
27618 | 117 char buf[BUFLENGTH]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
118 |
527 | 119 if(z_compression == 0) { |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
120 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning1); |
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
121 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning2); |
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
122 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning3); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
123 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
124 |
27618 | 125 snprintf(buf, BUFLENGTH, "%s", png_outdir); |
126 png_mkdir(buf, 1); | |
24671
fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
reimar
parents:
24670
diff
changeset
|
127 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Compression level %i\n", z_compression); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
128 |
527 | 129 return 0; |
130 } | |
131 | |
132 | |
18950 | 133 static struct pngdata create_png (char * fname, int image_width, int image_height, int swapped) |
527 | 134 { |
135 struct pngdata png; | |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
136 |
527 | 137 /*png_structp png_ptr = png_create_write_struct |
138 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, | |
139 user_error_fn, user_warning_fn);*/ | |
140 //png_byte *row_pointers[image_height]; | |
141 png.png_ptr = png_create_write_struct | |
142 (PNG_LIBPNG_VER_STRING, NULL, | |
143 NULL, NULL); | |
144 png.info_ptr = png_create_info_struct(png.png_ptr); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
145 |
527 | 146 if (!png.png_ptr) { |
24671
fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
reimar
parents:
24670
diff
changeset
|
147 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Failed to init png pointer\n"); |
527 | 148 png.status = ERROR; |
149 return png; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
150 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
151 |
527 | 152 if (!png.info_ptr) { |
24671
fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
reimar
parents:
24670
diff
changeset
|
153 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Failed to init png infopointer\n"); |
527 | 154 png_destroy_write_struct(&png.png_ptr, |
155 (png_infopp)NULL); | |
156 png.status = ERROR; | |
157 return png; | |
158 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
159 |
527 | 160 if (setjmp(png.png_ptr->jmpbuf)) { |
24671
fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
reimar
parents:
24670
diff
changeset
|
161 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Internal error!\n"); |
527 | 162 png_destroy_write_struct(&png.png_ptr, &png.info_ptr); |
163 fclose(png.fp); | |
164 png.status = ERROR; | |
165 return png; | |
166 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
167 |
527 | 168 png.fp = fopen (fname, "wb"); |
169 if (png.fp == NULL) { | |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
170 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorOpeningForWriting, strerror(errno)); |
527 | 171 png.status = ERROR; |
172 return png; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
173 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
174 |
24671
fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
reimar
parents:
24670
diff
changeset
|
175 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Init IO\n"); |
527 | 176 png_init_io(png.png_ptr, png.fp); |
177 | |
178 /* set the zlib compression level */ | |
179 png_set_compression_level(png.png_ptr, z_compression); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
180 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
181 |
527 | 182 /*png_set_IHDR(png_ptr, info_ptr, width, height, |
183 bit_depth, color_type, interlace_type, | |
184 compression_type, filter_type)*/ | |
185 png_set_IHDR(png.png_ptr, png.info_ptr, image_width, image_height, | |
28092
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
186 8, use_alpha ? PNG_COLOR_TYPE_RGBA : PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, |
527 | 187 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
188 |
24671
fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
reimar
parents:
24670
diff
changeset
|
189 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Write Info\n"); |
527 | 190 png_write_info(png.png_ptr, png.info_ptr); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
191 |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
192 if(swapped) { |
24671
fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
reimar
parents:
24670
diff
changeset
|
193 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Set BGR Conversion\n"); |
527 | 194 png_set_bgr(png.png_ptr); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
195 } |
527 | 196 |
197 png.status = OK; | |
198 return png; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
199 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
200 |
527 | 201 static uint8_t destroy_png(struct pngdata png) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
202 |
24671
fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
reimar
parents:
24670
diff
changeset
|
203 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Write End\n"); |
527 | 204 png_write_end(png.png_ptr, png.info_ptr); |
205 | |
24671
fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
reimar
parents:
24670
diff
changeset
|
206 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Destroy Write Struct\n"); |
527 | 207 png_destroy_write_struct(&png.png_ptr, &png.info_ptr); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
208 |
527 | 209 fclose (png.fp); |
210 | |
211 return 0; | |
212 } | |
213 | |
7693 | 214 static uint32_t draw_image(mp_image_t* mpi){ |
527 | 215 char buf[100]; |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
216 int k; |
527 | 217 struct pngdata png; |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
218 png_byte *row_pointers[mpi->h]; |
7693 | 219 |
220 // if -dr or -slices then do nothing: | |
221 if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
222 |
27618 | 223 snprintf (buf, 100, "%s/%08d.png", png_outdir, ++framenum); |
527 | 224 |
24670
a2599160737c
Use IMGFMT_IS_BGR instead of mpi->flags&MP_IMGFLAG_SWAPPED, this is easier
reimar
parents:
24669
diff
changeset
|
225 png = create_png(buf, mpi->w, mpi->h, IMGFMT_IS_BGR(mpi->imgfmt)); |
527 | 226 |
227 if(png.status){ | |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
228 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorInCreatePng); |
527 | 229 return 1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
230 } |
527 | 231 |
24671
fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
reimar
parents:
24670
diff
changeset
|
232 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Creating Row Pointers\n"); |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
233 for ( k = 0; k < mpi->h; k++ ) |
7693 | 234 row_pointers[k] = mpi->planes[0]+mpi->stride[0]*k; |
235 | |
527 | 236 //png_write_flush(png.png_ptr); |
237 //png_set_flush(png.png_ptr, nrows); | |
238 | |
17932 | 239 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) { |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
240 mp_msg(MSGT_VO,MSGL_DBG2, "PNG Writing Image Data\n"); } |
527 | 241 png_write_image(png.png_ptr, row_pointers); |
242 | |
7693 | 243 destroy_png(png); |
527 | 244 |
7693 | 245 return VO_TRUE; |
527 | 246 } |
247 | |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
248 static void draw_osd(void){} |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1078
diff
changeset
|
249 |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
250 static void flip_page (void){} |
527 | 251 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
252 static int draw_frame(uint8_t * src[]) |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
253 { |
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
254 return -1; |
527 | 255 } |
256 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
257 static int draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y ) |
527 | 258 { |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
259 return -1; |
527 | 260 } |
261 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
262 static int |
527 | 263 query_format(uint32_t format) |
264 { | |
28092
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
265 const int supported_flags = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE; |
527 | 266 switch(format){ |
27873
80a16d26acda
Use the proper IMGFMT_RGB24 and IMGFMT_BGR24 defines instead of
reimar
parents:
27655
diff
changeset
|
267 case IMGFMT_RGB24: |
80a16d26acda
Use the proper IMGFMT_RGB24 and IMGFMT_BGR24 defines instead of
reimar
parents:
27655
diff
changeset
|
268 case IMGFMT_BGR24: |
28092
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
269 return use_alpha ? 0 : supported_flags; |
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
270 case IMGFMT_RGBA: |
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
271 case IMGFMT_BGRA: |
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
272 return use_alpha ? supported_flags : 0; |
527 | 273 } |
274 return 0; | |
275 } | |
276 | |
27618 | 277 static void uninit(void){ |
278 if (png_outdir) { | |
279 free(png_outdir); | |
280 png_outdir = NULL; | |
281 } | |
282 } | |
527 | 283 |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
284 static void check_events(void){} |
4352 | 285 |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
286 static int int_zero_to_nine(int *sh) |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
287 { |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
288 if ( (*sh < 0) || (*sh > 9) ) |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
289 return 0; |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
290 return 1; |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
291 } |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
292 |
28828
56eee6ffba9b
Make data related to suboption parsing const in libvo
reimar
parents:
28446
diff
changeset
|
293 static const opt_t subopts[] = { |
28922
9dd905e52639
Remove obsolete extra elements from opt_t struct initialization.
diego
parents:
28828
diff
changeset
|
294 {"alpha", OPT_ARG_BOOL, &use_alpha, NULL}, |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
295 {"z", OPT_ARG_INT, &z_compression, (opt_test_f)int_zero_to_nine}, |
28922
9dd905e52639
Remove obsolete extra elements from opt_t struct initialization.
diego
parents:
28828
diff
changeset
|
296 {"outdir", OPT_ARG_MSTRZ, &png_outdir, NULL}, |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
297 {NULL} |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
298 }; |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
299 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
300 static int preinit(const char *arg) |
4352 | 301 { |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
302 z_compression = 0; |
27618 | 303 png_outdir = strdup("."); |
28092
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
304 use_alpha = 0; |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
305 if (subopt_parse(arg, subopts) != 0) { |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
306 return -1; |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
307 } |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
308 return 0; |
4352 | 309 } |
310 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
311 static int control(uint32_t request, void *data, ...) |
4352 | 312 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
313 switch (request) { |
7693 | 314 case VOCTRL_DRAW_IMAGE: |
315 return draw_image(data); | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
316 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
317 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
318 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
319 return VO_NOTIMPL; |
4352 | 320 } |