Mercurial > mplayer.hg
annotate libvo/vo_jpeg.c @ 14094:a0197f7b0784
remove old buggy workaround. kerneltwosix.h itself will be removed soon if this doesn't cause problems
author | rfelker |
---|---|
date | Fri, 03 Dec 2004 20:55:00 +0000 |
parents | 0b4f2d91b27c |
children | 3673ad04ebfb |
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 |
13347 | 100 #ifndef __MINGW32__ |
13217 | 101 if ( mkdir(buf, 0755) < 0 ) { |
13347 | 102 #else |
103 if ( mkdir(buf) < 0 ) { | |
104 #endif | |
13217 | 105 switch (errno) { /* use switch in case other errors need to be caught |
106 and handled in the future */ | |
107 case EEXIST: | |
108 if ( stat(buf, &stat_p ) < 0 ) { | |
109 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
|
110 MSGTR_VO_GenericError, strerror(errno) ); |
13217 | 111 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
|
112 MSGTR_VO_UnableToAccess,buf); |
13217 | 113 exit_player(MSGTR_Exit_error); |
114 } | |
115 if ( !S_ISDIR(stat_p.st_mode) ) { | |
116 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
|
117 buf, MSGTR_VO_ExistsButNoDirectory); |
13217 | 118 exit_player(MSGTR_Exit_error); |
119 } | |
120 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
|
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 buf, MSGTR_VO_DirExistsButNotWritable); |
13217 | 123 exit_player(MSGTR_Exit_error); |
124 } | |
125 | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
126 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
|
127 buf, MSGTR_VO_DirExistsAndIsWritable); |
13217 | 128 break; |
13158 | 129 |
13217 | 130 default: |
131 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
|
132 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
|
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_CantCreateDirectory); |
13217 | 135 exit_player(MSGTR_Exit_error); |
136 } /* end switch */ | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
137 } else if ( verbose ) { |
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_DirectoryCreateSuccess); |
13217 | 140 } /* end if */ |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
141 } |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
142 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
143 /* ------------------------------------------------------------------------- */ |
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 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
|
146 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
|
147 uint32_t format) |
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 char buf[BUFLENGTH]; |
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 /* Create outdir. */ |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
152 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
153 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
|
154 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
155 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
|
156 successful. If not, the player will exit. */ |
13158 | 157 |
13217 | 158 image_height = height; |
159 image_width = width; | |
5648 | 160 |
13217 | 161 return 0; |
5648 | 162 } |
163 | |
13217 | 164 /* ------------------------------------------------------------------------- */ |
5648 | 165 |
13217 | 166 static uint32_t jpeg_write(uint8_t * name, uint8_t * buffer) |
167 { | |
168 FILE *outfile; | |
169 struct jpeg_compress_struct cinfo; | |
170 struct jpeg_error_mgr jerr; | |
171 JSAMPROW row_pointer[1]; | |
172 int row_stride; | |
5648 | 173 |
13217 | 174 if ( !buffer ) return 1; |
175 if ( (outfile = fopen(name, "wb") ) == NULL ) { | |
13252 | 176 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
|
177 MSGTR_VO_CantCreateFile); |
13252 | 178 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
|
179 info.short_name, MSGTR_VO_GenericError, |
13252 | 180 strerror(errno) ); |
181 exit_player(MSGTR_Exit_error); | |
13217 | 182 } |
8267 | 183 |
13217 | 184 cinfo.err = jpeg_std_error(&jerr); |
185 jpeg_create_compress(&cinfo); | |
186 jpeg_stdio_dest(&cinfo, outfile); | |
187 | |
188 cinfo.image_width = image_width; | |
189 cinfo.image_height = image_height; | |
190 cinfo.input_components = 3; | |
191 cinfo.in_color_space = JCS_RGB; | |
192 | |
193 jpeg_set_defaults(&cinfo); | |
194 jpeg_set_quality(&cinfo,jpeg_quality, jpeg_baseline); | |
195 cinfo.optimize_coding = jpeg_optimize; | |
196 cinfo.smoothing_factor = jpeg_smooth; | |
5648 | 197 |
13217 | 198 if ( jpeg_progressive_mode ) { |
199 jpeg_simple_progression(&cinfo); | |
200 } | |
201 | |
202 jpeg_start_compress(&cinfo, TRUE); | |
203 | |
204 row_stride = image_width * 3; | |
205 while (cinfo.next_scanline < cinfo.image_height) { | |
206 row_pointer[0] = &buffer[cinfo.next_scanline * row_stride]; | |
207 (void)jpeg_write_scanlines(&cinfo, row_pointer,1); | |
208 } | |
5648 | 209 |
13217 | 210 jpeg_finish_compress(&cinfo); |
211 fclose(outfile); | |
212 jpeg_destroy_compress(&cinfo); | |
213 | |
214 return 0; | |
5648 | 215 } |
216 | |
13217 | 217 /* ------------------------------------------------------------------------- */ |
218 | |
219 static uint32_t draw_frame(uint8_t *src[]) | |
5648 | 220 { |
13217 | 221 static uint32_t framecounter = 0, subdircounter = 0; |
222 char buf[BUFLENGTH]; | |
223 static char subdirname[BUFLENGTH] = ""; | |
13158 | 224 |
13217 | 225 /* Start writing to new subdirectory after a certain amount of frames */ |
226 if ( framecounter == jpeg_maxfiles ) { | |
227 framecounter = 0; | |
228 } | |
13158 | 229 |
13217 | 230 /* If framecounter is zero (or reset to zero), increment subdirectory |
231 * number and create the subdirectory. | |
232 * If jpeg_subdirs is not set, do nothing and resort to old behaviour. */ | |
233 if ( !framecounter && jpeg_subdirs ) { | |
13300
47dd02fb02df
Removed unused variable (leftover of having two instances of directory creation
ivo
parents:
13284
diff
changeset
|
234 subdircounter++; |
47dd02fb02df
Removed unused variable (leftover of having two instances of directory creation
ivo
parents:
13284
diff
changeset
|
235 snprintf(subdirname, BUFLENGTH, "%s%08d", jpeg_subdirs, subdircounter); |
13217 | 236 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
|
237 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
|
238 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
|
239 } |
13217 | 240 |
241 framenum++; | |
13158 | 242 |
13217 | 243 /* snprintf the full pathname of the outputfile */ |
244 snprintf(buf, BUFLENGTH, "%s/%s/%08d.jpg", jpeg_outdir, subdirname, | |
245 framenum); | |
246 | |
247 framecounter++; | |
248 | |
249 return jpeg_write(buf, src[0]); | |
250 } | |
13158 | 251 |
13217 | 252 /* ------------------------------------------------------------------------- */ |
5648 | 253 |
254 static void draw_osd(void) | |
255 { | |
256 } | |
257 | |
13217 | 258 /* ------------------------------------------------------------------------- */ |
259 | |
5648 | 260 static void flip_page (void) |
261 { | |
262 } | |
263 | |
13217 | 264 /* ------------------------------------------------------------------------- */ |
265 | |
266 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, | |
267 int x, int y) | |
5648 | 268 { |
13217 | 269 return 0; |
5648 | 270 } |
271 | |
13217 | 272 /* ------------------------------------------------------------------------- */ |
273 | |
5648 | 274 static uint32_t query_format(uint32_t format) |
275 { | |
13217 | 276 if (format == IMGFMT_RGB24) { |
277 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW; | |
278 } | |
279 | |
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
|
280 return 0; |
5648 | 281 } |
282 | |
13217 | 283 /* ------------------------------------------------------------------------- */ |
284 | |
5648 | 285 static void uninit(void) |
286 { | |
13316 | 287 if (jpeg_subdirs) { |
288 free(jpeg_subdirs); | |
289 jpeg_subdirs = NULL; | |
290 } | |
291 if (jpeg_outdir) { | |
292 free(jpeg_outdir); | |
293 jpeg_outdir = NULL; | |
294 } | |
5648 | 295 } |
296 | |
13217 | 297 /* ------------------------------------------------------------------------- */ |
298 | |
5648 | 299 static void check_events(void) |
300 { | |
301 } | |
302 | |
13217 | 303 /* ------------------------------------------------------------------------- */ |
304 | |
13316 | 305 /** \brief Memory allocation failed. |
306 * | |
13317 | 307 * This function can be called if memory allocation failed. It prints a |
13316 | 308 * message and exits the player. |
309 * | |
310 * \return none It never returns. | |
311 */ | |
312 | |
313 void jpeg_malloc_failed(void) { | |
314 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s\n", info.short_name, | |
315 MSGTR_MemAllocFailed); | |
316 exit_player(MSGTR_Exit_error); | |
317 } | |
318 | |
319 /* ------------------------------------------------------------------------- */ | |
320 | |
5648 | 321 static uint32_t preinit(const char *arg) |
322 { | |
13247 | 323 char *buf; /* buf is used to store parsed string values */ |
324 int value; /* storage for parsed integer values */ | |
325 | |
326 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
|
327 MSGTR_VO_ParsingSuboptions); |
13247 | 328 |
329 if (arg) { | |
330 | |
331 while (*arg != '\0') { | |
332 if (!strncmp(arg, ":", 1)) { | |
333 arg++; | |
334 continue; /* multiple ':' is not really an error */ | |
335 } if (!strncmp(arg, "progressive", 11)) { | |
336 arg += 11; | |
337 jpeg_progressive_mode = 1; | |
338 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
339 MSGTR_VO_JPEG_ProgressiveJPEG); | |
340 } else if (!strncmp(arg, "noprogressive", 13)) { | |
341 arg += 13; | |
342 jpeg_progressive_mode = 0; | |
343 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
344 MSGTR_VO_JPEG_NoProgressiveJPEG); | |
345 } else if (!strncmp(arg, "baseline", 8)) { | |
346 arg += 8; | |
347 jpeg_baseline = 1; | |
348 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
349 MSGTR_VO_JPEG_BaselineJPEG); | |
350 } else if (!strncmp(arg, "nobaseline", 10)) { | |
351 arg += 10; | |
352 jpeg_baseline = 0; | |
353 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | |
354 MSGTR_VO_JPEG_NoBaselineJPEG); | |
355 } else if (!strncmp(arg, "optimize=", 9)) { | |
356 arg += 9; | |
357 if (sscanf(arg, "%d", &value) == 1) { | |
358 if ( (value < 0 ) || (value > 100) ) { | |
359 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
360 info.short_name, "optimize", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
361 MSGTR_VO_ValueOutOfRange, "[0-100]"); |
13247 | 362 exit_player(MSGTR_Exit_error); |
363 } else { | |
364 jpeg_optimize = value; | |
365 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
366 info.short_name, "optimize", value); | |
367 } | |
368 } else { | |
369 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
370 info.short_name, "optimize", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
371 MSGTR_VO_NoValueSpecified); |
13247 | 372 exit_player(MSGTR_Exit_error); |
373 } | |
374 /* only here if value is set and sane */ | |
375 if (value) { | |
376 arg += (int)log10(value) + 1; | |
377 } else { | |
378 arg++; /* log10(0) fails */ | |
379 } | |
380 } else if (!strncmp(arg, "smooth=", 7)) { | |
381 arg += 7; | |
382 if (sscanf(arg, "%d", &value) == 1 ) { | |
383 if ( (value < 0) || (value > 100) ) { | |
384 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
385 info.short_name, "smooth", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
386 MSGTR_VO_ValueOutOfRange, "[0-100]"); |
13247 | 387 exit_player(MSGTR_Exit_error); |
388 } else { | |
389 jpeg_smooth = value; | |
390 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
391 info.short_name, "smooth", value); | |
392 } | |
393 } else { | |
394 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
395 info.short_name, "smooth", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
396 MSGTR_VO_NoValueSpecified); |
13247 | 397 exit_player(MSGTR_Exit_error); |
398 } | |
399 /* only here if value is set and sane */ | |
400 if (value) { | |
401 arg += (int)log10(value) + 1; | |
402 } else { | |
403 arg++; /* log10(0) fails */ | |
404 } | |
405 } else if (!strncmp(arg, "quality=", 8)) { | |
406 arg += 8; | |
407 if (sscanf(arg, "%d", &value) == 1) { | |
408 if ( (value < 0) || (value > 100) ) { | |
409 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
410 info.short_name, "quality", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
411 MSGTR_VO_ValueOutOfRange, "[0-100]"); |
13247 | 412 exit_player(MSGTR_Exit_error); |
413 } else { | |
414 jpeg_quality = value; | |
415 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
416 info.short_name, "quality", value); | |
417 } | |
418 } else { | |
419 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
420 info.short_name, "quality", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
421 MSGTR_VO_NoValueSpecified); |
13247 | 422 exit_player(MSGTR_Exit_error); |
423 } | |
424 /* only here if value is set and sane */ | |
425 if (value) { | |
426 arg += (int)log10(value) + 1; | |
427 } else { | |
428 arg++; /* log10(0) fails */ | |
429 } | |
430 } else if (!strncmp(arg, "outdir=", 7)) { | |
431 arg += 7; | |
432 buf = malloc(strlen(arg)+1); /* maximum length possible */ | |
13316 | 433 if (!buf) jpeg_malloc_failed(); /* print msg and exit */ |
13247 | 434 if (sscanf(arg, "%[^:]", buf) == 1) { |
435 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %s\n", | |
436 info.short_name, "outdir", buf); | |
13316 | 437 arg += strlen(buf); |
438 jpeg_outdir = strdup(buf); | |
439 if (!jpeg_outdir) jpeg_malloc_failed(); | |
13247 | 440 free(buf); |
441 } else { | |
442 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
443 info.short_name, "outdir", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
444 MSGTR_VO_NoValueSpecified); |
13247 | 445 exit_player(MSGTR_Exit_error); |
446 } | |
447 } else if (!strncmp(arg, "subdirs=", 8)) { | |
448 arg += 8; | |
449 buf = malloc(strlen(arg)+1); /* maximum length possible */ | |
13316 | 450 if (!buf) jpeg_malloc_failed(); |
13247 | 451 if (sscanf(arg, "%[^:]", buf) == 1) { |
452 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %s\n", | |
453 info.short_name, "subdirs", buf); | |
13316 | 454 arg += strlen(buf); |
455 jpeg_subdirs = strdup(buf); | |
456 if (!jpeg_subdirs) jpeg_malloc_failed(); | |
13247 | 457 free(buf); |
458 } else { | |
459 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
460 info.short_name, "subdirs", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
461 MSGTR_VO_NoValueSpecified); |
13247 | 462 exit_player(MSGTR_Exit_error); |
463 } | |
464 } else if (!strncmp(arg, "maxfiles=", 9)) { | |
465 arg += 9; | |
466 if (sscanf(arg, "%d", &value) == 1) { | |
467 if (value < 1) { | |
468 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s %s.\n", | |
469 info.short_name, "maxfiles", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
470 MSGTR_VO_ValueOutOfRange, ">=1"); |
13247 | 471 exit_player(MSGTR_Exit_error); |
472 } else { | |
473 jpeg_maxfiles = value; | |
474 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s --> %d\n", | |
475 info.short_name, "maxfiles", value); | |
476 } | |
477 } else { | |
478 mp_msg(MSGT_VO, MSGL_ERR, "%s: %s - %s\n", | |
479 info.short_name, "maxfiles", | |
13284
6370626e902b
Renamed some MSGTR_VO_JPEG_* messages to MSGTR_VO_* messages, so they can
ivo
parents:
13283
diff
changeset
|
480 MSGTR_VO_NoValueSpecified); |
13247 | 481 exit_player(MSGTR_Exit_error); |
482 } | |
483 /* only here if value is set and sane */ | |
484 if (value) { | |
485 arg += (int)log10(value) + 1; | |
486 } else { | |
487 arg++; /* log10(0) fails */ | |
488 } | |
489 } else { | |
490 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
|
491 MSGTR_VO_UnknownSuboptions, arg); |
13247 | 492 exit_player(MSGTR_Exit_error); |
493 } | |
494 } /* end while */ | |
495 } /* endif */ | |
496 | |
13316 | 497 /* If jpeg_outdir is not set by an option, resort to default of "." */ |
498 if (!jpeg_outdir) { | |
499 jpeg_outdir = strdup("."); | |
13322
078e32bc2f59
Added one more error check. Forgot it last time (grrr :) ).
ivo
parents:
13317
diff
changeset
|
500 if (!jpeg_outdir) jpeg_malloc_failed(); |
13316 | 501 } |
502 | |
13247 | 503 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
|
504 MSGTR_VO_SuboptionsParsedOK); |
13217 | 505 return 0; |
5648 | 506 } |
507 | |
13217 | 508 /* ------------------------------------------------------------------------- */ |
509 | |
5648 | 510 static uint32_t control(uint32_t request, void *data, ...) |
511 { | |
13217 | 512 switch (request) { |
513 case VOCTRL_QUERY_FORMAT: | |
514 return query_format(*((uint32_t*)data)); | |
515 } | |
516 return VO_NOTIMPL; | |
5648 | 517 } |
13158 | 518 |
13217 | 519 /* ------------------------------------------------------------------------- */ |
520 | |
13158 | 521 #undef BUFLENGTH |
522 | |
13217 | 523 /* ------------------------------------------------------------------------- */ |
524 |