Mercurial > mplayer.hg
annotate codec-cfg.c @ 6495:0ae1387363a2
10l
author | gabucino |
---|---|
date | Sat, 22 Jun 2002 09:07:29 +0000 |
parents | 37fb529873d7 |
children | f0788e0f7475 |
rev | line source |
---|---|
319 | 1 /* |
2 * codec.conf parser | |
3 * by Szabolcs Berecz <szabi@inf.elte.hu> | |
4 * (C) 2001 | |
4676 | 5 * |
6 * to compile tester app: gcc -Iloader/ -DTESTING -o codec-cfg codec-cfg.c | |
7 * to compile CODECS2HTML: gcc -Iloader/ -DCODECS2HTML -o codecs2html codecs-cfg.c | |
8 * | |
9 * TODO: implement informat in CODECS2HTML too | |
319 | 10 */ |
303 | 11 |
319 | 12 #define DEBUG |
303 | 13 |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
14 //disable asserts |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
15 #define NDEBUG |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
16 |
297 | 17 #include <stdio.h> |
18 #include <stdlib.h> | |
19 #include <fcntl.h> | |
20 #include <unistd.h> | |
21 #include <errno.h> | |
22 #include <ctype.h> | |
23 #include <assert.h> | |
24 #include <string.h> | |
25 | |
5284
0a58c2ef1da1
added missing #include config.h, removed LIBVO2 ifdef.
arpi
parents:
5263
diff
changeset
|
26 #include "config.h" |
5937 | 27 #include "mp_msg.h" |
5284
0a58c2ef1da1
added missing #include config.h, removed LIBVO2 ifdef.
arpi
parents:
5263
diff
changeset
|
28 |
2052 | 29 // for mmioFOURCC: |
1305
0a8237e28ce0
Use FOURCC macro to encode fcc values. Avoids accessing 32-bit data from
jkeil
parents:
1297
diff
changeset
|
30 #include "wine/avifmt.h" |
0a8237e28ce0
Use FOURCC macro to encode fcc values. Avoids accessing 32-bit data from
jkeil
parents:
1297
diff
changeset
|
31 |
408 | 32 #include "libvo/img_format.h" |
297 | 33 #include "codec-cfg.h" |
34 | |
5937 | 35 #define PRINT_LINENUM mp_msg(MSGT_CODECCFG,MSGL_ERR," at line %d\n", line_num) |
328 | 36 |
319 | 37 #define MAX_NR_TOKEN 16 |
297 | 38 |
39 #define MAX_LINE_LEN 1000 | |
40 | |
41 #define RET_EOF -1 | |
42 #define RET_EOL -2 | |
43 | |
328 | 44 #define TYPE_VIDEO 0 |
45 #define TYPE_AUDIO 1 | |
297 | 46 |
303 | 47 static int add_to_fourcc(char *s, char *alias, unsigned int *fourcc, |
297 | 48 unsigned int *map) |
49 { | |
319 | 50 int i, j, freeslots; |
51 unsigned int tmp; | |
52 | |
53 /* find first unused slot */ | |
54 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++) | |
55 /* NOTHING */; | |
56 freeslots = CODECS_MAX_FOURCC - i; | |
57 if (!freeslots) | |
328 | 58 goto err_out_too_many; |
319 | 59 |
60 do { | |
1305
0a8237e28ce0
Use FOURCC macro to encode fcc values. Avoids accessing 32-bit data from
jkeil
parents:
1297
diff
changeset
|
61 tmp = mmioFOURCC(s[0], s[1], s[2], s[3]); |
319 | 62 for (j = 0; j < i; j++) |
63 if (tmp == fourcc[j]) | |
328 | 64 goto err_out_duplicated; |
319 | 65 fourcc[i] = tmp; |
2681 | 66 map[i] = alias ? mmioFOURCC(alias[0], alias[1], alias[2], alias[3]) : tmp; |
319 | 67 s += 4; |
68 i++; | |
69 } while ((*(s++) == ',') && --freeslots); | |
70 | |
71 if (!freeslots) | |
328 | 72 goto err_out_too_many; |
319 | 73 if (*(--s) != '\0') |
361 | 74 goto err_out_parse_error; |
319 | 75 return 1; |
328 | 76 err_out_duplicated: |
5937 | 77 mp_msg(MSGT_CODECCFG,MSGL_ERR,"duplicated fourcc/format"); |
319 | 78 return 0; |
328 | 79 err_out_too_many: |
5937 | 80 mp_msg(MSGT_CODECCFG,MSGL_ERR,"too many fourcc/format..."); |
361 | 81 return 0; |
82 err_out_parse_error: | |
5937 | 83 mp_msg(MSGT_CODECCFG,MSGL_ERR,"parse error"); |
319 | 84 return 0; |
85 } | |
86 | |
87 static int add_to_format(char *s, unsigned int *fourcc, unsigned int *fourccmap) | |
88 { | |
89 int i, j; | |
361 | 90 char *endptr; |
297 | 91 |
92 /* find first unused slot */ | |
93 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++) | |
94 /* NOTHING */; | |
95 if (i == CODECS_MAX_FOURCC) { | |
5937 | 96 mp_msg(MSGT_CODECCFG,MSGL_ERR,"too many fourcc/format..."); |
297 | 97 return 0; |
98 } | |
99 | |
361 | 100 fourcc[i]=fourccmap[i]=strtoul(s,&endptr,0); |
101 if (*endptr != '\0') { | |
5937 | 102 mp_msg(MSGT_CODECCFG,MSGL_ERR,"parse error"); |
361 | 103 return 0; |
104 } | |
319 | 105 for (j = 0; j < i; j++) |
106 if (fourcc[j] == fourcc[i]) { | |
5937 | 107 mp_msg(MSGT_CODECCFG,MSGL_ERR,"duplicated fourcc/format"); |
319 | 108 return 0; |
109 } | |
300 | 110 |
297 | 111 return 1; |
112 } | |
113 | |
408 | 114 static struct { |
115 const char *name; | |
116 const unsigned int num; | |
117 } fmt_table[] = { | |
415 | 118 {"YV12", IMGFMT_YV12}, |
119 {"I420", IMGFMT_I420}, | |
120 {"IYUV", IMGFMT_IYUV}, | |
6489
37fb529873d7
yvu9 support, 0l to me becouse i forget to commit it (0l becouse i've drinken 1litre of bier, yet ;)
alex
parents:
6343
diff
changeset
|
121 {"YVU9", IMGFMT_YVU9}, |
408 | 122 |
415 | 123 {"YUY2", IMGFMT_YUY2}, |
124 {"UYVY", IMGFMT_UYVY}, | |
125 {"YVYU", IMGFMT_YVYU}, | |
408 | 126 |
415 | 127 {"RGB8", IMGFMT_RGB|8}, |
128 {"RGB15", IMGFMT_RGB|15}, | |
129 {"RGB16", IMGFMT_RGB|16}, | |
130 {"RGB24", IMGFMT_RGB|24}, | |
131 {"RGB32", IMGFMT_RGB|32}, | |
132 {"BGR8", IMGFMT_BGR|8}, | |
133 {"BGR15", IMGFMT_BGR|15}, | |
134 {"BGR16", IMGFMT_BGR|16}, | |
135 {"BGR24", IMGFMT_BGR|24}, | |
136 {"BGR32", IMGFMT_BGR|32}, | |
1871 | 137 |
138 {"MPES", IMGFMT_MPEGPES}, | |
415 | 139 {NULL, 0} |
297 | 140 }; |
408 | 141 |
607 | 142 |
4675 | 143 static int add_to_inout(char *sfmt, char *sflags, unsigned int *outfmt, |
607 | 144 unsigned char *outflags) |
145 { | |
146 | |
299 | 147 static char *flagstr[] = { |
148 "flip", | |
149 "noflip", | |
150 "yuvhack", | |
5249 | 151 "query", |
6103 | 152 "static", |
299 | 153 NULL |
154 }; | |
155 | |
319 | 156 int i, j, freeslots; |
297 | 157 unsigned char flags; |
158 | |
159 for (i = 0; i < CODECS_MAX_OUTFMT && outfmt[i] != 0xffffffff; i++) | |
160 /* NOTHING */; | |
319 | 161 freeslots = CODECS_MAX_OUTFMT - i; |
162 if (!freeslots) | |
328 | 163 goto err_out_too_many; |
297 | 164 |
319 | 165 flags = 0; |
361 | 166 if(sflags) { |
167 do { | |
168 for (j = 0; flagstr[j] != NULL; j++) | |
169 if (!strncmp(sflags, flagstr[j], | |
170 strlen(flagstr[j]))) | |
171 break; | |
172 if (flagstr[j] == NULL) | |
173 goto err_out_parse_error; | |
174 flags|=(1<<j); | |
175 sflags+=strlen(flagstr[j]); | |
176 } while (*(sflags++) == ','); | |
177 | |
178 if (*(--sflags) != '\0') | |
179 goto err_out_parse_error; | |
180 } | |
297 | 181 |
182 do { | |
408 | 183 for (j = 0; fmt_table[j].name != NULL; j++) |
184 if (!strncmp(sfmt, fmt_table[j].name, strlen(fmt_table[j].name))) | |
297 | 185 break; |
408 | 186 if (fmt_table[j].name == NULL) |
361 | 187 goto err_out_parse_error; |
408 | 188 outfmt[i] = fmt_table[j].num; |
297 | 189 outflags[i] = flags; |
299 | 190 ++i; |
408 | 191 sfmt+=strlen(fmt_table[j].name); |
319 | 192 } while ((*(sfmt++) == ',') && --freeslots); |
193 | |
194 if (!freeslots) | |
328 | 195 goto err_out_too_many; |
319 | 196 |
361 | 197 if (*(--sfmt) != '\0') |
198 goto err_out_parse_error; | |
299 | 199 |
297 | 200 return 1; |
328 | 201 err_out_too_many: |
5937 | 202 mp_msg(MSGT_CODECCFG,MSGL_ERR,"too many out..."); |
361 | 203 return 0; |
204 err_out_parse_error: | |
5937 | 205 mp_msg(MSGT_CODECCFG,MSGL_ERR,"parse error"); |
319 | 206 return 0; |
297 | 207 } |
208 | |
303 | 209 static short get_driver(char *s,int audioflag) |
297 | 210 { |
301 | 211 static char *audiodrv[] = { |
1293 | 212 "null", |
301 | 213 "mp3lib", |
214 "pcm", | |
215 "libac3", | |
216 "acm", | |
217 "alaw", | |
218 "msgsm", | |
219 "dshow", | |
401 | 220 "dvdpcm", |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1488
diff
changeset
|
221 "hwac3", |
1828 | 222 "libvorbis", |
1929 | 223 "ffmpeg", |
2415 | 224 "libmad", |
3787 | 225 "msadpcm", |
3400 | 226 "liba52", |
227 "g72x", | |
3787 | 228 "imaadpcm", |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4676
diff
changeset
|
229 "dk4adpcm", |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4676
diff
changeset
|
230 "dk3adpcm", |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
4301
diff
changeset
|
231 "roqaudio", |
5190
59df6b778d78
Beta AAC decoding support, seeking totally broken yet, add philipps mpeg4 video in qt to ffmpeg4 although it's still buggy in decoding
atmos4
parents:
5029
diff
changeset
|
232 "faad", |
6343
d253cf4f43a9
realvideo support by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6200
diff
changeset
|
233 "realaud", |
301 | 234 NULL |
235 }; | |
236 static char *videodrv[] = { | |
1293 | 237 "null", |
301 | 238 "libmpeg2", |
239 "vfw", | |
240 "odivx", | |
241 "dshow", | |
1248 | 242 "ffmpeg", |
1297 | 243 "vfwex", |
1349 | 244 "divx4", |
1488 | 245 "raw", |
5193
abea2deab4d6
MPlayer now has a Microsoft RLE decoder to call its own...only supports
melanson
parents:
5190
diff
changeset
|
246 "msrle", |
2379 | 247 "xanim", |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2681
diff
changeset
|
248 "msvidc", |
3172 | 249 "fli", |
3643
fb9fd7e2dd35
native opensourec Cinepak (CVID) codec by im Ferguson <timf@mail.csse.monash.edu.au>
arpi
parents:
3408
diff
changeset
|
250 "cinepak", |
3687
7fb817c9060b
This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
3667
diff
changeset
|
251 "qtrle", |
3804
53ed66a4f0bf
NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
3798
diff
changeset
|
252 "nuv", |
3969 | 253 "cyuv", |
4227 | 254 "qtsmc", |
4301
8f43b10f387f
added skeleton for Duck Truemotion v1 decoder (doesn't do anything yet)
melanson
parents:
4227
diff
changeset
|
255 "ducktm1", |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
4301
diff
changeset
|
256 "roqvideo", |
4615
b1fe5f58cd82
Added native codec support for QT RPZA data, courtesy of Roberto Togni
melanson
parents:
4450
diff
changeset
|
257 "qtrpza", |
4656 | 258 "mpng", |
5029 | 259 "ijpg", |
5235
3e04fd1074d3
added HuffYUV support, courtesy of Roberto Togni <rtogni@bresciaonline.it>
melanson
parents:
5193
diff
changeset
|
260 "huffyuv", |
5263 | 261 "zlib", |
5478 | 262 "mpegpes", |
6343
d253cf4f43a9
realvideo support by Florian Schneider <flo-mplayer-dev@gmx.net>
arpi
parents:
6200
diff
changeset
|
263 "realvid", |
301 | 264 NULL |
265 }; | |
266 char **drv=audioflag?audiodrv:videodrv; | |
267 int i; | |
268 | |
1293 | 269 for(i=0;drv[i];i++) if(!strcmp(s,drv[i])) return i; |
301 | 270 |
1293 | 271 return -1; |
297 | 272 } |
273 | |
328 | 274 static int validate_codec(codecs_t *c, int type) |
319 | 275 { |
5937 | 276 unsigned int i; |
3408 | 277 char *tmp_name = strdup(c->name); |
328 | 278 |
3408 | 279 for (i = 0; i < strlen(tmp_name) && isalnum(tmp_name[i]); i++) |
328 | 280 /* NOTHING */; |
3408 | 281 |
282 if (i < strlen(tmp_name)) { | |
5937 | 283 mp_msg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) name is not valid!\n", c->name); |
328 | 284 return 0; |
285 } | |
3408 | 286 |
328 | 287 if (!c->info) |
3408 | 288 c->info = strdup(c->name); |
289 | |
290 #if 0 | |
328 | 291 if (c->fourcc[0] == 0xffffffff) { |
5937 | 292 mp_msg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) does not have fourcc/format!\n", c->name); |
328 | 293 return 0; |
294 } | |
3408 | 295 |
296 /* XXX fix this: shitty with 'null' codec */ | |
328 | 297 if (!c->driver) { |
5937 | 298 mp_msg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) does not have a driver!\n", c->name); |
328 | 299 return 0; |
300 } | |
3408 | 301 #endif |
302 | |
303 #if 0 | |
328 | 304 #warning codec->driver == 4;... <- ezt nem kellene belehegeszteni... |
305 #warning HOL VANNAK DEFINIALVA???????????? | |
306 if (!c->dll && (c->driver == 4 || | |
307 (c->driver == 2 && type == TYPE_VIDEO))) { | |
5937 | 308 mp_msg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) needs a 'dll'!\n", c->name); |
328 | 309 return 0; |
310 } | |
311 #warning guid.f1 lehet 0? honnan lehet tudni, hogy nem adtak meg? | |
312 // if (!(codec->flags & CODECS_FLAG_AUDIO) && codec->driver == 4) | |
313 | |
314 if (type == TYPE_VIDEO) | |
315 if (c->outfmt[0] == 0xffffffff) { | |
5937 | 316 mp_msg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) needs an 'outfmt'!\n", c->name); |
328 | 317 return 0; |
318 } | |
329 | 319 #endif |
319 | 320 return 1; |
321 } | |
322 | |
323 static int add_comment(char *s, char **d) | |
324 { | |
325 int pos; | |
326 | |
327 if (!*d) | |
328 pos = 0; | |
329 else { | |
330 pos = strlen(*d); | |
331 (*d)[pos++] = '\n'; | |
332 } | |
333 if (!(*d = (char *) realloc(*d, pos + strlen(s) + 1))) { | |
5937 | 334 mp_msg(MSGT_CODECCFG,MSGL_FATAL,"can't allocate mem for comment. "); |
319 | 335 return 0; |
336 } | |
337 strcpy(*d + pos, s); | |
338 return 1; | |
339 } | |
297 | 340 |
361 | 341 static short get_cpuflags(char *s) |
342 { | |
343 static char *flagstr[] = { | |
344 "mmx", | |
345 "sse", | |
346 "3dnow", | |
347 NULL | |
348 }; | |
349 int i; | |
350 short flags = 0; | |
351 | |
352 do { | |
353 for (i = 0; flagstr[i]; i++) | |
354 if (!strncmp(s, flagstr[i], strlen(flagstr[i]))) | |
355 break; | |
356 if (!flagstr[i]) | |
357 goto err_out_parse_error; | |
358 flags |= 1<<i; | |
359 s += strlen(flagstr[i]); | |
360 } while (*(s++) == ','); | |
361 | |
362 if (*(--s) != '\0') | |
363 goto err_out_parse_error; | |
364 | |
365 return flags; | |
366 err_out_parse_error: | |
367 return 0; | |
368 } | |
369 | |
328 | 370 static FILE *fp; |
371 static int line_num = 0; | |
372 static char *line; | |
373 static char *token[MAX_NR_TOKEN]; | |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
374 static int read_nextline = 1; |
328 | 375 |
376 static int get_token(int min, int max) | |
297 | 377 { |
328 | 378 static int line_pos; |
379 int i; | |
380 char c; | |
381 | |
382 if (max >= MAX_NR_TOKEN) { | |
5937 | 383 mp_msg(MSGT_CODECCFG,MSGL_ERR,"get_token(): max >= MAX_NR_TOKEN!"); |
328 | 384 goto out_eof; |
385 } | |
386 | |
387 memset(token, 0x00, sizeof(*token) * max); | |
388 | |
389 if (read_nextline) { | |
390 if (!fgets(line, MAX_LINE_LEN, fp)) | |
391 goto out_eof; | |
392 line_pos = 0; | |
393 ++line_num; | |
394 read_nextline = 0; | |
395 } | |
396 for (i = 0; i < max; i++) { | |
397 while (isspace(line[line_pos])) | |
398 ++line_pos; | |
399 if (line[line_pos] == '\0' || line[line_pos] == '#' || | |
400 line[line_pos] == ';') { | |
401 read_nextline = 1; | |
402 if (i >= min) | |
403 goto out_ok; | |
404 goto out_eol; | |
405 } | |
406 token[i] = line + line_pos; | |
407 c = line[line_pos]; | |
408 if (c == '"' || c == '\'') { | |
409 token[i]++; | |
410 while (line[++line_pos] != c && line[line_pos]) | |
411 /* NOTHING */; | |
412 } else { | |
413 for (/* NOTHING */; !isspace(line[line_pos]) && | |
414 line[line_pos]; line_pos++) | |
415 /* NOTHING */; | |
416 } | |
417 if (!line[line_pos]) { | |
418 read_nextline = 1; | |
419 if (i >= min - 1) | |
420 goto out_ok; | |
421 goto out_eol; | |
422 } | |
423 line[line_pos] = '\0'; | |
424 line_pos++; | |
425 } | |
426 out_ok: | |
427 return i; | |
428 out_eof: | |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
429 read_nextline = 1; |
328 | 430 return RET_EOF; |
431 out_eol: | |
432 return RET_EOL; | |
433 } | |
434 | |
435 static codecs_t *video_codecs=NULL; | |
436 static codecs_t *audio_codecs=NULL; | |
437 static int nr_vcodecs = 0; | |
438 static int nr_acodecs = 0; | |
439 | |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
440 int parse_codec_cfg(char *cfgfile) |
328 | 441 { |
442 codecs_t *codec = NULL; // current codec | |
443 codecs_t **codecsp = NULL;// points to audio_codecs or to video_codecs | |
335 | 444 char *endptr; // strtoul()... |
328 | 445 int *nr_codecsp; |
446 int codec_type; /* TYPE_VIDEO/TYPE_AUDIO */ | |
297 | 447 int tmp, i; |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
448 |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
449 // in case we call it secont time |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
450 if(video_codecs!=NULL)free(video_codecs); |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
451 else video_codecs=NULL; |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
452 |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
453 if(audio_codecs!=NULL)free(audio_codecs); |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
454 else audio_codecs=NULL; |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
455 |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
456 nr_vcodecs = 0; |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
457 nr_acodecs = 0; |
297 | 458 |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
459 if(cfgfile==NULL)return 0; |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
460 |
5937 | 461 mp_msg(MSGT_CODECCFG,MSGL_INFO,"Reading %s: ", cfgfile); |
297 | 462 |
301 | 463 if ((fp = fopen(cfgfile, "r")) == NULL) { |
5937 | 464 mp_msg(MSGT_CODECCFG,MSGL_ERR,"can't open '%s': %s\n", cfgfile, strerror(errno)); |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
465 return 0; |
297 | 466 } |
467 | |
301 | 468 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) { |
5937 | 469 mp_msg(MSGT_CODECCFG,MSGL_FATAL,"can't get memory for 'line': %s\n", strerror(errno)); |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
470 return 0; |
297 | 471 } |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
472 read_nextline = 1; |
297 | 473 |
328 | 474 /* |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
475 * this only catches release lines at the start of |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
476 * codecs.conf, before audiocodecs and videocodecs. |
328 | 477 */ |
478 while ((tmp = get_token(1, 1)) == RET_EOL) | |
479 /* NOTHING */; | |
361 | 480 if (tmp == RET_EOF) |
481 goto out; | |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
482 if (!strcmp(token[0], "release")) { |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
483 if (get_token(1, 2) < 0) |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
484 goto err_out_parse_error; |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
485 tmp = atoi(token[0]); |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
486 if (tmp < CODEC_CFG_MIN) |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
487 goto err_out_release_num; |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
488 while ((tmp = get_token(1, 1)) == RET_EOL) |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
489 /* NOTHING */; |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
490 if (tmp == RET_EOF) |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
491 goto out; |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
492 } else |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
493 goto err_out_release_num; |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
494 |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
495 /* |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
496 * check if the next block starts with 'audiocodec' or |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
497 * with 'videocodec' |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
498 */ |
361 | 499 if (!strcmp(token[0], "audiocodec") || !strcmp(token[0], "videocodec")) |
328 | 500 goto loop_enter; |
361 | 501 goto err_out_parse_error; |
328 | 502 |
319 | 503 while ((tmp = get_token(1, 1)) != RET_EOF) { |
297 | 504 if (tmp == RET_EOL) |
505 continue; | |
328 | 506 if (!strcmp(token[0], "audiocodec") || |
507 !strcmp(token[0], "videocodec")) { | |
508 if (!validate_codec(codec, codec_type)) | |
509 goto err_out_not_valid; | |
510 loop_enter: | |
511 if (*token[0] == 'v') { | |
512 codec_type = TYPE_VIDEO; | |
513 nr_codecsp = &nr_vcodecs; | |
514 codecsp = &video_codecs; | |
515 } else if (*token[0] == 'a') { | |
516 codec_type = TYPE_AUDIO; | |
517 nr_codecsp = &nr_acodecs; | |
518 codecsp = &audio_codecs; | |
361 | 519 #ifdef DEBUG |
328 | 520 } else { |
5937 | 521 mp_msg(MSGT_CODECCFG,MSGL_ERR,"picsba\n"); |
328 | 522 goto err_out; |
361 | 523 #endif |
328 | 524 } |
525 if (!(*codecsp = (codecs_t *) realloc(*codecsp, | |
332 | 526 sizeof(codecs_t) * (*nr_codecsp + 2)))) { |
5937 | 527 mp_msg(MSGT_CODECCFG,MSGL_FATAL,"can't realloc '*codecsp': %s\n", strerror(errno)); |
300 | 528 goto err_out; |
529 } | |
328 | 530 codec=*codecsp + *nr_codecsp; |
531 ++*nr_codecsp; | |
300 | 532 memset(codec,0,sizeof(codecs_t)); |
533 memset(codec->fourcc, 0xff, sizeof(codec->fourcc)); | |
534 memset(codec->outfmt, 0xff, sizeof(codec->outfmt)); | |
4675 | 535 memset(codec->infmt, 0xff, sizeof(codec->infmt)); |
300 | 536 |
319 | 537 if (get_token(1, 1) < 0) |
328 | 538 goto err_out_parse_error; |
539 for (i = 0; i < *nr_codecsp - 1; i++) { | |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
540 if(( (*codecsp)[i].name!=NULL) && |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
541 (!strcmp(token[0], (*codecsp)[i].name)) ) { |
5937 | 542 mp_msg(MSGT_CODECCFG,MSGL_ERR,"codec name '%s' isn't unique", token[0]); |
361 | 543 goto err_out_print_linenum; |
319 | 544 } |
545 } | |
328 | 546 if (!(codec->name = strdup(token[0]))) { |
5937 | 547 mp_msg(MSGT_CODECCFG,MSGL_ERR,"can't strdup -> 'name': %s\n", strerror(errno)); |
328 | 548 goto err_out; |
549 } | |
319 | 550 } else if (!strcmp(token[0], "info")) { |
328 | 551 if (codec->info || get_token(1, 1) < 0) |
552 goto err_out_parse_error; | |
553 if (!(codec->info = strdup(token[0]))) { | |
5937 | 554 mp_msg(MSGT_CODECCFG,MSGL_ERR,"can't strdup -> 'info': %s\n", strerror(errno)); |
328 | 555 goto err_out; |
556 } | |
319 | 557 } else if (!strcmp(token[0], "comment")) { |
558 if (get_token(1, 1) < 0) | |
328 | 559 goto err_out_parse_error; |
361 | 560 add_comment(token[0], &codec->comment); |
319 | 561 } else if (!strcmp(token[0], "fourcc")) { |
562 if (get_token(1, 2) < 0) | |
328 | 563 goto err_out_parse_error; |
319 | 564 if (!add_to_fourcc(token[0], token[1], |
300 | 565 codec->fourcc, |
566 codec->fourccmap)) | |
361 | 567 goto err_out_print_linenum; |
319 | 568 } else if (!strcmp(token[0], "format")) { |
569 if (get_token(1, 1) < 0) | |
328 | 570 goto err_out_parse_error; |
319 | 571 if (!add_to_format(token[0], codec->fourcc,codec->fourccmap)) |
361 | 572 goto err_out_print_linenum; |
319 | 573 } else if (!strcmp(token[0], "driver")) { |
574 if (get_token(1, 1) < 0) | |
328 | 575 goto err_out_parse_error; |
1293 | 576 if ((codec->driver = get_driver(token[0],codec_type))<0) |
361 | 577 goto err_out_parse_error; |
319 | 578 } else if (!strcmp(token[0], "dll")) { |
579 if (get_token(1, 1) < 0) | |
328 | 580 goto err_out_parse_error; |
581 if (!(codec->dll = strdup(token[0]))) { | |
5937 | 582 mp_msg(MSGT_CODECCFG,MSGL_ERR,"can't strdup -> 'dll': %s\n", strerror(errno)); |
328 | 583 goto err_out; |
584 } | |
319 | 585 } else if (!strcmp(token[0], "guid")) { |
328 | 586 if (get_token(11, 11) < 0) |
587 goto err_out_parse_error; | |
335 | 588 codec->guid.f1=strtoul(token[0],&endptr,0); |
361 | 589 if ((*endptr != ',' || *(endptr + 1) != '\0') && |
590 *endptr != '\0') | |
335 | 591 goto err_out_parse_error; |
592 codec->guid.f2=strtoul(token[1],&endptr,0); | |
361 | 593 if ((*endptr != ',' || *(endptr + 1) != '\0') && |
594 *endptr != '\0') | |
335 | 595 goto err_out_parse_error; |
596 codec->guid.f3=strtoul(token[2],&endptr,0); | |
361 | 597 if ((*endptr != ',' || *(endptr + 1) != '\0') && |
598 *endptr != '\0') | |
335 | 599 goto err_out_parse_error; |
600 for (i = 0; i < 8; i++) { | |
601 codec->guid.f4[i]=strtoul(token[i + 3],&endptr,0); | |
361 | 602 if ((*endptr != ',' || *(endptr + 1) != '\0') && |
603 *endptr != '\0') | |
328 | 604 goto err_out_parse_error; |
297 | 605 } |
319 | 606 } else if (!strcmp(token[0], "out")) { |
607 if (get_token(1, 2) < 0) | |
328 | 608 goto err_out_parse_error; |
4675 | 609 if (!add_to_inout(token[0], token[1], codec->outfmt, |
300 | 610 codec->outflags)) |
361 | 611 goto err_out_print_linenum; |
4675 | 612 } else if (!strcmp(token[0], "in")) { |
613 if (get_token(1, 2) < 0) | |
614 goto err_out_parse_error; | |
615 if (!add_to_inout(token[0], token[1], codec->infmt, | |
616 codec->inflags)) | |
617 goto err_out_print_linenum; | |
319 | 618 } else if (!strcmp(token[0], "flags")) { |
619 if (get_token(1, 1) < 0) | |
328 | 620 goto err_out_parse_error; |
321 | 621 if (!strcmp(token[0], "seekable")) |
622 codec->flags |= CODECS_FLAG_SEEKABLE; | |
623 else | |
328 | 624 goto err_out_parse_error; |
319 | 625 } else if (!strcmp(token[0], "status")) { |
626 if (get_token(1, 1) < 0) | |
328 | 627 goto err_out_parse_error; |
332 | 628 if (!strcasecmp(token[0], "working")) |
316 | 629 codec->status = CODECS_STATUS_WORKING; |
332 | 630 else if (!strcasecmp(token[0], "crashing")) |
316 | 631 codec->status = CODECS_STATUS_NOT_WORKING; |
332 | 632 else if (!strcasecmp(token[0], "untested")) |
316 | 633 codec->status = CODECS_STATUS_UNTESTED; |
332 | 634 else if (!strcasecmp(token[0], "buggy")) |
316 | 635 codec->status = CODECS_STATUS_PROBLEMS; |
636 else | |
328 | 637 goto err_out_parse_error; |
361 | 638 } else if (!strcmp(token[0], "cpuflags")) { |
639 if (get_token(1, 1) < 0) | |
640 goto err_out_parse_error; | |
641 if (!(codec->cpuflags = get_cpuflags(token[0]))) | |
642 goto err_out_parse_error; | |
3667
ec943f8ec439
add support for priotity <int> in codecs.conf, higher numbers are better
atmos4
parents:
3643
diff
changeset
|
643 } else if (!strcasecmp(token[0], "priority")) { |
ec943f8ec439
add support for priotity <int> in codecs.conf, higher numbers are better
atmos4
parents:
3643
diff
changeset
|
644 if (get_token(1, 1) < 0) |
ec943f8ec439
add support for priotity <int> in codecs.conf, higher numbers are better
atmos4
parents:
3643
diff
changeset
|
645 goto err_out_parse_error; |
ec943f8ec439
add support for priotity <int> in codecs.conf, higher numbers are better
atmos4
parents:
3643
diff
changeset
|
646 //printf("\n\n!!!cfg-parse: priority %s (%d) found!!!\n\n", token[0], atoi(token[0])); // ::atmos |
ec943f8ec439
add support for priotity <int> in codecs.conf, higher numbers are better
atmos4
parents:
3643
diff
changeset
|
647 codec->priority = atoi(token[0]); |
297 | 648 } else |
328 | 649 goto err_out_parse_error; |
297 | 650 } |
328 | 651 if (!validate_codec(codec, codec_type)) |
652 goto err_out_not_valid; | |
5937 | 653 mp_msg(MSGT_CODECCFG,MSGL_INFO,"%d audio & %d video codecs\n", nr_acodecs, nr_vcodecs); |
895 | 654 if(video_codecs) video_codecs[nr_vcodecs].name = NULL; |
655 if(audio_codecs) audio_codecs[nr_acodecs].name = NULL; | |
297 | 656 out: |
657 free(line); | |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
658 line=NULL; |
297 | 659 fclose(fp); |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
660 return 1; |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
661 |
328 | 662 err_out_parse_error: |
5937 | 663 mp_msg(MSGT_CODECCFG,MSGL_ERR,"parse error"); |
361 | 664 err_out_print_linenum: |
297 | 665 PRINT_LINENUM; |
666 err_out: | |
328 | 667 if (audio_codecs) |
668 free(audio_codecs); | |
669 if (video_codecs) | |
670 free(video_codecs); | |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
671 video_codecs=NULL; |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
672 audio_codecs=NULL; |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
673 |
328 | 674 free(line); |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
675 line=NULL; |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
676 line_num = 0; |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
677 fclose(fp); |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
678 return 0; |
328 | 679 err_out_not_valid: |
5937 | 680 mp_msg(MSGT_CODECCFG,MSGL_ERR,"codec is not defined correctly"); |
361 | 681 goto err_out_print_linenum; |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
682 err_out_release_num: |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
683 mp_msg(MSGT_CODECCFG,MSGL_ERR,"this codecs.conf is too old, incompatible with this mplayer release!"); |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
684 goto err_out_print_linenum; |
297 | 685 } |
686 | |
332 | 687 codecs_t *find_audio_codec(unsigned int fourcc, unsigned int *fourccmap, |
688 codecs_t *start) | |
328 | 689 { |
332 | 690 return find_codec(fourcc, fourccmap, start, 1); |
328 | 691 } |
692 | |
332 | 693 codecs_t *find_video_codec(unsigned int fourcc, unsigned int *fourccmap, |
694 codecs_t *start) | |
328 | 695 { |
332 | 696 return find_codec(fourcc, fourccmap, start, 0); |
328 | 697 } |
698 | |
332 | 699 codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap, |
700 codecs_t *start, int audioflag) | |
328 | 701 { |
702 int i, j; | |
703 codecs_t *c; | |
704 | |
628 | 705 #if 0 |
332 | 706 if (start) { |
707 for (/* NOTHING */; start->name; start++) { | |
708 for (j = 0; j < CODECS_MAX_FOURCC; j++) { | |
709 if (start->fourcc[j] == fourcc) { | |
710 if (fourccmap) | |
711 *fourccmap = start->fourccmap[j]; | |
712 return start; | |
713 } | |
714 } | |
715 } | |
628 | 716 } else |
717 #endif | |
718 { | |
332 | 719 if (audioflag) { |
720 i = nr_acodecs; | |
721 c = audio_codecs; | |
722 } else { | |
723 i = nr_vcodecs; | |
724 c = video_codecs; | |
725 } | |
895 | 726 if(!i) return NULL; |
332 | 727 for (/* NOTHING */; i--; c++) { |
628 | 728 if(start && c<=start) continue; |
332 | 729 for (j = 0; j < CODECS_MAX_FOURCC; j++) { |
1391 | 730 if (c->fourcc[j]==fourcc || c->driver==0) { |
332 | 731 if (fourccmap) |
732 *fourccmap = c->fourccmap[j]; | |
733 return c; | |
734 } | |
328 | 735 } |
736 } | |
737 } | |
738 return NULL; | |
303 | 739 } |
740 | |
5325
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
741 void codecs_reset_selection(int audioflag){ |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
742 int i; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
743 codecs_t *c; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
744 if (audioflag) { |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
745 i = nr_acodecs; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
746 c = audio_codecs; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
747 } else { |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
748 i = nr_vcodecs; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
749 c = video_codecs; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
750 } |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
751 if(i) |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
752 for (/* NOTHING */; i--; c++) |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
753 c->flags&=(~CODECS_FLAG_SELECTED); |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
754 } |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
755 |
1983 | 756 void list_codecs(int audioflag){ |
2050 | 757 int i; |
1983 | 758 codecs_t *c; |
759 | |
760 if (audioflag) { | |
761 i = nr_acodecs; | |
762 c = audio_codecs; | |
5937 | 763 mp_msg(MSGT_CODECCFG,MSGL_INFO,"ac: afm: status: info: [lib/dll]\n"); |
1983 | 764 } else { |
765 i = nr_vcodecs; | |
766 c = video_codecs; | |
5937 | 767 mp_msg(MSGT_CODECCFG,MSGL_INFO,"vc: vfm: status: info: [lib/dll]\n"); |
1983 | 768 } |
2050 | 769 if(!i) return; |
1983 | 770 for (/* NOTHING */; i--; c++) { |
1984 | 771 char* s="unknown "; |
772 switch(c->status){ | |
773 case CODECS_STATUS_WORKING: s="working ";break; | |
774 case CODECS_STATUS_PROBLEMS: s="problems";break; | |
775 case CODECS_STATUS_NOT_WORKING: s="crashing";break; | |
776 case CODECS_STATUS_UNTESTED: s="untested";break; | |
777 } | |
1983 | 778 if(c->dll) |
5937 | 779 mp_msg(MSGT_CODECCFG,MSGL_INFO,"%-11s%2d %s %s [%s]\n",c->name,c->driver,s,c->info,c->dll); |
1983 | 780 else |
5937 | 781 mp_msg(MSGT_CODECCFG,MSGL_INFO,"%-11s%2d %s %s\n",c->name,c->driver,s,c->info); |
1983 | 782 |
783 } | |
784 | |
785 } | |
786 | |
787 | |
788 | |
607 | 789 #ifdef CODECS2HTML |
790 | |
791 void wrapline(FILE *f2,char *s){ | |
792 int c; | |
793 if(!s){ | |
794 fprintf(f2,"-"); | |
795 return; | |
796 } | |
797 while((c=*s++)){ | |
798 if(c==',') fprintf(f2,"<br>"); else fputc(c,f2); | |
799 } | |
800 } | |
801 | |
802 void parsehtml(FILE *f1,FILE *f2,codecs_t *codec,int section,int dshow){ | |
803 int c,d; | |
804 while((c=fgetc(f1))>=0){ | |
805 if(c!='%'){ | |
806 fputc(c,f2); | |
807 continue; | |
808 } | |
809 d=fgetc(f1); | |
810 | |
811 switch(d){ | |
812 case '.': | |
613 | 813 return; // end of section |
607 | 814 case 'n': |
815 wrapline(f2,codec->name); break; | |
816 case 'i': | |
817 wrapline(f2,codec->info); break; | |
818 case 'c': | |
819 wrapline(f2,codec->comment); break; | |
820 case 'd': | |
821 wrapline(f2,codec->dll); break; | |
822 case 'D': | |
823 fprintf(f2,"%c",codec->driver==dshow?'+':'-'); break; | |
824 case 'F': | |
825 for(d=0;d<CODECS_MAX_FOURCC;d++) | |
1944
4d8123ae7b4b
Fixed vfwex section, null codec and other fourcc issues and improved codecs-in.html usability.
atmos4
parents:
1929
diff
changeset
|
826 if(!d || codec->fourcc[d]!=0xFFFFFFFF) |
4d8123ae7b4b
Fixed vfwex section, null codec and other fourcc issues and improved codecs-in.html usability.
atmos4
parents:
1929
diff
changeset
|
827 fprintf(f2,"%s%.4s",d?"<br>":"",(codec->fourcc[d]==0xFFFFFFFF || codec->fourcc[d]<0x20202020)?!d?"-":"":(char*) &codec->fourcc[d]); |
607 | 828 break; |
829 case 'f': | |
830 for(d=0;d<CODECS_MAX_FOURCC;d++) | |
831 if(codec->fourcc[d]!=0xFFFFFFFF) | |
832 fprintf(f2,"%s0x%X",d?"<br>":"",codec->fourcc[d]); | |
833 break; | |
834 case 'Y': | |
835 for(d=0;d<CODECS_MAX_OUTFMT;d++) | |
836 if(codec->outfmt[d]!=0xFFFFFFFF){ | |
837 for (c=0; fmt_table[c].name; c++) | |
838 if(fmt_table[c].num==codec->outfmt[d]) break; | |
839 if(fmt_table[c].name) | |
840 fprintf(f2,"%s%s",d?"<br>":"",fmt_table[c].name); | |
841 } | |
842 break; | |
843 default: | |
844 fputc(c,f2); | |
845 fputc(d,f2); | |
846 } | |
847 } | |
848 | |
849 } | |
850 | |
851 void skiphtml(FILE *f1){ | |
852 int c,d; | |
853 while((c=fgetc(f1))>=0){ | |
854 if(c!='%'){ | |
855 continue; | |
856 } | |
857 d=fgetc(f1); | |
858 if(d=='.') return; // end of section | |
859 } | |
860 } | |
861 | |
862 int main(void) | |
863 { | |
4027 | 864 codecs_t *cl; |
607 | 865 FILE *f1; |
866 FILE *f2; | |
867 int c,d,i; | |
868 int pos; | |
869 int section=-1; | |
870 int nr_codecs; | |
871 int win32=-1; | |
872 int dshow=-1; | |
1944
4d8123ae7b4b
Fixed vfwex section, null codec and other fourcc issues and improved codecs-in.html usability.
atmos4
parents:
1929
diff
changeset
|
873 int win32ex=-1; |
607 | 874 |
4027 | 875 if (!(nr_codecs = parse_codec_cfg("etc/codecs.conf"))) |
607 | 876 return 0; |
877 | |
878 f1=fopen("DOCS/codecs-in.html","rb"); if(!f1) exit(1); | |
1689 | 879 f2=fopen("DOCS/codecs-status.html","wb"); if(!f2) exit(1); |
607 | 880 |
881 while((c=fgetc(f1))>=0){ | |
882 if(c!='%'){ | |
883 fputc(c,f2); | |
884 continue; | |
885 } | |
886 d=fgetc(f1); | |
887 if(d>='0' && d<='9'){ | |
888 // begin section | |
889 section=d-'0'; | |
890 printf("BEGIN %d\n",section); | |
891 if(section>=5){ | |
892 // audio | |
4027 | 893 cl = audio_codecs; |
607 | 894 nr_codecs = nr_acodecs; |
895 dshow=7;win32=4; | |
896 } else { | |
897 // video | |
4027 | 898 cl = video_codecs; |
607 | 899 nr_codecs = nr_vcodecs; |
1944
4d8123ae7b4b
Fixed vfwex section, null codec and other fourcc issues and improved codecs-in.html usability.
atmos4
parents:
1929
diff
changeset
|
900 dshow=4;win32=2;win32ex=6; |
607 | 901 } |
902 pos=ftell(f1); | |
903 for(i=0;i<nr_codecs;i++){ | |
904 fseek(f1,pos,SEEK_SET); | |
905 switch(section){ | |
906 case 0: | |
907 case 5: | |
908 if(cl[i].status==CODECS_STATUS_WORKING) | |
1944
4d8123ae7b4b
Fixed vfwex section, null codec and other fourcc issues and improved codecs-in.html usability.
atmos4
parents:
1929
diff
changeset
|
909 if(!(cl[i].driver==win32 || cl[i].driver==dshow || cl[i].driver==win32ex)) |
607 | 910 parsehtml(f1,f2,&cl[i],section,dshow); |
911 break; | |
912 case 1: | |
913 case 6: | |
914 if(cl[i].status==CODECS_STATUS_WORKING) | |
1944
4d8123ae7b4b
Fixed vfwex section, null codec and other fourcc issues and improved codecs-in.html usability.
atmos4
parents:
1929
diff
changeset
|
915 if(cl[i].driver==win32 || cl[i].driver==dshow || cl[i].driver==win32ex) |
607 | 916 parsehtml(f1,f2,&cl[i],section,dshow); |
917 break; | |
918 case 2: | |
919 case 7: | |
920 if(cl[i].status==CODECS_STATUS_PROBLEMS) | |
921 parsehtml(f1,f2,&cl[i],section,dshow); | |
922 break; | |
923 case 3: | |
924 case 8: | |
925 if(cl[i].status==CODECS_STATUS_NOT_WORKING) | |
926 parsehtml(f1,f2,&cl[i],section,dshow); | |
927 break; | |
928 case 4: | |
929 case 9: | |
930 if(cl[i].status==CODECS_STATUS_UNTESTED) | |
931 parsehtml(f1,f2,&cl[i],section,dshow); | |
932 break; | |
933 default: | |
934 printf("Warning! unimplemented section: %d\n",section); | |
935 } | |
936 } | |
937 fseek(f1,pos,SEEK_SET); | |
938 skiphtml(f1); | |
939 //void parsehtml(FILE *f1,FILE *f2,codecs_t *codec,int section,int dshow){ | |
940 | |
941 continue; | |
942 } | |
943 fputc(c,f2); | |
944 fputc(d,f2); | |
945 } | |
946 | |
947 fclose(f2); | |
948 fclose(f1); | |
949 return 0; | |
950 } | |
951 | |
952 #endif | |
953 | |
297 | 954 #ifdef TESTING |
955 int main(void) | |
956 { | |
4676 | 957 codecs_t *c; |
328 | 958 int i,j, nr_codecs, state; |
297 | 959 |
4676 | 960 if (!(parse_codec_cfg("etc/codecs.conf"))) |
319 | 961 return 0; |
4676 | 962 if (!video_codecs) |
328 | 963 printf("no videoconfig.\n"); |
4676 | 964 if (!audio_codecs) |
328 | 965 printf("no audioconfig.\n"); |
966 | |
967 printf("videocodecs:\n"); | |
4676 | 968 c = video_codecs; |
328 | 969 nr_codecs = nr_vcodecs; |
970 state = 0; | |
971 next: | |
972 if (c) { | |
4676 | 973 printf("number of %scodecs: %d\n", state==0?"video":"audio", |
974 nr_codecs); | |
328 | 975 for(i=0;i<nr_codecs;i++, c++){ |
4676 | 976 printf("\n============== %scodec %02d ===============\n", |
977 state==0?"video":"audio",i); | |
328 | 978 printf("name='%s'\n",c->name); |
979 printf("info='%s'\n",c->info); | |
980 printf("comment='%s'\n",c->comment); | |
981 printf("dll='%s'\n",c->dll); | |
361 | 982 printf("flags=%X driver=%d status=%d cpuflags=%d\n", |
983 c->flags, c->driver, c->status, c->cpuflags); | |
300 | 984 |
328 | 985 for(j=0;j<CODECS_MAX_FOURCC;j++){ |
986 if(c->fourcc[j]!=0xFFFFFFFF){ | |
361 | 987 printf("fourcc %02d: %08X (%.4s) ===> %08X (%.4s)\n",j,c->fourcc[j],(char *) &c->fourcc[j],c->fourccmap[j],(char *) &c->fourccmap[j]); |
328 | 988 } |
989 } | |
990 | |
991 for(j=0;j<CODECS_MAX_OUTFMT;j++){ | |
992 if(c->outfmt[j]!=0xFFFFFFFF){ | |
361 | 993 printf("outfmt %02d: %08X (%.4s) flags: %d\n",j,c->outfmt[j],(char *) &c->outfmt[j],c->outflags[j]); |
328 | 994 } |
995 } | |
300 | 996 |
4676 | 997 for(j=0;j<CODECS_MAX_INFMT;j++){ |
998 if(c->infmt[j]!=0xFFFFFFFF){ | |
999 printf("infmt %02d: %08X (%.4s) flags: %d\n",j,c->infmt[j],(char *) &c->infmt[j],c->inflags[j]); | |
1000 } | |
1001 } | |
1002 | |
328 | 1003 printf("GUID: %08lX %04X %04X",c->guid.f1,c->guid.f2,c->guid.f3); |
1004 for(j=0;j<8;j++) printf(" %02X",c->guid.f4[j]); | |
1005 printf("\n"); | |
300 | 1006 |
328 | 1007 |
1008 } | |
1009 } | |
1010 if (!state) { | |
1011 printf("audiocodecs:\n"); | |
4676 | 1012 c = audio_codecs; |
328 | 1013 nr_codecs = nr_acodecs; |
1014 state = 1; | |
1015 goto next; | |
1016 } | |
297 | 1017 return 0; |
1018 } | |
1019 | |
1020 #endif |