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