Mercurial > mplayer.hg
annotate libvo/vo_jpeg.c @ 14742:76d461a061df
Unified colorkey code for vo xv and vo xvmc.
Made the code also more flexible.
Colorkey drawing is now by default done as
proposed by Marko Macek.
Patch also approved by iive.
author | al |
---|---|
date | Sun, 20 Feb 2005 22:43:25 +0000 |
parents | 00c3c4111017 |
children | 5f0f4c31e18b |
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 |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
14 * 2005-01-16 Replaced suboption parser by call to subopt-helper --Ivo |
5648 | 15 * |
16 */ | |
17 | |
13217 | 18 /* ------------------------------------------------------------------------- */ |
19 | |
20 /* Global Includes */ | |
21 | |
5648 | 22 #include <stdio.h> |
23 #include <stdlib.h> | |
24 #include <string.h> | |
25 #include <errno.h> | |
13217 | 26 #include <jpeglib.h> |
27 #include <sys/stat.h> | |
28 #include <sys/types.h> | |
29 #include <unistd.h> | |
5648 | 30 |
13217 | 31 /* ------------------------------------------------------------------------- */ |
32 | |
33 /* Local Includes */ | |
5648 | 34 |
35 #include "config.h" | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
36 #include "subopt-helper.h" |
13158 | 37 #include "mp_msg.h" |
5648 | 38 #include "video_out.h" |
39 #include "video_out_internal.h" | |
13158 | 40 #include "mplayer.h" /* for exit_player() */ |
41 #include "help_mp.h" | |
42 | |
13217 | 43 /* ------------------------------------------------------------------------- */ |
44 | |
45 /* Defines */ | |
13158 | 46 |
47 /* Used for temporary buffers to store file- and pathnames */ | |
48 #define BUFLENGTH 512 | |
5648 | 49 |
13217 | 50 /* ------------------------------------------------------------------------- */ |
51 | |
52 /* Info */ | |
53 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7487
diff
changeset
|
54 static vo_info_t info= |
5648 | 55 { |
56 "JPEG file", | |
57 "jpeg", | |
58 "Zoltan Ponekker (pontscho@makacs.poliod.hu)", | |
59 "" | |
60 }; | |
61 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7487
diff
changeset
|
62 LIBVO_EXTERN (jpeg) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7487
diff
changeset
|
63 |
13217 | 64 /* ------------------------------------------------------------------------- */ |
65 | |
66 /* Global Variables */ | |
67 | |
5648 | 68 static int image_width; |
69 static int image_height; | |
70 | |
71 int jpeg_baseline = 1; | |
72 int jpeg_progressive_mode = 0; | |
73 int jpeg_optimize = 100; | |
74 int jpeg_smooth = 0; | |
75 int jpeg_quality = 75; | |
13316 | 76 char *jpeg_outdir = NULL; |
13217 | 77 char *jpeg_subdirs = NULL; |
78 int jpeg_maxfiles = 1000; | |
5648 | 79 |
13217 | 80 static int framenum = 0; |
81 | |
82 /* ------------------------------------------------------------------------- */ | |
5648 | 83 |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
84 /** \brief Create a directory. |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
85 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
86 * 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
|
87 * 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
|
88 * 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
|
89 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
90 * \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
|
91 * \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
|
92 * 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
|
93 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
94 * \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
|
95 * returns, everything went well. |
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 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
98 void jpeg_mkdir(char *buf, int verbose) { |
13217 | 99 struct stat stat_p; |
13158 | 100 |
13347 | 101 #ifndef __MINGW32__ |
13217 | 102 if ( mkdir(buf, 0755) < 0 ) { |
13347 | 103 #else |
104 if ( mkdir(buf) < 0 ) { | |
105 #endif | |
13217 | 106 switch (errno) { /* use switch in case other errors need to be caught |
107 and handled in the future */ | |
108 case EEXIST: | |
109 if ( stat(buf, &stat_p ) < 0 ) { | |
110 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
|
111 MSGTR_VO_GenericError, strerror(errno) ); |
13217 | 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 MSGTR_VO_UnableToAccess,buf); |
13217 | 114 exit_player(MSGTR_Exit_error); |
115 } | |
116 if ( !S_ISDIR(stat_p.st_mode) ) { | |
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_ExistsButNoDirectory); |
13217 | 119 exit_player(MSGTR_Exit_error); |
120 } | |
121 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
|
122 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
|
123 buf, MSGTR_VO_DirExistsButNotWritable); |
13217 | 124 exit_player(MSGTR_Exit_error); |
125 } | |
126 | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
127 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
|
128 buf, MSGTR_VO_DirExistsAndIsWritable); |
13217 | 129 break; |
13158 | 130 |
13217 | 131 default: |
132 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
|
133 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
|
134 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
|
135 buf, MSGTR_VO_CantCreateDirectory); |
13217 | 136 exit_player(MSGTR_Exit_error); |
137 } /* end switch */ | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
138 } else if ( verbose ) { |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
139 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
|
140 buf, MSGTR_VO_DirectoryCreateSuccess); |
13217 | 141 } /* end if */ |
13283
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 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
146 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
|
147 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
|
148 uint32_t format) |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
149 { |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
150 char buf[BUFLENGTH]; |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
151 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
152 /* Create outdir. */ |
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 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
|
155 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
156 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
|
157 successful. If not, the player will exit. */ |
13158 | 158 |
13217 | 159 image_height = height; |
160 image_width = width; | |
5648 | 161 |
13217 | 162 return 0; |
5648 | 163 } |
164 | |
13217 | 165 /* ------------------------------------------------------------------------- */ |
5648 | 166 |
13217 | 167 static uint32_t jpeg_write(uint8_t * name, uint8_t * buffer) |
168 { | |
169 FILE *outfile; | |
170 struct jpeg_compress_struct cinfo; | |
171 struct jpeg_error_mgr jerr; | |
172 JSAMPROW row_pointer[1]; | |
173 int row_stride; | |
5648 | 174 |
13217 | 175 if ( !buffer ) return 1; |
176 if ( (outfile = fopen(name, "wb") ) == NULL ) { | |
13252 | 177 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
|
178 MSGTR_VO_CantCreateFile); |
13252 | 179 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
|
180 info.short_name, MSGTR_VO_GenericError, |
13252 | 181 strerror(errno) ); |
182 exit_player(MSGTR_Exit_error); | |
13217 | 183 } |
8267 | 184 |
13217 | 185 cinfo.err = jpeg_std_error(&jerr); |
186 jpeg_create_compress(&cinfo); | |
187 jpeg_stdio_dest(&cinfo, outfile); | |
188 | |
189 cinfo.image_width = image_width; | |
190 cinfo.image_height = image_height; | |
191 cinfo.input_components = 3; | |
192 cinfo.in_color_space = JCS_RGB; | |
193 | |
194 jpeg_set_defaults(&cinfo); | |
195 jpeg_set_quality(&cinfo,jpeg_quality, jpeg_baseline); | |
196 cinfo.optimize_coding = jpeg_optimize; | |
197 cinfo.smoothing_factor = jpeg_smooth; | |
5648 | 198 |
13217 | 199 if ( jpeg_progressive_mode ) { |
200 jpeg_simple_progression(&cinfo); | |
201 } | |
202 | |
203 jpeg_start_compress(&cinfo, TRUE); | |
204 | |
205 row_stride = image_width * 3; | |
206 while (cinfo.next_scanline < cinfo.image_height) { | |
207 row_pointer[0] = &buffer[cinfo.next_scanline * row_stride]; | |
208 (void)jpeg_write_scanlines(&cinfo, row_pointer,1); | |
209 } | |
5648 | 210 |
13217 | 211 jpeg_finish_compress(&cinfo); |
212 fclose(outfile); | |
213 jpeg_destroy_compress(&cinfo); | |
214 | |
215 return 0; | |
5648 | 216 } |
217 | |
13217 | 218 /* ------------------------------------------------------------------------- */ |
219 | |
220 static uint32_t draw_frame(uint8_t *src[]) | |
5648 | 221 { |
13217 | 222 static uint32_t framecounter = 0, subdircounter = 0; |
223 char buf[BUFLENGTH]; | |
224 static char subdirname[BUFLENGTH] = ""; | |
13158 | 225 |
13217 | 226 /* Start writing to new subdirectory after a certain amount of frames */ |
227 if ( framecounter == jpeg_maxfiles ) { | |
228 framecounter = 0; | |
229 } | |
13158 | 230 |
13217 | 231 /* If framecounter is zero (or reset to zero), increment subdirectory |
232 * number and create the subdirectory. | |
233 * If jpeg_subdirs is not set, do nothing and resort to old behaviour. */ | |
234 if ( !framecounter && jpeg_subdirs ) { | |
13300
47dd02fb02df
Removed unused variable (leftover of having two instances of directory creation
ivo
parents:
13284
diff
changeset
|
235 subdircounter++; |
47dd02fb02df
Removed unused variable (leftover of having two instances of directory creation
ivo
parents:
13284
diff
changeset
|
236 snprintf(subdirname, BUFLENGTH, "%s%08d", jpeg_subdirs, subdircounter); |
13217 | 237 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
|
238 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
|
239 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
|
240 } |
13217 | 241 |
242 framenum++; | |
13158 | 243 |
13217 | 244 /* snprintf the full pathname of the outputfile */ |
245 snprintf(buf, BUFLENGTH, "%s/%s/%08d.jpg", jpeg_outdir, subdirname, | |
246 framenum); | |
247 | |
248 framecounter++; | |
249 | |
250 return jpeg_write(buf, src[0]); | |
251 } | |
13158 | 252 |
13217 | 253 /* ------------------------------------------------------------------------- */ |
5648 | 254 |
255 static void draw_osd(void) | |
256 { | |
257 } | |
258 | |
13217 | 259 /* ------------------------------------------------------------------------- */ |
260 | |
5648 | 261 static void flip_page (void) |
262 { | |
263 } | |
264 | |
13217 | 265 /* ------------------------------------------------------------------------- */ |
266 | |
267 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, | |
268 int x, int y) | |
5648 | 269 { |
13217 | 270 return 0; |
5648 | 271 } |
272 | |
13217 | 273 /* ------------------------------------------------------------------------- */ |
274 | |
5648 | 275 static uint32_t query_format(uint32_t format) |
276 { | |
13217 | 277 if (format == IMGFMT_RGB24) { |
278 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW; | |
279 } | |
280 | |
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
|
281 return 0; |
5648 | 282 } |
283 | |
13217 | 284 /* ------------------------------------------------------------------------- */ |
285 | |
5648 | 286 static void uninit(void) |
287 { | |
13316 | 288 if (jpeg_subdirs) { |
289 free(jpeg_subdirs); | |
290 jpeg_subdirs = NULL; | |
291 } | |
292 if (jpeg_outdir) { | |
293 free(jpeg_outdir); | |
294 jpeg_outdir = NULL; | |
295 } | |
5648 | 296 } |
297 | |
13217 | 298 /* ------------------------------------------------------------------------- */ |
299 | |
5648 | 300 static void check_events(void) |
301 { | |
302 } | |
303 | |
13217 | 304 /* ------------------------------------------------------------------------- */ |
305 | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
306 /** \brief Validation function for values [0-100] |
13316 | 307 */ |
308 | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
309 static int int_zero_hundred(int *val) |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
310 { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
311 if ( (*val >=0) && (*val<=100) ) |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
312 return 1; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
313 return 0; |
13316 | 314 } |
315 | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
316 /** \brief Validation function for maxfiles > 0 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
317 */ |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
318 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
319 static int int_pos(int *mf) |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
320 { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
321 if ( *mf > 0 ) |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
322 return 1; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
323 return 0; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
324 } |
13316 | 325 |
5648 | 326 static uint32_t preinit(const char *arg) |
327 { | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
328 opt_t subopts[] = { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
329 {"progressive", OPT_ARG_BOOL, &jpeg_progressive_mode, NULL}, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
330 {"baseline", OPT_ARG_BOOL, &jpeg_baseline, NULL}, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
331 {"optimize", OPT_ARG_INT, &jpeg_optimize, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
332 (opt_test_f)int_zero_hundred}, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
333 {"smooth", OPT_ARG_INT, &jpeg_smooth, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
334 (opt_test_f)int_zero_hundred}, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
335 {"quality", OPT_ARG_INT, &jpeg_quality, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
336 (opt_test_f)int_zero_hundred}, |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14508
diff
changeset
|
337 {"outdir", OPT_ARG_MSTRZ, &jpeg_outdir, NULL}, |
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14508
diff
changeset
|
338 {"subdirs", OPT_ARG_MSTRZ, &jpeg_subdirs, NULL}, |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
339 {"maxfiles", OPT_ARG_INT, &jpeg_maxfiles, (opt_test_f)int_pos}, |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
340 {NULL} |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
341 }; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
342 const char *info_message = NULL; |
13247 | 343 |
344 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
|
345 MSGTR_VO_ParsingSuboptions); |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
346 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
347 jpeg_progressive_mode = 0; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
348 jpeg_baseline = 1; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
349 jpeg_optimize = 100; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
350 jpeg_smooth = 0; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
351 jpeg_quality = 75; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
352 jpeg_maxfiles = 1000; |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14508
diff
changeset
|
353 jpeg_outdir = strdup("."); |
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14508
diff
changeset
|
354 jpeg_subdirs = NULL; |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
355 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
356 if (subopt_parse(arg, subopts) != 0) { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
357 return -1; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
358 } |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
359 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
360 if (jpeg_progressive_mode) info_message = MSGTR_VO_JPEG_ProgressiveJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
361 else info_message = MSGTR_VO_JPEG_NoProgressiveJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
362 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
|
363 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
364 if (jpeg_baseline) info_message = MSGTR_VO_JPEG_BaselineJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
365 else info_message = MSGTR_VO_JPEG_NoBaselineJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
366 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
|
367 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
368 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
|
369 jpeg_optimize); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
370 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
|
371 jpeg_smooth); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
372 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
|
373 jpeg_quality); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
374 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
|
375 jpeg_outdir); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
376 if (jpeg_subdirs) { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
377 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
|
378 jpeg_subdirs); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
379 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
|
380 jpeg_maxfiles); |
13316 | 381 } |
382 | |
13247 | 383 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
|
384 MSGTR_VO_SuboptionsParsedOK); |
13217 | 385 return 0; |
5648 | 386 } |
387 | |
13217 | 388 /* ------------------------------------------------------------------------- */ |
389 | |
5648 | 390 static uint32_t control(uint32_t request, void *data, ...) |
391 { | |
13217 | 392 switch (request) { |
393 case VOCTRL_QUERY_FORMAT: | |
394 return query_format(*((uint32_t*)data)); | |
395 } | |
396 return VO_NOTIMPL; | |
5648 | 397 } |
13158 | 398 |
13217 | 399 /* ------------------------------------------------------------------------- */ |
400 | |
13158 | 401 #undef BUFLENGTH |
402 | |
13217 | 403 /* ------------------------------------------------------------------------- */ |
404 |