Mercurial > mplayer.hg
annotate libvo/vo_jpeg.c @ 13316:0d17bef9894d
* Changed malloc and strncpy to strdup. Less code.
* More error checking. If malloc or strdup fails, print message and exit.
* Free malloc'd memory when uninit is called.
* Moved default of jpeg_outdir to preinit, so it is always malloc'd and can
easily be freed at uninit.
author | ivo |
---|---|
date | Sat, 11 Sep 2004 19:59:31 +0000 |
parents | 47dd02fb02df |
children | 42d52a9f72a4 |
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; | |
13316 | 75 char *jpeg_outdir = NULL; |
13217 | 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, | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
106 MSGTR_VO_GenericError, strerror(errno) ); |
13217 | 107 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
|
108 MSGTR_VO_UnableToAccess,buf); |
13217 | 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, | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
113 buf, MSGTR_VO_ExistsButNoDirectory); |
13217 | 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, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
118 buf, MSGTR_VO_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, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
123 buf, MSGTR_VO_DirExistsAndIsWritable); |
13217 | 124 break; |
13158 | 125 |
13217 | 126 default: |
127 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
|
128 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
|
129 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
|
130 buf, MSGTR_VO_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, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
135 buf, MSGTR_VO_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, |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
173 MSGTR_VO_CantCreateFile); |
13252 | 174 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
|
175 info.short_name, MSGTR_VO_GenericError, |
13252 | 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] = ""; | |
13158 | 220 |
13217 | 221 /* Start writing to new subdirectory after a certain amount of frames */ |
222 if ( framecounter == jpeg_maxfiles ) { | |
223 framecounter = 0; | |
224 } | |
13158 | 225 |
13217 | 226 /* If framecounter is zero (or reset to zero), increment subdirectory |
227 * number and create the subdirectory. | |
228 * If jpeg_subdirs is not set, do nothing and resort to old behaviour. */ | |
229 if ( !framecounter && jpeg_subdirs ) { | |
13300
47dd02fb02df
Removed unused variable (leftover of having two instances of directory creation
ivo
parents:
13284
diff
changeset
|
230 subdircounter++; |
47dd02fb02df
Removed unused variable (leftover of having two instances of directory creation
ivo
parents:
13284
diff
changeset
|
231 snprintf(subdirname, BUFLENGTH, "%s%08d", jpeg_subdirs, subdircounter); |
13217 | 232 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
|
233 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
|
234 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
|
235 } |
13217 | 236 |
237 framenum++; | |
13158 | 238 |
13217 | 239 /* snprintf the full pathname of the outputfile */ |
240 snprintf(buf, BUFLENGTH, "%s/%s/%08d.jpg", jpeg_outdir, subdirname, | |
241 framenum); | |
242 | |
243 framecounter++; | |
244 | |
245 return jpeg_write(buf, src[0]); | |
246 } | |
13158 | 247 |
13217 | 248 /* ------------------------------------------------------------------------- */ |
5648 | 249 |
250 static void draw_osd(void) | |
251 { | |
252 } | |
253 | |
13217 | 254 /* ------------------------------------------------------------------------- */ |
255 | |
5648 | 256 static void flip_page (void) |
257 { | |
258 } | |
259 | |
13217 | 260 /* ------------------------------------------------------------------------- */ |
261 | |
262 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, | |
263 int x, int y) | |
5648 | 264 { |
13217 | 265 return 0; |
5648 | 266 } |
267 | |
13217 | 268 /* ------------------------------------------------------------------------- */ |
269 | |
5648 | 270 static uint32_t query_format(uint32_t format) |
271 { | |
13217 | 272 if (format == IMGFMT_RGB24) { |
273 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW; | |
274 } | |
275 | |
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
|
276 return 0; |
5648 | 277 } |
278 | |
13217 | 279 /* ------------------------------------------------------------------------- */ |
280 | |
5648 | 281 static void uninit(void) |
282 { | |
13316 | 283 if (jpeg_subdirs) { |
284 free(jpeg_subdirs); | |
285 jpeg_subdirs = NULL; | |
286 } | |
287 if (jpeg_outdir) { | |
288 free(jpeg_outdir); | |
289 jpeg_outdir = NULL; | |
290 } | |
5648 | 291 } |
292 | |
13217 | 293 /* ------------------------------------------------------------------------- */ |
294 | |
5648 | 295 static void check_events(void) |
296 { | |
297 } | |
298 | |
13217 | 299 /* ------------------------------------------------------------------------- */ |
300 | |
13316 | 301 /** \brief Memory allocation failed. |
302 * | |
303 * This function can be called if memory allocations failed. It prints a | |
304 * message and exits the player. | |
305 * | |
306 * \return none It never returns. | |
307 */ | |
308 | |
309 void jpeg_malloc_failed(void) { | |
310 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s\n", info.short_name, | |
311 MSGTR_MemAllocFailed); | |
312 exit_player(MSGTR_Exit_error); | |
313 } | |
314 | |
315 /* ------------------------------------------------------------------------- */ | |
316 | |
5648 | 317 static uint32_t preinit(const char *arg) |
318 { | |
13247 | 319 char *buf; /* buf is used to store parsed string values */ |
320 int value; /* storage for parsed integer values */ | |
321 | |
322 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
|
323 MSGTR_VO_ParsingSuboptions); |
13247 | 324 |
325 if (arg) { | |
326 | |
327 while (*arg != '\0') { | |
328 if (!strncmp(arg, ":", 1)) { | |
329 arg++; | |
330 continue; /* multiple ':' is not really an error */ | |
331 } if (!strncmp(arg, "progressive", 11)) { | |
332 arg += 11; | |
333 jpeg_progressive_mode = 1; | |
334 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
335 MSGTR_VO_JPEG_ProgressiveJPEG); | |
336 } else if (!strncmp(arg, "noprogressive", 13)) { | |
337 arg += 13; | |
338 jpeg_progressive_mode = 0; | |
339 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
340 MSGTR_VO_JPEG_NoProgressiveJPEG); | |
341 } else if (!strncmp(arg, "baseline", 8)) { | |
342 arg += 8; | |
343 jpeg_baseline = 1; | |
344 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
345 MSGTR_VO_JPEG_BaselineJPEG); | |
346 } else if (!strncmp(arg, "nobaseline", 10)) { | |
347 arg += 10; | |
348 jpeg_baseline = 0; | |
349 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
350 MSGTR_VO_JPEG_NoBaselineJPEG); | |
351 } else if (!strncmp(arg, "optimize=", 9)) { | |
352 arg += 9; | |
353 if (sscanf(arg, "%d", &value) == 1) { | |
354 if ( (value < 0 ) || (value > 100) ) { | |
355 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
356 info.short_name, "optimize", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
357 MSGTR_VO_ValueOutOfRange, "[0-100]"); |
13247 | 358 exit_player(MSGTR_Exit_error); |
359 } else { | |
360 jpeg_optimize = value; | |
361 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
362 info.short_name, "optimize", value); | |
363 } | |
364 } else { | |
365 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
366 info.short_name, "optimize", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
367 MSGTR_VO_NoValueSpecified); |
13247 | 368 exit_player(MSGTR_Exit_error); |
369 } | |
370 /* only here if value is set and sane */ | |
371 if (value) { | |
372 arg += (int)log10(value) + 1; | |
373 } else { | |
374 arg++; /* log10(0) fails */ | |
375 } | |
376 } else if (!strncmp(arg, "smooth=", 7)) { | |
377 arg += 7; | |
378 if (sscanf(arg, "%d", &value) == 1 ) { | |
379 if ( (value < 0) || (value > 100) ) { | |
380 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
381 info.short_name, "smooth", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
382 MSGTR_VO_ValueOutOfRange, "[0-100]"); |
13247 | 383 exit_player(MSGTR_Exit_error); |
384 } else { | |
385 jpeg_smooth = value; | |
386 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
387 info.short_name, "smooth", value); | |
388 } | |
389 } else { | |
390 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
391 info.short_name, "smooth", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
392 MSGTR_VO_NoValueSpecified); |
13247 | 393 exit_player(MSGTR_Exit_error); |
394 } | |
395 /* only here if value is set and sane */ | |
396 if (value) { | |
397 arg += (int)log10(value) + 1; | |
398 } else { | |
399 arg++; /* log10(0) fails */ | |
400 } | |
401 } else if (!strncmp(arg, "quality=", 8)) { | |
402 arg += 8; | |
403 if (sscanf(arg, "%d", &value) == 1) { | |
404 if ( (value < 0) || (value > 100) ) { | |
405 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
406 info.short_name, "quality", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
407 MSGTR_VO_ValueOutOfRange, "[0-100]"); |
13247 | 408 exit_player(MSGTR_Exit_error); |
409 } else { | |
410 jpeg_quality = value; | |
411 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
412 info.short_name, "quality", value); | |
413 } | |
414 } else { | |
415 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
416 info.short_name, "quality", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
417 MSGTR_VO_NoValueSpecified); |
13247 | 418 exit_player(MSGTR_Exit_error); |
419 } | |
420 /* only here if value is set and sane */ | |
421 if (value) { | |
422 arg += (int)log10(value) + 1; | |
423 } else { | |
424 arg++; /* log10(0) fails */ | |
425 } | |
426 } else if (!strncmp(arg, "outdir=", 7)) { | |
427 arg += 7; | |
428 buf = malloc(strlen(arg)+1); /* maximum length possible */ | |
13316 | 429 if (!buf) jpeg_malloc_failed(); /* print msg and exit */ |
13247 | 430 if (sscanf(arg, "%[^:]", buf) == 1) { |
431 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %s\n", | |
432 info.short_name, "outdir", buf); | |
13316 | 433 arg += strlen(buf); |
434 jpeg_outdir = strdup(buf); | |
435 if (!jpeg_outdir) jpeg_malloc_failed(); | |
13247 | 436 free(buf); |
437 } else { | |
438 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
439 info.short_name, "outdir", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
440 MSGTR_VO_NoValueSpecified); |
13247 | 441 exit_player(MSGTR_Exit_error); |
442 } | |
443 } else if (!strncmp(arg, "subdirs=", 8)) { | |
444 arg += 8; | |
445 buf = malloc(strlen(arg)+1); /* maximum length possible */ | |
13316 | 446 if (!buf) jpeg_malloc_failed(); |
13247 | 447 if (sscanf(arg, "%[^:]", buf) == 1) { |
448 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %s\n", | |
449 info.short_name, "subdirs", buf); | |
13316 | 450 arg += strlen(buf); |
451 jpeg_subdirs = strdup(buf); | |
452 if (!jpeg_subdirs) jpeg_malloc_failed(); | |
13247 | 453 free(buf); |
454 } else { | |
455 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
456 info.short_name, "subdirs", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
457 MSGTR_VO_NoValueSpecified); |
13247 | 458 exit_player(MSGTR_Exit_error); |
459 } | |
460 } else if (!strncmp(arg, "maxfiles=", 9)) { | |
461 arg += 9; | |
462 if (sscanf(arg, "%d", &value) == 1) { | |
463 if (value < 1) { | |
464 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
465 info.short_name, "maxfiles", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
466 MSGTR_VO_ValueOutOfRange, ">=1"); |
13247 | 467 exit_player(MSGTR_Exit_error); |
468 } else { | |
469 jpeg_maxfiles = value; | |
470 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
471 info.short_name, "maxfiles", value); | |
472 } | |
473 } else { | |
474 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
475 info.short_name, "maxfiles", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
476 MSGTR_VO_NoValueSpecified); |
13247 | 477 exit_player(MSGTR_Exit_error); |
478 } | |
479 /* only here if value is set and sane */ | |
480 if (value) { | |
481 arg += (int)log10(value) + 1; | |
482 } else { | |
483 arg++; /* log10(0) fails */ | |
484 } | |
485 } else { | |
486 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %-20s...\n", info.short_name, | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
487 MSGTR_VO_UnknownSuboptions, arg); |
13247 | 488 exit_player(MSGTR_Exit_error); |
489 } | |
490 } /* end while */ | |
491 } /* endif */ | |
492 | |
13316 | 493 /* If jpeg_outdir is not set by an option, resort to default of "." */ |
494 if (!jpeg_outdir) { | |
495 jpeg_outdir = strdup("."); | |
496 } | |
497 | |
13247 | 498 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
|
499 MSGTR_VO_SuboptionsParsedOK); |
13217 | 500 return 0; |
5648 | 501 } |
502 | |
13217 | 503 /* ------------------------------------------------------------------------- */ |
504 | |
5648 | 505 static uint32_t control(uint32_t request, void *data, ...) |
506 { | |
13217 | 507 switch (request) { |
508 case VOCTRL_QUERY_FORMAT: | |
509 return query_format(*((uint32_t*)data)); | |
510 } | |
511 return VO_NOTIMPL; | |
5648 | 512 } |
13158 | 513 |
13217 | 514 /* ------------------------------------------------------------------------- */ |
515 | |
13158 | 516 #undef BUFLENGTH |
517 | |
13217 | 518 /* ------------------------------------------------------------------------- */ |
519 |