Mercurial > mplayer.hg
annotate libvo/vo_jpeg.c @ 25553:6ac1ece1f9fe
Add multiple inclusion guards to all header files that lack them.
author | diego |
---|---|
date | Tue, 01 Jan 2008 21:35:58 +0000 |
parents | c9e9ac2008c2 |
children | 2a34d9fa52ab |
rev | line source |
---|---|
13217 | 1 /* ------------------------------------------------------------------------- */ |
2 | |
5648 | 3 /* |
12857 | 4 * vo_jpeg.c, JPEG Renderer for MPlayer |
5648 | 5 * |
25174 | 6 * Copyright (C) 2002 by Pontscho <pontscho@makacs.poliod.hu> |
7 * Copyright (C) 2003 by Alex | |
8 * Copyright (C) 2004, 2005 by Ivo van Poorten <ivop@euronet.nl> | |
9 * | |
10 * This program is free software; you can redistribute it and/or | |
11 * modify it under the terms of the GNU General Public License | |
12 * as published by the Free Software Foundation; either version 2 | |
13 * of the License, or (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
5648 | 23 * |
24 */ | |
25 | |
13217 | 26 /* ------------------------------------------------------------------------- */ |
27 | |
28 /* Global Includes */ | |
29 | |
5648 | 30 #include <stdio.h> |
31 #include <stdlib.h> | |
32 #include <string.h> | |
33 #include <errno.h> | |
13217 | 34 #include <jpeglib.h> |
35 #include <sys/stat.h> | |
36 #include <sys/types.h> | |
37 #include <unistd.h> | |
5648 | 38 |
13217 | 39 /* ------------------------------------------------------------------------- */ |
40 | |
41 /* Local Includes */ | |
5648 | 42 |
43 #include "config.h" | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
44 #include "subopt-helper.h" |
13158 | 45 #include "mp_msg.h" |
5648 | 46 #include "video_out.h" |
47 #include "video_out_internal.h" | |
13158 | 48 #include "mplayer.h" /* for exit_player() */ |
49 #include "help_mp.h" | |
50 | |
13217 | 51 /* ------------------------------------------------------------------------- */ |
52 | |
53 /* Defines */ | |
13158 | 54 |
55 /* Used for temporary buffers to store file- and pathnames */ | |
56 #define BUFLENGTH 512 | |
5648 | 57 |
13217 | 58 /* ------------------------------------------------------------------------- */ |
59 | |
60 /* Info */ | |
61 | |
25216 | 62 static const vo_info_t info= |
5648 | 63 { |
64 "JPEG file", | |
65 "jpeg", | |
66 "Zoltan Ponekker (pontscho@makacs.poliod.hu)", | |
67 "" | |
68 }; | |
69 | |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
70 const LIBVO_EXTERN (jpeg) |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7487
diff
changeset
|
71 |
13217 | 72 /* ------------------------------------------------------------------------- */ |
73 | |
74 /* Global Variables */ | |
75 | |
5648 | 76 static int image_width; |
77 static int image_height; | |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
78 static int image_d_width; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
79 static int image_d_height; |
5648 | 80 |
81 int jpeg_baseline = 1; | |
82 int jpeg_progressive_mode = 0; | |
83 int jpeg_optimize = 100; | |
84 int jpeg_smooth = 0; | |
85 int jpeg_quality = 75; | |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
86 int jpeg_dpi = 72; /** Screen resolution = 72 dpi */ |
13316 | 87 char *jpeg_outdir = NULL; |
13217 | 88 char *jpeg_subdirs = NULL; |
89 int jpeg_maxfiles = 1000; | |
5648 | 90 |
13217 | 91 static int framenum = 0; |
92 | |
93 /* ------------------------------------------------------------------------- */ | |
5648 | 94 |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
95 /** \brief Create a directory. |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
96 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
97 * This function creates a directory. If it already exists, it tests if |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
98 * it's a directory and not something else, and if it is, it tests whether |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
99 * the directory is writable or not. |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
100 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
101 * \param buf Pointer to directory name. |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
102 * \param verbose Verbose on success. If verbose is non-zero, it will print |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
103 * a message if it was successful in creating the directory. |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
104 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
105 * \return nothing In case anything fails, the player will exit. If it |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
106 * returns, everything went well. |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
107 */ |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
108 |
18950 | 109 static void jpeg_mkdir(char *buf, int verbose) { |
13217 | 110 struct stat stat_p; |
13158 | 111 |
13347 | 112 #ifndef __MINGW32__ |
13217 | 113 if ( mkdir(buf, 0755) < 0 ) { |
13347 | 114 #else |
115 if ( mkdir(buf) < 0 ) { | |
116 #endif | |
13217 | 117 switch (errno) { /* use switch in case other errors need to be caught |
118 and handled in the future */ | |
119 case EEXIST: | |
120 if ( stat(buf, &stat_p ) < 0 ) { | |
121 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
122 MSGTR_VO_GenericError, strerror(errno) ); |
13217 | 123 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
124 MSGTR_VO_UnableToAccess,buf); |
13217 | 125 exit_player(MSGTR_Exit_error); |
126 } | |
127 if ( !S_ISDIR(stat_p.st_mode) ) { | |
128 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
129 buf, MSGTR_VO_ExistsButNoDirectory); |
13217 | 130 exit_player(MSGTR_Exit_error); |
131 } | |
132 if ( !(stat_p.st_mode & S_IWUSR) ) { | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
133 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
134 buf, MSGTR_VO_DirExistsButNotWritable); |
13217 | 135 exit_player(MSGTR_Exit_error); |
136 } | |
137 | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
138 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
139 buf, MSGTR_VO_DirExistsAndIsWritable); |
13217 | 140 break; |
13158 | 141 |
13217 | 142 default: |
143 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
144 MSGTR_VO_GenericError, strerror(errno) ); |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
145 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
146 buf, MSGTR_VO_CantCreateDirectory); |
13217 | 147 exit_player(MSGTR_Exit_error); |
148 } /* end switch */ | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
149 } else if ( verbose ) { |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
150 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
151 buf, MSGTR_VO_DirectoryCreateSuccess); |
13217 | 152 } /* end if */ |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
153 } |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
154 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
155 /* ------------------------------------------------------------------------- */ |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
156 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
157 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14850
diff
changeset
|
158 uint32_t d_height, uint32_t flags, char *title, |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
159 uint32_t format) |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
160 { |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
161 char buf[BUFLENGTH]; |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
162 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
163 /* Create outdir. */ |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
164 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
165 snprintf(buf, BUFLENGTH, "%s", jpeg_outdir); |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
166 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
167 jpeg_mkdir(buf, 1); /* This function only returns if creation was |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
168 successful. If not, the player will exit. */ |
13158 | 169 |
13217 | 170 image_height = height; |
171 image_width = width; | |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
172 /* Save for JFIF-Header PAR */ |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
173 image_d_width = d_width; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
174 image_d_height = d_height; |
5648 | 175 |
13217 | 176 return 0; |
5648 | 177 } |
178 | |
13217 | 179 /* ------------------------------------------------------------------------- */ |
5648 | 180 |
13217 | 181 static uint32_t jpeg_write(uint8_t * name, uint8_t * buffer) |
182 { | |
183 FILE *outfile; | |
184 struct jpeg_compress_struct cinfo; | |
185 struct jpeg_error_mgr jerr; | |
186 JSAMPROW row_pointer[1]; | |
187 int row_stride; | |
5648 | 188 |
13217 | 189 if ( !buffer ) return 1; |
190 if ( (outfile = fopen(name, "wb") ) == NULL ) { | |
13252 | 191 mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
192 MSGTR_VO_CantCreateFile); |
13252 | 193 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
194 info.short_name, MSGTR_VO_GenericError, |
13252 | 195 strerror(errno) ); |
196 exit_player(MSGTR_Exit_error); | |
13217 | 197 } |
8267 | 198 |
13217 | 199 cinfo.err = jpeg_std_error(&jerr); |
200 jpeg_create_compress(&cinfo); | |
201 jpeg_stdio_dest(&cinfo, outfile); | |
202 | |
203 cinfo.image_width = image_width; | |
204 cinfo.image_height = image_height; | |
205 cinfo.input_components = 3; | |
206 cinfo.in_color_space = JCS_RGB; | |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
207 |
13217 | 208 jpeg_set_defaults(&cinfo); |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
209 /* Important: Header info must be set AFTER jpeg_set_defaults() */ |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
210 cinfo.write_JFIF_header = TRUE; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
211 cinfo.JFIF_major_version = 1; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
212 cinfo.JFIF_minor_version = 2; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
213 cinfo.density_unit = 1; /* 0=unknown, 1=dpi, 2=dpcm */ |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
214 /* Image DPI is determined by Y_density, so we leave that at |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
215 jpeg_dpi if possible and crunch X_density instead (PAR > 1) */ |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
216 cinfo.X_density = jpeg_dpi*image_width/image_d_width; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
217 cinfo.Y_density = jpeg_dpi*image_height/image_d_height; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
218 cinfo.write_Adobe_marker = TRUE; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
219 |
13217 | 220 jpeg_set_quality(&cinfo,jpeg_quality, jpeg_baseline); |
221 cinfo.optimize_coding = jpeg_optimize; | |
222 cinfo.smoothing_factor = jpeg_smooth; | |
5648 | 223 |
13217 | 224 if ( jpeg_progressive_mode ) { |
225 jpeg_simple_progression(&cinfo); | |
226 } | |
227 | |
228 jpeg_start_compress(&cinfo, TRUE); | |
229 | |
230 row_stride = image_width * 3; | |
231 while (cinfo.next_scanline < cinfo.image_height) { | |
232 row_pointer[0] = &buffer[cinfo.next_scanline * row_stride]; | |
233 (void)jpeg_write_scanlines(&cinfo, row_pointer,1); | |
234 } | |
5648 | 235 |
13217 | 236 jpeg_finish_compress(&cinfo); |
237 fclose(outfile); | |
238 jpeg_destroy_compress(&cinfo); | |
239 | |
240 return 0; | |
5648 | 241 } |
242 | |
13217 | 243 /* ------------------------------------------------------------------------- */ |
244 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
245 static int draw_frame(uint8_t *src[]) |
5648 | 246 { |
14850 | 247 static int framecounter = 0, subdircounter = 0; |
13217 | 248 char buf[BUFLENGTH]; |
249 static char subdirname[BUFLENGTH] = ""; | |
13158 | 250 |
13217 | 251 /* Start writing to new subdirectory after a certain amount of frames */ |
252 if ( framecounter == jpeg_maxfiles ) { | |
253 framecounter = 0; | |
254 } | |
13158 | 255 |
13217 | 256 /* If framecounter is zero (or reset to zero), increment subdirectory |
257 * number and create the subdirectory. | |
258 * If jpeg_subdirs is not set, do nothing and resort to old behaviour. */ | |
259 if ( !framecounter && jpeg_subdirs ) { | |
13300
47dd02fb02df
Removed unused variable (leftover of having two instances of directory creation
ivo
parents:
13284
diff
changeset
|
260 subdircounter++; |
47dd02fb02df
Removed unused variable (leftover of having two instances of directory creation
ivo
parents:
13284
diff
changeset
|
261 snprintf(subdirname, BUFLENGTH, "%s%08d", jpeg_subdirs, subdircounter); |
13217 | 262 snprintf(buf, BUFLENGTH, "%s/%s", jpeg_outdir, subdirname); |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
263 jpeg_mkdir(buf, 0); /* This function only returns if creation was |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
264 successful. If not, the player will exit. */ |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
265 } |
13217 | 266 |
267 framenum++; | |
13158 | 268 |
13217 | 269 /* snprintf the full pathname of the outputfile */ |
270 snprintf(buf, BUFLENGTH, "%s/%s/%08d.jpg", jpeg_outdir, subdirname, | |
271 framenum); | |
272 | |
273 framecounter++; | |
274 | |
275 return jpeg_write(buf, src[0]); | |
276 } | |
13158 | 277 |
13217 | 278 /* ------------------------------------------------------------------------- */ |
5648 | 279 |
280 static void draw_osd(void) | |
281 { | |
282 } | |
283 | |
13217 | 284 /* ------------------------------------------------------------------------- */ |
285 | |
5648 | 286 static void flip_page (void) |
287 { | |
288 } | |
289 | |
13217 | 290 /* ------------------------------------------------------------------------- */ |
291 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
292 static int draw_slice(uint8_t *src[], int stride[], int w, int h, |
13217 | 293 int x, int y) |
5648 | 294 { |
13217 | 295 return 0; |
5648 | 296 } |
297 | |
13217 | 298 /* ------------------------------------------------------------------------- */ |
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 query_format(uint32_t format) |
5648 | 301 { |
13217 | 302 if (format == IMGFMT_RGB24) { |
303 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW; | |
304 } | |
305 | |
9989
98791b90215a
Spring cleanup: supporting only RGB24 as input (native jpeg lib supports only that, maybe we could later add nativ YCbCr (YUV) support, but not swscale ones)
alex
parents:
9019
diff
changeset
|
306 return 0; |
5648 | 307 } |
308 | |
13217 | 309 /* ------------------------------------------------------------------------- */ |
310 | |
5648 | 311 static void uninit(void) |
312 { | |
13316 | 313 if (jpeg_subdirs) { |
314 free(jpeg_subdirs); | |
315 jpeg_subdirs = NULL; | |
316 } | |
317 if (jpeg_outdir) { | |
318 free(jpeg_outdir); | |
319 jpeg_outdir = NULL; | |
320 } | |
5648 | 321 } |
322 | |
13217 | 323 /* ------------------------------------------------------------------------- */ |
324 | |
5648 | 325 static void check_events(void) |
326 { | |
327 } | |
328 | |
13217 | 329 /* ------------------------------------------------------------------------- */ |
330 | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
331 /** \brief Validation function for values [0-100] |
13316 | 332 */ |
333 | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
334 static int int_zero_hundred(int *val) |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
335 { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
336 if ( (*val >=0) && (*val<=100) ) |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
337 return 1; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
338 return 0; |
13316 | 339 } |
340 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
341 static int preinit(const char *arg) |
5648 | 342 { |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
343 opt_t subopts[] = { |
14850 | 344 {"progressive", OPT_ARG_BOOL, &jpeg_progressive_mode, NULL, 0}, |
345 {"baseline", OPT_ARG_BOOL, &jpeg_baseline, NULL, 0}, | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
346 {"optimize", OPT_ARG_INT, &jpeg_optimize, |
14850 | 347 (opt_test_f)int_zero_hundred, 0}, |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
348 {"smooth", OPT_ARG_INT, &jpeg_smooth, |
14850 | 349 (opt_test_f)int_zero_hundred, 0}, |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
350 {"quality", OPT_ARG_INT, &jpeg_quality, |
14850 | 351 (opt_test_f)int_zero_hundred, 0}, |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
352 {"dpi", OPT_ARG_INT, &jpeg_dpi, NULL, 0}, |
14850 | 353 {"outdir", OPT_ARG_MSTRZ, &jpeg_outdir, NULL, 0}, |
354 {"subdirs", OPT_ARG_MSTRZ, &jpeg_subdirs, NULL, 0}, | |
355 {"maxfiles", OPT_ARG_INT, &jpeg_maxfiles, (opt_test_f)int_pos, 0}, | |
356 {NULL, 0, NULL, NULL, 0} | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
357 }; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
358 const char *info_message = NULL; |
13247 | 359 |
360 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
361 MSGTR_VO_ParsingSuboptions); |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
362 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
363 jpeg_progressive_mode = 0; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
364 jpeg_baseline = 1; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
365 jpeg_optimize = 100; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
366 jpeg_smooth = 0; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
367 jpeg_quality = 75; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
368 jpeg_maxfiles = 1000; |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14508
diff
changeset
|
369 jpeg_outdir = strdup("."); |
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14508
diff
changeset
|
370 jpeg_subdirs = NULL; |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
371 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
372 if (subopt_parse(arg, subopts) != 0) { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
373 return -1; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
374 } |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
375 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
376 if (jpeg_progressive_mode) info_message = MSGTR_VO_JPEG_ProgressiveJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
377 else info_message = MSGTR_VO_JPEG_NoProgressiveJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
378 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
379 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
380 if (jpeg_baseline) info_message = MSGTR_VO_JPEG_BaselineJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
381 else info_message = MSGTR_VO_JPEG_NoBaselineJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
382 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, info_message); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
383 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
384 mp_msg(MSGT_VO, MSGL_V, "%s: optimize --> %d\n", info.short_name, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
385 jpeg_optimize); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
386 mp_msg(MSGT_VO, MSGL_V, "%s: smooth --> %d\n", info.short_name, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
387 jpeg_smooth); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
388 mp_msg(MSGT_VO, MSGL_V, "%s: quality --> %d\n", info.short_name, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
389 jpeg_quality); |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
390 mp_msg(MSGT_VO, MSGL_V, "%s: dpi --> %d\n", info.short_name, |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
391 jpeg_dpi); |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
392 mp_msg(MSGT_VO, MSGL_V, "%s: outdir --> %s\n", info.short_name, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
393 jpeg_outdir); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
394 if (jpeg_subdirs) { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
395 mp_msg(MSGT_VO, MSGL_V, "%s: subdirs --> %s\n", info.short_name, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
396 jpeg_subdirs); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
397 mp_msg(MSGT_VO, MSGL_V, "%s: maxfiles --> %d\n", info.short_name, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
398 jpeg_maxfiles); |
13316 | 399 } |
400 | |
13247 | 401 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
402 MSGTR_VO_SuboptionsParsedOK); |
13217 | 403 return 0; |
5648 | 404 } |
405 | |
13217 | 406 /* ------------------------------------------------------------------------- */ |
407 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
408 static int control(uint32_t request, void *data, ...) |
5648 | 409 { |
13217 | 410 switch (request) { |
411 case VOCTRL_QUERY_FORMAT: | |
412 return query_format(*((uint32_t*)data)); | |
413 } | |
414 return VO_NOTIMPL; | |
5648 | 415 } |
13158 | 416 |
13217 | 417 /* ------------------------------------------------------------------------- */ |
418 | |
13158 | 419 #undef BUFLENGTH |
420 | |
13217 | 421 /* ------------------------------------------------------------------------- */ |
422 |