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