annotate libvo/vo_jpeg.c @ 13247:933b45ad31d5

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