Mercurial > mplayer.hg
annotate libvo/vo_jpeg.c @ 24744:d81eef9beb1b
DirectShow based tv:// driver for win32
Teletext is also supported (but 625 system parameters are hardcoded).
pthreads is required for teletext.
Code is still experimental.
author | voroshil |
---|---|
date | Sat, 13 Oct 2007 17:14:39 +0000 |
parents | a943bc3f26c8 |
children | 3b78fa30a2b7 |
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; | |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
70 static int image_d_width; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
71 static int image_d_height; |
5648 | 72 |
73 int jpeg_baseline = 1; | |
74 int jpeg_progressive_mode = 0; | |
75 int jpeg_optimize = 100; | |
76 int jpeg_smooth = 0; | |
77 int jpeg_quality = 75; | |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
78 int jpeg_dpi = 72; /** Screen resolution = 72 dpi */ |
13316 | 79 char *jpeg_outdir = NULL; |
13217 | 80 char *jpeg_subdirs = NULL; |
81 int jpeg_maxfiles = 1000; | |
5648 | 82 |
13217 | 83 static int framenum = 0; |
84 | |
85 /* ------------------------------------------------------------------------- */ | |
5648 | 86 |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
87 /** \brief Create a directory. |
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 * 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
|
90 * 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
|
91 * 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
|
92 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
93 * \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
|
94 * \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
|
95 * 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
|
96 * |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
97 * \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
|
98 * returns, everything went well. |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
99 */ |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
100 |
18950 | 101 static void jpeg_mkdir(char *buf, int verbose) { |
13217 | 102 struct stat stat_p; |
13158 | 103 |
13347 | 104 #ifndef __MINGW32__ |
13217 | 105 if ( mkdir(buf, 0755) < 0 ) { |
13347 | 106 #else |
107 if ( mkdir(buf) < 0 ) { | |
108 #endif | |
13217 | 109 switch (errno) { /* use switch in case other errors need to be caught |
110 and handled in the future */ | |
111 case EEXIST: | |
112 if ( stat(buf, &stat_p ) < 0 ) { | |
113 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
|
114 MSGTR_VO_GenericError, strerror(errno) ); |
13217 | 115 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
|
116 MSGTR_VO_UnableToAccess,buf); |
13217 | 117 exit_player(MSGTR_Exit_error); |
118 } | |
119 if ( !S_ISDIR(stat_p.st_mode) ) { | |
120 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
|
121 buf, MSGTR_VO_ExistsButNoDirectory); |
13217 | 122 exit_player(MSGTR_Exit_error); |
123 } | |
124 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
|
125 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
|
126 buf, MSGTR_VO_DirExistsButNotWritable); |
13217 | 127 exit_player(MSGTR_Exit_error); |
128 } | |
129 | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
130 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
|
131 buf, MSGTR_VO_DirExistsAndIsWritable); |
13217 | 132 break; |
13158 | 133 |
13217 | 134 default: |
135 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
|
136 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
|
137 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
|
138 buf, MSGTR_VO_CantCreateDirectory); |
13217 | 139 exit_player(MSGTR_Exit_error); |
140 } /* end switch */ | |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
141 } else if ( verbose ) { |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
142 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
|
143 buf, MSGTR_VO_DirectoryCreateSuccess); |
13217 | 144 } /* end if */ |
13283
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 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
147 /* ------------------------------------------------------------------------- */ |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
148 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
149 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14850
diff
changeset
|
150 uint32_t d_height, uint32_t flags, char *title, |
13283
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
151 uint32_t format) |
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 char buf[BUFLENGTH]; |
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 /* Create outdir. */ |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
156 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
157 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
|
158 |
858b7e04718c
This patch moves the directory creation code to a separate function. I have
ivo
parents:
13252
diff
changeset
|
159 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
|
160 successful. If not, the player will exit. */ |
13158 | 161 |
13217 | 162 image_height = height; |
163 image_width = width; | |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
164 /* Save for JFIF-Header PAR */ |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
165 image_d_width = d_width; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
166 image_d_height = d_height; |
5648 | 167 |
13217 | 168 return 0; |
5648 | 169 } |
170 | |
13217 | 171 /* ------------------------------------------------------------------------- */ |
5648 | 172 |
13217 | 173 static uint32_t jpeg_write(uint8_t * name, uint8_t * buffer) |
174 { | |
175 FILE *outfile; | |
176 struct jpeg_compress_struct cinfo; | |
177 struct jpeg_error_mgr jerr; | |
178 JSAMPROW row_pointer[1]; | |
179 int row_stride; | |
5648 | 180 |
13217 | 181 if ( !buffer ) return 1; |
182 if ( (outfile = fopen(name, "wb") ) == NULL ) { | |
13252 | 183 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
|
184 MSGTR_VO_CantCreateFile); |
13252 | 185 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
|
186 info.short_name, MSGTR_VO_GenericError, |
13252 | 187 strerror(errno) ); |
188 exit_player(MSGTR_Exit_error); | |
13217 | 189 } |
8267 | 190 |
13217 | 191 cinfo.err = jpeg_std_error(&jerr); |
192 jpeg_create_compress(&cinfo); | |
193 jpeg_stdio_dest(&cinfo, outfile); | |
194 | |
195 cinfo.image_width = image_width; | |
196 cinfo.image_height = image_height; | |
197 cinfo.input_components = 3; | |
198 cinfo.in_color_space = JCS_RGB; | |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
199 |
13217 | 200 jpeg_set_defaults(&cinfo); |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
201 /* Important: Header info must be set AFTER jpeg_set_defaults() */ |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
202 cinfo.write_JFIF_header = TRUE; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
203 cinfo.JFIF_major_version = 1; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
204 cinfo.JFIF_minor_version = 2; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
205 cinfo.density_unit = 1; /* 0=unknown, 1=dpi, 2=dpcm */ |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
206 /* Image DPI is determined by Y_density, so we leave that at |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
207 jpeg_dpi if possible and crunch X_density instead (PAR > 1) */ |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
208 cinfo.X_density = jpeg_dpi*image_width/image_d_width; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
209 cinfo.Y_density = jpeg_dpi*image_height/image_d_height; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
210 cinfo.write_Adobe_marker = TRUE; |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
211 |
13217 | 212 jpeg_set_quality(&cinfo,jpeg_quality, jpeg_baseline); |
213 cinfo.optimize_coding = jpeg_optimize; | |
214 cinfo.smoothing_factor = jpeg_smooth; | |
5648 | 215 |
13217 | 216 if ( jpeg_progressive_mode ) { |
217 jpeg_simple_progression(&cinfo); | |
218 } | |
219 | |
220 jpeg_start_compress(&cinfo, TRUE); | |
221 | |
222 row_stride = image_width * 3; | |
223 while (cinfo.next_scanline < cinfo.image_height) { | |
224 row_pointer[0] = &buffer[cinfo.next_scanline * row_stride]; | |
225 (void)jpeg_write_scanlines(&cinfo, row_pointer,1); | |
226 } | |
5648 | 227 |
13217 | 228 jpeg_finish_compress(&cinfo); |
229 fclose(outfile); | |
230 jpeg_destroy_compress(&cinfo); | |
231 | |
232 return 0; | |
5648 | 233 } |
234 | |
13217 | 235 /* ------------------------------------------------------------------------- */ |
236 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
237 static int draw_frame(uint8_t *src[]) |
5648 | 238 { |
14850 | 239 static int framecounter = 0, subdircounter = 0; |
13217 | 240 char buf[BUFLENGTH]; |
241 static char subdirname[BUFLENGTH] = ""; | |
13158 | 242 |
13217 | 243 /* Start writing to new subdirectory after a certain amount of frames */ |
244 if ( framecounter == jpeg_maxfiles ) { | |
245 framecounter = 0; | |
246 } | |
13158 | 247 |
13217 | 248 /* If framecounter is zero (or reset to zero), increment subdirectory |
249 * number and create the subdirectory. | |
250 * If jpeg_subdirs is not set, do nothing and resort to old behaviour. */ | |
251 if ( !framecounter && jpeg_subdirs ) { | |
13300
47dd02fb02df
Removed unused variable (leftover of having two instances of directory creation
ivo
parents:
13284
diff
changeset
|
252 subdircounter++; |
47dd02fb02df
Removed unused variable (leftover of having two instances of directory creation
ivo
parents:
13284
diff
changeset
|
253 snprintf(subdirname, BUFLENGTH, "%s%08d", jpeg_subdirs, subdircounter); |
13217 | 254 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
|
255 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
|
256 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
|
257 } |
13217 | 258 |
259 framenum++; | |
13158 | 260 |
13217 | 261 /* snprintf the full pathname of the outputfile */ |
262 snprintf(buf, BUFLENGTH, "%s/%s/%08d.jpg", jpeg_outdir, subdirname, | |
263 framenum); | |
264 | |
265 framecounter++; | |
266 | |
267 return jpeg_write(buf, src[0]); | |
268 } | |
13158 | 269 |
13217 | 270 /* ------------------------------------------------------------------------- */ |
5648 | 271 |
272 static void draw_osd(void) | |
273 { | |
274 } | |
275 | |
13217 | 276 /* ------------------------------------------------------------------------- */ |
277 | |
5648 | 278 static void flip_page (void) |
279 { | |
280 } | |
281 | |
13217 | 282 /* ------------------------------------------------------------------------- */ |
283 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
284 static int draw_slice(uint8_t *src[], int stride[], int w, int h, |
13217 | 285 int x, int y) |
5648 | 286 { |
13217 | 287 return 0; |
5648 | 288 } |
289 | |
13217 | 290 /* ------------------------------------------------------------------------- */ |
291 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
292 static int query_format(uint32_t format) |
5648 | 293 { |
13217 | 294 if (format == IMGFMT_RGB24) { |
295 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW; | |
296 } | |
297 | |
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
|
298 return 0; |
5648 | 299 } |
300 | |
13217 | 301 /* ------------------------------------------------------------------------- */ |
302 | |
5648 | 303 static void uninit(void) |
304 { | |
13316 | 305 if (jpeg_subdirs) { |
306 free(jpeg_subdirs); | |
307 jpeg_subdirs = NULL; | |
308 } | |
309 if (jpeg_outdir) { | |
310 free(jpeg_outdir); | |
311 jpeg_outdir = NULL; | |
312 } | |
5648 | 313 } |
314 | |
13217 | 315 /* ------------------------------------------------------------------------- */ |
316 | |
5648 | 317 static void check_events(void) |
318 { | |
319 } | |
320 | |
13217 | 321 /* ------------------------------------------------------------------------- */ |
322 | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
323 /** \brief Validation function for values [0-100] |
13316 | 324 */ |
325 | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
326 static int int_zero_hundred(int *val) |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
327 { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
328 if ( (*val >=0) && (*val<=100) ) |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
329 return 1; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
330 return 0; |
13316 | 331 } |
332 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
333 static int preinit(const char *arg) |
5648 | 334 { |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
335 opt_t subopts[] = { |
14850 | 336 {"progressive", OPT_ARG_BOOL, &jpeg_progressive_mode, NULL, 0}, |
337 {"baseline", OPT_ARG_BOOL, &jpeg_baseline, NULL, 0}, | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
338 {"optimize", OPT_ARG_INT, &jpeg_optimize, |
14850 | 339 (opt_test_f)int_zero_hundred, 0}, |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
340 {"smooth", OPT_ARG_INT, &jpeg_smooth, |
14850 | 341 (opt_test_f)int_zero_hundred, 0}, |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
342 {"quality", OPT_ARG_INT, &jpeg_quality, |
14850 | 343 (opt_test_f)int_zero_hundred, 0}, |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
344 {"dpi", OPT_ARG_INT, &jpeg_dpi, NULL, 0}, |
14850 | 345 {"outdir", OPT_ARG_MSTRZ, &jpeg_outdir, NULL, 0}, |
346 {"subdirs", OPT_ARG_MSTRZ, &jpeg_subdirs, NULL, 0}, | |
347 {"maxfiles", OPT_ARG_INT, &jpeg_maxfiles, (opt_test_f)int_pos, 0}, | |
348 {NULL, 0, NULL, NULL, 0} | |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
349 }; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
350 const char *info_message = NULL; |
13247 | 351 |
352 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
|
353 MSGTR_VO_ParsingSuboptions); |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
354 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
355 jpeg_progressive_mode = 0; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
356 jpeg_baseline = 1; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
357 jpeg_optimize = 100; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
358 jpeg_smooth = 0; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
359 jpeg_quality = 75; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
360 jpeg_maxfiles = 1000; |
14538
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14508
diff
changeset
|
361 jpeg_outdir = strdup("."); |
00c3c4111017
New suboption type: malloc'ed, zero terminated string
reimar
parents:
14508
diff
changeset
|
362 jpeg_subdirs = NULL; |
14508
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 (subopt_parse(arg, subopts) != 0) { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
365 return -1; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
366 } |
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 if (jpeg_progressive_mode) info_message = MSGTR_VO_JPEG_ProgressiveJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
369 else info_message = MSGTR_VO_JPEG_NoProgressiveJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
370 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
|
371 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
372 if (jpeg_baseline) info_message = MSGTR_VO_JPEG_BaselineJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
373 else info_message = MSGTR_VO_JPEG_NoBaselineJPEG; |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
374 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
|
375 |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
376 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
|
377 jpeg_optimize); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
378 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
|
379 jpeg_smooth); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
380 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
|
381 jpeg_quality); |
17436
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
382 mp_msg(MSGT_VO, MSGL_V, "%s: dpi --> %d\n", info.short_name, |
2ab8452b8ce4
Added DPI (Print-Resolution) and Pixel-Aspect awareness to vo_jpeg.
atmos4
parents:
16171
diff
changeset
|
383 jpeg_dpi); |
14508
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
384 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
|
385 jpeg_outdir); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
386 if (jpeg_subdirs) { |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
387 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
|
388 jpeg_subdirs); |
3673ad04ebfb
Replaced suboption parser by call to suboption helper.
ivo
parents:
13347
diff
changeset
|
389 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
|
390 jpeg_maxfiles); |
13316 | 391 } |
392 | |
13247 | 393 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
|
394 MSGTR_VO_SuboptionsParsedOK); |
13217 | 395 return 0; |
5648 | 396 } |
397 | |
13217 | 398 /* ------------------------------------------------------------------------- */ |
399 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
400 static int control(uint32_t request, void *data, ...) |
5648 | 401 { |
13217 | 402 switch (request) { |
403 case VOCTRL_QUERY_FORMAT: | |
404 return query_format(*((uint32_t*)data)); | |
405 } | |
406 return VO_NOTIMPL; | |
5648 | 407 } |
13158 | 408 |
13217 | 409 /* ------------------------------------------------------------------------- */ |
410 | |
13158 | 411 #undef BUFLENGTH |
412 | |
13217 | 413 /* ------------------------------------------------------------------------- */ |
414 |