annotate libvo/vo_jpeg.c @ 13252:7dfd84faaa09

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