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