Mercurial > mplayer.hg
annotate libvo/vo_png.c @ 30587:5df7d33f5545
Add header for asf_check_header, read_asf_header; avoids forward declarations.
author | diego |
---|---|
date | Wed, 17 Feb 2010 23:45:01 +0000 |
parents | f4e017b6921a |
children | 8fa2f43cb760 |
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 |
26203 | 33 #include "config.h" |
30427 | 34 #include "fmt-conversion.h" |
30516 | 35 #include "mp_core.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
|
36 #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
|
37 #include "help_mp.h" |
527 | 38 #include "video_out.h" |
39 #include "video_out_internal.h" | |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
40 #include "subopt-helper.h" |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
41 #include "libavcodec/avcodec.h" |
527 | 42 |
27618 | 43 #define BUFLENGTH 512 |
44 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
45 static const vo_info_t info = |
527 | 46 { |
47 "PNG file", | |
48 "png", | |
49 "Felix Buenemann <atmosfear@users.sourceforge.net>", | |
50 "" | |
51 }; | |
52 | |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
53 const LIBVO_EXTERN (png) |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7926
diff
changeset
|
54 |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
55 static int z_compression; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
56 static char *png_outdir; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
57 static int framenum; |
28092
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
58 static int use_alpha; |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
59 static AVCodecContext *avctx; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
60 static uint8_t *outbuffer; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
61 int outbuffer_size; |
3950
e92653caf5d7
osd support, zlib range fix. by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2732
diff
changeset
|
62 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
63 static void png_mkdir(char *buf, int verbose) { |
27618 | 64 struct stat stat_p; |
65 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
66 #ifndef __MINGW32__ |
27618 | 67 if ( mkdir(buf, 0755) < 0 ) { |
68 #else | |
69 if ( mkdir(buf) < 0 ) { | |
70 #endif | |
71 switch (errno) { /* use switch in case other errors need to be caught | |
72 and handled in the future */ | |
73 case EEXIST: | |
74 if ( stat(buf, &stat_p ) < 0 ) { | |
75 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, | |
76 MSGTR_VO_GenericError, strerror(errno) ); | |
77 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, | |
78 MSGTR_VO_UnableToAccess,buf); | |
30516 | 79 exit_player(EXIT_ERROR); |
27618 | 80 } |
81 if ( !S_ISDIR(stat_p.st_mode) ) { | |
82 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, | |
83 buf, MSGTR_VO_ExistsButNoDirectory); | |
30516 | 84 exit_player(EXIT_ERROR); |
27618 | 85 } |
86 if ( !(stat_p.st_mode & S_IWUSR) ) { | |
87 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, | |
88 buf, MSGTR_VO_DirExistsButNotWritable); | |
30516 | 89 exit_player(EXIT_ERROR); |
27618 | 90 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
91 |
27618 | 92 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, |
93 buf, MSGTR_VO_DirExistsAndIsWritable); | |
94 break; | |
95 | |
96 default: | |
97 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, | |
98 MSGTR_VO_GenericError, strerror(errno) ); | |
99 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, | |
100 buf, MSGTR_VO_CantCreateDirectory); | |
30516 | 101 exit_player(EXIT_ERROR); |
27618 | 102 } /* end switch */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
103 } else if ( verbose ) { |
27618 | 104 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, |
105 buf, MSGTR_VO_DirectoryCreateSuccess); | |
106 } /* end if */ | |
107 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
108 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
109 static int |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14451
diff
changeset
|
110 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
527 | 111 { |
27618 | 112 char buf[BUFLENGTH]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
113 |
527 | 114 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
|
115 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
|
116 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
|
117 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_PNG_Warning3); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
118 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
119 |
27618 | 120 snprintf(buf, BUFLENGTH, "%s", png_outdir); |
121 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
|
122 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
|
123 |
527 | 124 return 0; |
125 } | |
126 | |
127 | |
7693 | 128 static uint32_t draw_image(mp_image_t* mpi){ |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
129 AVFrame pic; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
130 int buffersize; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
131 int res; |
527 | 132 char buf[100]; |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
133 FILE *outfile; |
7693 | 134 |
135 // if -dr or -slices then do nothing: | |
136 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
|
137 |
27618 | 138 snprintf (buf, 100, "%s/%08d.png", png_outdir, ++framenum); |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
139 outfile = fopen(buf, "wb"); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
140 if (!outfile) { |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
141 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorOpeningForWriting, strerror(errno)); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
142 return 1; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
143 } |
527 | 144 |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
145 avctx->width = mpi->w; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
146 avctx->height = mpi->h; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
147 avctx->pix_fmt = imgfmt2pixfmt(mpi->imgfmt); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
148 pic.data[0] = mpi->planes[0]; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
149 pic.linesize[0] = mpi->stride[0]; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
150 buffersize = mpi->w * mpi->h * 8; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
151 if (outbuffer_size < buffersize) { |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
152 av_freep(&outbuffer); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
153 outbuffer = av_malloc(buffersize); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
154 outbuffer_size = buffersize; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
155 } |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
156 res = avcodec_encode_video(avctx, outbuffer, outbuffer_size, &pic); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
157 |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
158 if(res < 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
|
159 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorInCreatePng); |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
160 fclose(outfile); |
527 | 161 return 1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28922
diff
changeset
|
162 } |
527 | 163 |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
164 fwrite(outbuffer, res, 1, outfile); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
165 fclose(outfile); |
527 | 166 |
7693 | 167 return VO_TRUE; |
527 | 168 } |
169 | |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
170 static void draw_osd(void){} |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1078
diff
changeset
|
171 |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
172 static void flip_page (void){} |
527 | 173 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
174 static int draw_frame(uint8_t * src[]) |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
175 { |
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
176 return -1; |
527 | 177 } |
178 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
179 static int draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y ) |
527 | 180 { |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
181 return -1; |
527 | 182 } |
183 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
184 static int |
527 | 185 query_format(uint32_t format) |
186 { | |
28092
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
187 const int supported_flags = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE; |
527 | 188 switch(format){ |
27873
80a16d26acda
Use the proper IMGFMT_RGB24 and IMGFMT_BGR24 defines instead of
reimar
parents:
27655
diff
changeset
|
189 case IMGFMT_RGB24: |
28092
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
190 return use_alpha ? 0 : supported_flags; |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
191 case IMGFMT_BGR32: |
28092
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
192 return use_alpha ? supported_flags : 0; |
527 | 193 } |
194 return 0; | |
195 } | |
196 | |
27618 | 197 static void uninit(void){ |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
198 avcodec_close(avctx); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
199 av_freep(&avctx); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
200 av_freep(&outbuffer); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
201 outbuffer_size = 0; |
27618 | 202 if (png_outdir) { |
203 free(png_outdir); | |
204 png_outdir = NULL; | |
205 } | |
206 } | |
527 | 207 |
7926
7d2542838d24
- removed YV12 support (builtin yv12->rgb conversion)
arpi
parents:
7694
diff
changeset
|
208 static void check_events(void){} |
4352 | 209 |
30122
1772a5171ac7
Fix function declarations to avoid casting function pointers.
reimar
parents:
29263
diff
changeset
|
210 static int int_zero_to_nine(void *value) |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
211 { |
30122
1772a5171ac7
Fix function declarations to avoid casting function pointers.
reimar
parents:
29263
diff
changeset
|
212 int *sh = value; |
30123
0f5f75b4a015
Simplify range-checking functions for subopt parsing.
reimar
parents:
30122
diff
changeset
|
213 return *sh >= 0 && *sh <= 9; |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
214 } |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
215 |
28828
56eee6ffba9b
Make data related to suboption parsing const in libvo
reimar
parents:
28446
diff
changeset
|
216 static const opt_t subopts[] = { |
28922
9dd905e52639
Remove obsolete extra elements from opt_t struct initialization.
diego
parents:
28828
diff
changeset
|
217 {"alpha", OPT_ARG_BOOL, &use_alpha, NULL}, |
30122
1772a5171ac7
Fix function declarations to avoid casting function pointers.
reimar
parents:
29263
diff
changeset
|
218 {"z", OPT_ARG_INT, &z_compression, int_zero_to_nine}, |
28922
9dd905e52639
Remove obsolete extra elements from opt_t struct initialization.
diego
parents:
28828
diff
changeset
|
219 {"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
|
220 {NULL} |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
221 }; |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
222 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
223 static int preinit(const char *arg) |
4352 | 224 { |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
225 z_compression = 0; |
27618 | 226 png_outdir = strdup("."); |
28092
77c7b422a49d
Add support for writing PNG files with alpha channel in -vo png
reimar
parents:
27873
diff
changeset
|
227 use_alpha = 0; |
14451
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
228 if (subopt_parse(arg, subopts) != 0) { |
4a6f25e88dbb
Implementation of vo_png suboption parser with subopt-helper and removal
ivo
parents:
12857
diff
changeset
|
229 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
|
230 } |
30144
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
231 avcodec_register_all(); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
232 avctx = avcodec_alloc_context(); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
233 if (avcodec_open(avctx, avcodec_find_encoder(CODEC_ID_PNG)) < 0) { |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
234 uninit(); |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
235 return -1; |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
236 } |
0a92a14ced38
Change vo_png to use FFmpeg's png encoder instead of libpng.
reimar
parents:
30123
diff
changeset
|
237 avctx->compression_level = z_compression; |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
238 return 0; |
4352 | 239 } |
240 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
241 static int control(uint32_t request, void *data, ...) |
4352 | 242 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
243 switch (request) { |
7693 | 244 case VOCTRL_DRAW_IMAGE: |
245 return draw_image(data); | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
246 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
247 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
248 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4433
diff
changeset
|
249 return VO_NOTIMPL; |
4352 | 250 } |