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