Mercurial > mplayer.hg
annotate libvo/vo_jpeg.c @ 13283:858b7e04718c
This patch moves the directory creation code to a separate function. I have
tried to re-use as much code as possible, to reduce the size of the patch.
All duplicate code is removed, resulting in my first patch that actually
decreases the size of the binary by about 700 bytes :-)
author | ivo |
---|---|
date | Wed, 08 Sep 2004 01:11:16 +0000 |
parents | 7dfd84faaa09 |
children | 6370626e902b |
rev | line source |
---|---|
13217 | 1 /* ------------------------------------------------------------------------- */ |
2 | |
5648 | 3 /* |
12857 | 4 * vo_jpeg.c, JPEG Renderer for MPlayer |
5648 | 5 * |
13217 | 6 * |
7 * Changelog | |
8 * | |
9 * Original version: Copyright 2002 by Pontscho (pontscho@makacs.poliod.hu) | |
10 * 2003-04-25 Spring cleanup -- Alex | |
11 * 2004-08-04 Added multiple subdirectory support -- Ivo (ivop@euronet.nl) | |
12 * 2004-09-01 Cosmetics update -- Ivo | |
13252 | 13 * 2004-09-05 Added suboptions parser -- Ivo |
5648 | 14 * |
15 */ | |
16 | |
13217 | 17 /* ------------------------------------------------------------------------- */ |
18 | |
19 /* Global Includes */ | |
20 | |
5648 | 21 #include <stdio.h> |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 #include <errno.h> | |
13217 | 25 #include <jpeglib.h> |
26 #include <sys/stat.h> | |
27 #include <sys/types.h> | |
28 #include <unistd.h> | |
13247 | 29 #include <math.h> /* for log10() */ |
5648 | 30 |
13217 | 31 /* ------------------------------------------------------------------------- */ |
32 | |
33 /* Local Includes */ | |
5648 | 34 |
35 #include "config.h" | |
13158 | 36 #include "mp_msg.h" |
5648 | 37 #include "video_out.h" |
38 #include "video_out_internal.h" | |
13158 | 39 #include "mplayer.h" /* for exit_player() */ |
40 #include "help_mp.h" | |
41 | |
13217 | 42 /* ------------------------------------------------------------------------- */ |
43 | |
44 /* Defines */ | |
13158 | 45 |
46 /* Used for temporary buffers to store file- and pathnames */ | |
47 #define BUFLENGTH 512 | |
5648 | 48 |
13217 | 49 /* ------------------------------------------------------------------------- */ |
50 | |
51 /* Info */ | |
52 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7487
diff
changeset
|
53 static vo_info_t info= |
5648 | 54 { |
55 "JPEG file", | |
56 "jpeg", | |
57 "Zoltan Ponekker (pontscho@makacs.poliod.hu)", | |
58 "" | |
59 }; | |
60 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7487
diff
changeset
|
61 LIBVO_EXTERN (jpeg) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7487
diff
changeset
|
62 |
13217 | 63 /* ------------------------------------------------------------------------- */ |
64 | |
65 /* Global Variables */ | |
66 | |
5648 | 67 static int image_width; |
68 static int image_height; | |
69 | |
70 int jpeg_baseline = 1; | |
71 int jpeg_progressive_mode = 0; | |
72 int jpeg_optimize = 100; | |
73 int jpeg_smooth = 0; | |
74 int jpeg_quality = 75; | |
13217 | 75 char *jpeg_outdir = "."; |
76 char *jpeg_subdirs = NULL; | |
77 int jpeg_maxfiles = 1000; | |
5648 | 78 |
13217 | 79 static int framenum = 0; |
80 | |
81 /* ------------------------------------------------------------------------- */ | |
5648 | 82 |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
83 /** \brief Create a directory. |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
84 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
85 * 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
|
86 * 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
|
87 * 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
|
88 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
89 * \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
|
90 * \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
|
91 * 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
|
92 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
93 * \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
|
94 * returns, everything went well. |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
95 */ |
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 void jpeg_mkdir(char *buf, int verbose) { |
13217 | 98 struct stat stat_p; |
13158 | 99 |
13217 | 100 if ( mkdir(buf, 0755) < 0 ) { |
101 switch (errno) { /* use switch in case other errors need to be caught | |
102 and handled in the future */ | |
103 case EEXIST: | |
104 if ( stat(buf, &stat_p ) < 0 ) { | |
105 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, | |
106 MSGTR_VO_JPEG_GenericError, strerror(errno) ); | |
107 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, | |
108 MSGTR_VO_JPEG_UnableToAccess,buf); | |
109 exit_player(MSGTR_Exit_error); | |
110 } | |
111 if ( !S_ISDIR(stat_p.st_mode) ) { | |
112 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, | |
113 buf, MSGTR_VO_JPEG_ExistsButNoDirectory); | |
114 exit_player(MSGTR_Exit_error); | |
115 } | |
116 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
|
117 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
118 buf, MSGTR_VO_JPEG_DirExistsButNotWritable); |
13217 | 119 exit_player(MSGTR_Exit_error); |
120 } | |
121 | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
122 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
123 buf, MSGTR_VO_JPEG_DirExistsAndIsWritable); |
13217 | 124 break; |
13158 | 125 |
13217 | 126 default: |
127 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, | |
128 MSGTR_VO_JPEG_GenericError, strerror(errno) ); | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
129 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", info.short_name, |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
130 buf, MSGTR_VO_JPEG_CantCreateDirectory); |
13217 | 131 exit_player(MSGTR_Exit_error); |
132 } /* end switch */ | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
133 } else if ( verbose ) { |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
134 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s - %s\n", info.short_name, |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
135 buf, MSGTR_VO_JPEG_DirectoryCreateSuccess); |
13217 | 136 } /* end if */ |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
137 } |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
138 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
139 /* ------------------------------------------------------------------------- */ |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
140 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
141 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
142 uint32_t d_height, uint32_t fullscreen, char *title, |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
143 uint32_t format) |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
144 { |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
145 char buf[BUFLENGTH]; |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
146 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
147 /* Create outdir. */ |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
148 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
149 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
|
150 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
151 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
|
152 successful. If not, the player will exit. */ |
13158 | 153 |
13217 | 154 image_height = height; |
155 image_width = width; | |
5648 | 156 |
13217 | 157 return 0; |
5648 | 158 } |
159 | |
13217 | 160 /* ------------------------------------------------------------------------- */ |
5648 | 161 |
13217 | 162 static uint32_t jpeg_write(uint8_t * name, uint8_t * buffer) |
163 { | |
164 FILE *outfile; | |
165 struct jpeg_compress_struct cinfo; | |
166 struct jpeg_error_mgr jerr; | |
167 JSAMPROW row_pointer[1]; | |
168 int row_stride; | |
5648 | 169 |
13217 | 170 if ( !buffer ) return 1; |
171 if ( (outfile = fopen(name, "wb") ) == NULL ) { | |
13252 | 172 mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s\n", info.short_name, |
173 MSGTR_VO_JPEG_CantCreateFile); | |
174 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", | |
175 info.short_name, MSGTR_VO_JPEG_GenericError, | |
176 strerror(errno) ); | |
177 exit_player(MSGTR_Exit_error); | |
13217 | 178 } |
8267 | 179 |
13217 | 180 cinfo.err = jpeg_std_error(&jerr); |
181 jpeg_create_compress(&cinfo); | |
182 jpeg_stdio_dest(&cinfo, outfile); | |
183 | |
184 cinfo.image_width = image_width; | |
185 cinfo.image_height = image_height; | |
186 cinfo.input_components = 3; | |
187 cinfo.in_color_space = JCS_RGB; | |
188 | |
189 jpeg_set_defaults(&cinfo); | |
190 jpeg_set_quality(&cinfo,jpeg_quality, jpeg_baseline); | |
191 cinfo.optimize_coding = jpeg_optimize; | |
192 cinfo.smoothing_factor = jpeg_smooth; | |
5648 | 193 |
13217 | 194 if ( jpeg_progressive_mode ) { |
195 jpeg_simple_progression(&cinfo); | |
196 } | |
197 | |
198 jpeg_start_compress(&cinfo, TRUE); | |
199 | |
200 row_stride = image_width * 3; | |
201 while (cinfo.next_scanline < cinfo.image_height) { | |
202 row_pointer[0] = &buffer[cinfo.next_scanline * row_stride]; | |
203 (void)jpeg_write_scanlines(&cinfo, row_pointer,1); | |
204 } | |
5648 | 205 |
13217 | 206 jpeg_finish_compress(&cinfo); |
207 fclose(outfile); | |
208 jpeg_destroy_compress(&cinfo); | |
209 | |
210 return 0; | |
5648 | 211 } |
212 | |
13217 | 213 /* ------------------------------------------------------------------------- */ |
214 | |
215 static uint32_t draw_frame(uint8_t *src[]) | |
5648 | 216 { |
13217 | 217 static uint32_t framecounter = 0, subdircounter = 0; |
218 char buf[BUFLENGTH]; | |
219 static char subdirname[BUFLENGTH] = ""; | |
220 struct stat stat_p; | |
13158 | 221 |
13217 | 222 /* Start writing to new subdirectory after a certain amount of frames */ |
223 if ( framecounter == jpeg_maxfiles ) { | |
224 framecounter = 0; | |
225 } | |
13158 | 226 |
13217 | 227 /* If framecounter is zero (or reset to zero), increment subdirectory |
228 * number and create the subdirectory. | |
229 * If jpeg_subdirs is not set, do nothing and resort to old behaviour. */ | |
230 if ( !framecounter && jpeg_subdirs ) { | |
231 snprintf(subdirname, BUFLENGTH, "%s%08d", jpeg_subdirs, | |
232 ++subdircounter); | |
233 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
|
234 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
|
235 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
|
236 } |
13217 | 237 |
238 framenum++; | |
13158 | 239 |
13217 | 240 /* snprintf the full pathname of the outputfile */ |
241 snprintf(buf, BUFLENGTH, "%s/%s/%08d.jpg", jpeg_outdir, subdirname, | |
242 framenum); | |
243 | |
244 framecounter++; | |
245 | |
246 return jpeg_write(buf, src[0]); | |
247 } | |
13158 | 248 |
13217 | 249 /* ------------------------------------------------------------------------- */ |
5648 | 250 |
251 static void draw_osd(void) | |
252 { | |
253 } | |
254 | |
13217 | 255 /* ------------------------------------------------------------------------- */ |
256 | |
5648 | 257 static void flip_page (void) |
258 { | |
259 } | |
260 | |
13217 | 261 /* ------------------------------------------------------------------------- */ |
262 | |
263 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, | |
264 int x, int y) | |
5648 | 265 { |
13217 | 266 return 0; |
5648 | 267 } |
268 | |
13217 | 269 /* ------------------------------------------------------------------------- */ |
270 | |
5648 | 271 static uint32_t query_format(uint32_t format) |
272 { | |
13217 | 273 if (format == IMGFMT_RGB24) { |
274 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW; | |
275 } | |
276 | |
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
|
277 return 0; |
5648 | 278 } |
279 | |
13217 | 280 /* ------------------------------------------------------------------------- */ |
281 | |
5648 | 282 static void uninit(void) |
283 { | |
284 } | |
285 | |
13217 | 286 /* ------------------------------------------------------------------------- */ |
287 | |
5648 | 288 static void check_events(void) |
289 { | |
290 } | |
291 | |
13217 | 292 /* ------------------------------------------------------------------------- */ |
293 | |
5648 | 294 static uint32_t preinit(const char *arg) |
295 { | |
13247 | 296 char *buf; /* buf is used to store parsed string values */ |
297 int length; /* length is used when calculating the length of buf */ | |
298 int value; /* storage for parsed integer values */ | |
299 | |
300 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
301 MSGTR_VO_JPEG_ParsingSuboptions); | |
302 | |
303 if (arg) { | |
304 | |
305 while (*arg != '\0') { | |
306 if (!strncmp(arg, ":", 1)) { | |
307 arg++; | |
308 continue; /* multiple ':' is not really an error */ | |
309 } if (!strncmp(arg, "progressive", 11)) { | |
310 arg += 11; | |
311 jpeg_progressive_mode = 1; | |
312 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
313 MSGTR_VO_JPEG_ProgressiveJPEG); | |
314 } else if (!strncmp(arg, "noprogressive", 13)) { | |
315 arg += 13; | |
316 jpeg_progressive_mode = 0; | |
317 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
318 MSGTR_VO_JPEG_NoProgressiveJPEG); | |
319 } else if (!strncmp(arg, "baseline", 8)) { | |
320 arg += 8; | |
321 jpeg_baseline = 1; | |
322 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
323 MSGTR_VO_JPEG_BaselineJPEG); | |
324 } else if (!strncmp(arg, "nobaseline", 10)) { | |
325 arg += 10; | |
326 jpeg_baseline = 0; | |
327 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
328 MSGTR_VO_JPEG_NoBaselineJPEG); | |
329 } else if (!strncmp(arg, "optimize=", 9)) { | |
330 arg += 9; | |
331 if (sscanf(arg, "%d", &value) == 1) { | |
332 if ( (value < 0 ) || (value > 100) ) { | |
333 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
334 info.short_name, "optimize", | |
335 MSGTR_VO_JPEG_ValueOutOfRange, "[0-100]"); | |
336 exit_player(MSGTR_Exit_error); | |
337 } else { | |
338 jpeg_optimize = value; | |
339 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
340 info.short_name, "optimize", value); | |
341 } | |
342 } else { | |
343 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
344 info.short_name, "optimize", | |
345 MSGTR_VO_JPEG_NoValueSpecified); | |
346 exit_player(MSGTR_Exit_error); | |
347 } | |
348 /* only here if value is set and sane */ | |
349 if (value) { | |
350 arg += (int)log10(value) + 1; | |
351 } else { | |
352 arg++; /* log10(0) fails */ | |
353 } | |
354 } else if (!strncmp(arg, "smooth=", 7)) { | |
355 arg += 7; | |
356 if (sscanf(arg, "%d", &value) == 1 ) { | |
357 if ( (value < 0) || (value > 100) ) { | |
358 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
359 info.short_name, "smooth", | |
360 MSGTR_VO_JPEG_ValueOutOfRange, "[0-100]"); | |
361 exit_player(MSGTR_Exit_error); | |
362 } else { | |
363 jpeg_smooth = value; | |
364 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
365 info.short_name, "smooth", value); | |
366 } | |
367 } else { | |
368 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
369 info.short_name, "smooth", | |
370 MSGTR_VO_JPEG_NoValueSpecified); | |
371 exit_player(MSGTR_Exit_error); | |
372 } | |
373 /* only here if value is set and sane */ | |
374 if (value) { | |
375 arg += (int)log10(value) + 1; | |
376 } else { | |
377 arg++; /* log10(0) fails */ | |
378 } | |
379 } else if (!strncmp(arg, "quality=", 8)) { | |
380 arg += 8; | |
381 if (sscanf(arg, "%d", &value) == 1) { | |
382 if ( (value < 0) || (value > 100) ) { | |
383 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
384 info.short_name, "quality", | |
385 MSGTR_VO_JPEG_ValueOutOfRange, "[0-100]"); | |
386 exit_player(MSGTR_Exit_error); | |
387 } else { | |
388 jpeg_quality = value; | |
389 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
390 info.short_name, "quality", value); | |
391 } | |
392 } else { | |
393 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
394 info.short_name, "quality", | |
395 MSGTR_VO_JPEG_NoValueSpecified); | |
396 exit_player(MSGTR_Exit_error); | |
397 } | |
398 /* only here if value is set and sane */ | |
399 if (value) { | |
400 arg += (int)log10(value) + 1; | |
401 } else { | |
402 arg++; /* log10(0) fails */ | |
403 } | |
404 } else if (!strncmp(arg, "outdir=", 7)) { | |
405 arg += 7; | |
406 buf = malloc(strlen(arg)+1); /* maximum length possible */ | |
407 if (!buf) { | |
408 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s\n", info.short_name, | |
409 MSGTR_MemAllocFailed); | |
410 exit_player(MSGTR_Exit_error); | |
411 } | |
412 if (sscanf(arg, "%[^:]", buf) == 1) { | |
413 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %s\n", | |
414 info.short_name, "outdir", buf); | |
415 length = strlen(buf); | |
416 arg += length; | |
417 jpeg_outdir = malloc(length+1); | |
418 strncpy(jpeg_outdir, buf, length+1); | |
419 free(buf); | |
420 } else { | |
421 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
422 info.short_name, "outdir", | |
423 MSGTR_VO_JPEG_NoValueSpecified); | |
424 exit_player(MSGTR_Exit_error); | |
425 } | |
426 } else if (!strncmp(arg, "subdirs=", 8)) { | |
427 arg += 8; | |
428 buf = malloc(strlen(arg)+1); /* maximum length possible */ | |
429 if (!buf) { | |
430 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s\n", info.short_name, | |
431 MSGTR_MemAllocFailed); | |
432 exit_player(MSGTR_Exit_error); | |
433 } | |
434 if (sscanf(arg, "%[^:]", buf) == 1) { | |
435 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %s\n", | |
436 info.short_name, "subdirs", buf); | |
437 length = strlen(buf); | |
438 arg += length; | |
439 jpeg_subdirs = malloc(length+1); | |
440 strncpy(jpeg_subdirs, buf, length+1); | |
441 free(buf); | |
442 } else { | |
443 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
444 info.short_name, "subdirs", | |
445 MSGTR_VO_JPEG_NoValueSpecified); | |
446 exit_player(MSGTR_Exit_error); | |
447 } | |
448 } else if (!strncmp(arg, "maxfiles=", 9)) { | |
449 arg += 9; | |
450 if (sscanf(arg, "%d", &value) == 1) { | |
451 if (value < 1) { | |
452 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
453 info.short_name, "maxfiles", | |
454 MSGTR_VO_JPEG_ValueOutOfRange, ">=1"); | |
455 exit_player(MSGTR_Exit_error); | |
456 } else { | |
457 jpeg_maxfiles = value; | |
458 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
459 info.short_name, "maxfiles", value); | |
460 } | |
461 } else { | |
462 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
463 info.short_name, "maxfiles", | |
464 MSGTR_VO_JPEG_NoValueSpecified); | |
465 exit_player(MSGTR_Exit_error); | |
466 } | |
467 /* only here if value is set and sane */ | |
468 if (value) { | |
469 arg += (int)log10(value) + 1; | |
470 } else { | |
471 arg++; /* log10(0) fails */ | |
472 } | |
473 } else { | |
474 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %-20s...\n", info.short_name, | |
475 MSGTR_VO_JPEG_UnknownOptions, arg); | |
476 exit_player(MSGTR_Exit_error); | |
477 } | |
478 } /* end while */ | |
479 } /* endif */ | |
480 | |
481 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
482 MSGTR_VO_JPEG_SuboptionsParsedOK); | |
13217 | 483 return 0; |
5648 | 484 } |
485 | |
13217 | 486 /* ------------------------------------------------------------------------- */ |
487 | |
5648 | 488 static uint32_t control(uint32_t request, void *data, ...) |
489 { | |
13217 | 490 switch (request) { |
491 case VOCTRL_QUERY_FORMAT: | |
492 return query_format(*((uint32_t*)data)); | |
493 } | |
494 return VO_NOTIMPL; | |
5648 | 495 } |
13158 | 496 |
13217 | 497 /* ------------------------------------------------------------------------- */ |
498 | |
13158 | 499 #undef BUFLENGTH |
500 | |
13217 | 501 /* ------------------------------------------------------------------------- */ |
502 |