Mercurial > mplayer.hg
annotate codec-cfg.c @ 6276:e7916b6f455a
i cannot sleep ;-)
author | jaf |
---|---|
date | Sun, 02 Jun 2002 22:21:21 +0000 |
parents | e604be87613d |
children | d253cf4f43a9 |
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]; | |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
371 static int read_nextline = 1; |
328 | 372 |
373 static int get_token(int min, int max) | |
297 | 374 { |
328 | 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 } |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
469 read_nextline = 1; |
297 | 470 |
328 | 471 /* |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
472 * 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
|
473 * codecs.conf, before audiocodecs and videocodecs. |
328 | 474 */ |
475 while ((tmp = get_token(1, 1)) == RET_EOL) | |
476 /* NOTHING */; | |
361 | 477 if (tmp == RET_EOF) |
478 goto out; | |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
479 if (!strcmp(token[0], "release")) { |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
480 if (get_token(1, 2) < 0) |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
481 goto err_out_parse_error; |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
482 tmp = atoi(token[0]); |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
483 if (tmp < CODEC_CFG_MIN) |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
484 goto err_out_release_num; |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
485 while ((tmp = get_token(1, 1)) == RET_EOL) |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
486 /* NOTHING */; |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
487 if (tmp == RET_EOF) |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
488 goto out; |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
489 } else |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
490 goto err_out_release_num; |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
491 |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
492 /* |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
493 * 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
|
494 * with 'videocodec' |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
495 */ |
361 | 496 if (!strcmp(token[0], "audiocodec") || !strcmp(token[0], "videocodec")) |
328 | 497 goto loop_enter; |
361 | 498 goto err_out_parse_error; |
328 | 499 |
319 | 500 while ((tmp = get_token(1, 1)) != RET_EOF) { |
297 | 501 if (tmp == RET_EOL) |
502 continue; | |
328 | 503 if (!strcmp(token[0], "audiocodec") || |
504 !strcmp(token[0], "videocodec")) { | |
505 if (!validate_codec(codec, codec_type)) | |
506 goto err_out_not_valid; | |
507 loop_enter: | |
508 if (*token[0] == 'v') { | |
509 codec_type = TYPE_VIDEO; | |
510 nr_codecsp = &nr_vcodecs; | |
511 codecsp = &video_codecs; | |
512 } else if (*token[0] == 'a') { | |
513 codec_type = TYPE_AUDIO; | |
514 nr_codecsp = &nr_acodecs; | |
515 codecsp = &audio_codecs; | |
361 | 516 #ifdef DEBUG |
328 | 517 } else { |
5937 | 518 mp_msg(MSGT_CODECCFG,MSGL_ERR,"picsba\n"); |
328 | 519 goto err_out; |
361 | 520 #endif |
328 | 521 } |
522 if (!(*codecsp = (codecs_t *) realloc(*codecsp, | |
332 | 523 sizeof(codecs_t) * (*nr_codecsp + 2)))) { |
5937 | 524 mp_msg(MSGT_CODECCFG,MSGL_FATAL,"can't realloc '*codecsp': %s\n", strerror(errno)); |
300 | 525 goto err_out; |
526 } | |
328 | 527 codec=*codecsp + *nr_codecsp; |
528 ++*nr_codecsp; | |
300 | 529 memset(codec,0,sizeof(codecs_t)); |
530 memset(codec->fourcc, 0xff, sizeof(codec->fourcc)); | |
531 memset(codec->outfmt, 0xff, sizeof(codec->outfmt)); | |
4675 | 532 memset(codec->infmt, 0xff, sizeof(codec->infmt)); |
300 | 533 |
319 | 534 if (get_token(1, 1) < 0) |
328 | 535 goto err_out_parse_error; |
536 for (i = 0; i < *nr_codecsp - 1; i++) { | |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
537 if(( (*codecsp)[i].name!=NULL) && |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
538 (!strcmp(token[0], (*codecsp)[i].name)) ) { |
5937 | 539 mp_msg(MSGT_CODECCFG,MSGL_ERR,"codec name '%s' isn't unique", token[0]); |
361 | 540 goto err_out_print_linenum; |
319 | 541 } |
542 } | |
328 | 543 if (!(codec->name = strdup(token[0]))) { |
5937 | 544 mp_msg(MSGT_CODECCFG,MSGL_ERR,"can't strdup -> 'name': %s\n", strerror(errno)); |
328 | 545 goto err_out; |
546 } | |
319 | 547 } else if (!strcmp(token[0], "info")) { |
328 | 548 if (codec->info || get_token(1, 1) < 0) |
549 goto err_out_parse_error; | |
550 if (!(codec->info = strdup(token[0]))) { | |
5937 | 551 mp_msg(MSGT_CODECCFG,MSGL_ERR,"can't strdup -> 'info': %s\n", strerror(errno)); |
328 | 552 goto err_out; |
553 } | |
319 | 554 } else if (!strcmp(token[0], "comment")) { |
555 if (get_token(1, 1) < 0) | |
328 | 556 goto err_out_parse_error; |
361 | 557 add_comment(token[0], &codec->comment); |
319 | 558 } else if (!strcmp(token[0], "fourcc")) { |
559 if (get_token(1, 2) < 0) | |
328 | 560 goto err_out_parse_error; |
319 | 561 if (!add_to_fourcc(token[0], token[1], |
300 | 562 codec->fourcc, |
563 codec->fourccmap)) | |
361 | 564 goto err_out_print_linenum; |
319 | 565 } else if (!strcmp(token[0], "format")) { |
566 if (get_token(1, 1) < 0) | |
328 | 567 goto err_out_parse_error; |
319 | 568 if (!add_to_format(token[0], codec->fourcc,codec->fourccmap)) |
361 | 569 goto err_out_print_linenum; |
319 | 570 } else if (!strcmp(token[0], "driver")) { |
571 if (get_token(1, 1) < 0) | |
328 | 572 goto err_out_parse_error; |
1293 | 573 if ((codec->driver = get_driver(token[0],codec_type))<0) |
361 | 574 goto err_out_parse_error; |
319 | 575 } else if (!strcmp(token[0], "dll")) { |
576 if (get_token(1, 1) < 0) | |
328 | 577 goto err_out_parse_error; |
578 if (!(codec->dll = strdup(token[0]))) { | |
5937 | 579 mp_msg(MSGT_CODECCFG,MSGL_ERR,"can't strdup -> 'dll': %s\n", strerror(errno)); |
328 | 580 goto err_out; |
581 } | |
319 | 582 } else if (!strcmp(token[0], "guid")) { |
328 | 583 if (get_token(11, 11) < 0) |
584 goto err_out_parse_error; | |
335 | 585 codec->guid.f1=strtoul(token[0],&endptr,0); |
361 | 586 if ((*endptr != ',' || *(endptr + 1) != '\0') && |
587 *endptr != '\0') | |
335 | 588 goto err_out_parse_error; |
589 codec->guid.f2=strtoul(token[1],&endptr,0); | |
361 | 590 if ((*endptr != ',' || *(endptr + 1) != '\0') && |
591 *endptr != '\0') | |
335 | 592 goto err_out_parse_error; |
593 codec->guid.f3=strtoul(token[2],&endptr,0); | |
361 | 594 if ((*endptr != ',' || *(endptr + 1) != '\0') && |
595 *endptr != '\0') | |
335 | 596 goto err_out_parse_error; |
597 for (i = 0; i < 8; i++) { | |
598 codec->guid.f4[i]=strtoul(token[i + 3],&endptr,0); | |
361 | 599 if ((*endptr != ',' || *(endptr + 1) != '\0') && |
600 *endptr != '\0') | |
328 | 601 goto err_out_parse_error; |
297 | 602 } |
319 | 603 } else if (!strcmp(token[0], "out")) { |
604 if (get_token(1, 2) < 0) | |
328 | 605 goto err_out_parse_error; |
4675 | 606 if (!add_to_inout(token[0], token[1], codec->outfmt, |
300 | 607 codec->outflags)) |
361 | 608 goto err_out_print_linenum; |
4675 | 609 } else if (!strcmp(token[0], "in")) { |
610 if (get_token(1, 2) < 0) | |
611 goto err_out_parse_error; | |
612 if (!add_to_inout(token[0], token[1], codec->infmt, | |
613 codec->inflags)) | |
614 goto err_out_print_linenum; | |
319 | 615 } else if (!strcmp(token[0], "flags")) { |
616 if (get_token(1, 1) < 0) | |
328 | 617 goto err_out_parse_error; |
321 | 618 if (!strcmp(token[0], "seekable")) |
619 codec->flags |= CODECS_FLAG_SEEKABLE; | |
620 else | |
328 | 621 goto err_out_parse_error; |
319 | 622 } else if (!strcmp(token[0], "status")) { |
623 if (get_token(1, 1) < 0) | |
328 | 624 goto err_out_parse_error; |
332 | 625 if (!strcasecmp(token[0], "working")) |
316 | 626 codec->status = CODECS_STATUS_WORKING; |
332 | 627 else if (!strcasecmp(token[0], "crashing")) |
316 | 628 codec->status = CODECS_STATUS_NOT_WORKING; |
332 | 629 else if (!strcasecmp(token[0], "untested")) |
316 | 630 codec->status = CODECS_STATUS_UNTESTED; |
332 | 631 else if (!strcasecmp(token[0], "buggy")) |
316 | 632 codec->status = CODECS_STATUS_PROBLEMS; |
633 else | |
328 | 634 goto err_out_parse_error; |
361 | 635 } else if (!strcmp(token[0], "cpuflags")) { |
636 if (get_token(1, 1) < 0) | |
637 goto err_out_parse_error; | |
638 if (!(codec->cpuflags = get_cpuflags(token[0]))) | |
639 goto err_out_parse_error; | |
3667
ec943f8ec439
add support for priotity <int> in codecs.conf, higher numbers are better
atmos4
parents:
3643
diff
changeset
|
640 } else if (!strcasecmp(token[0], "priority")) { |
ec943f8ec439
add support for priotity <int> in codecs.conf, higher numbers are better
atmos4
parents:
3643
diff
changeset
|
641 if (get_token(1, 1) < 0) |
ec943f8ec439
add support for priotity <int> in codecs.conf, higher numbers are better
atmos4
parents:
3643
diff
changeset
|
642 goto err_out_parse_error; |
ec943f8ec439
add support for priotity <int> in codecs.conf, higher numbers are better
atmos4
parents:
3643
diff
changeset
|
643 //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
|
644 codec->priority = atoi(token[0]); |
297 | 645 } else |
328 | 646 goto err_out_parse_error; |
297 | 647 } |
328 | 648 if (!validate_codec(codec, codec_type)) |
649 goto err_out_not_valid; | |
5937 | 650 mp_msg(MSGT_CODECCFG,MSGL_INFO,"%d audio & %d video codecs\n", nr_acodecs, nr_vcodecs); |
895 | 651 if(video_codecs) video_codecs[nr_vcodecs].name = NULL; |
652 if(audio_codecs) audio_codecs[nr_acodecs].name = NULL; | |
297 | 653 out: |
654 free(line); | |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
655 line=NULL; |
297 | 656 fclose(fp); |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
657 return 1; |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
658 |
328 | 659 err_out_parse_error: |
5937 | 660 mp_msg(MSGT_CODECCFG,MSGL_ERR,"parse error"); |
361 | 661 err_out_print_linenum: |
297 | 662 PRINT_LINENUM; |
663 err_out: | |
328 | 664 if (audio_codecs) |
665 free(audio_codecs); | |
666 if (video_codecs) | |
667 free(video_codecs); | |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
668 video_codecs=NULL; |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
669 audio_codecs=NULL; |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
670 |
328 | 671 free(line); |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
672 line=NULL; |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
673 line_num = 0; |
3798
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
674 fclose(fp); |
d1e3ad5bcd8f
fixed few segfaults, make parse_codec_cfg() return int
iive
parents:
3787
diff
changeset
|
675 return 0; |
328 | 676 err_out_not_valid: |
5937 | 677 mp_msg(MSGT_CODECCFG,MSGL_ERR,"codec is not defined correctly"); |
361 | 678 goto err_out_print_linenum; |
6200
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
679 err_out_release_num: |
e604be87613d
codecs.conf versioning - patch by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6103
diff
changeset
|
680 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
|
681 goto err_out_print_linenum; |
297 | 682 } |
683 | |
332 | 684 codecs_t *find_audio_codec(unsigned int fourcc, unsigned int *fourccmap, |
685 codecs_t *start) | |
328 | 686 { |
332 | 687 return find_codec(fourcc, fourccmap, start, 1); |
328 | 688 } |
689 | |
332 | 690 codecs_t *find_video_codec(unsigned int fourcc, unsigned int *fourccmap, |
691 codecs_t *start) | |
328 | 692 { |
332 | 693 return find_codec(fourcc, fourccmap, start, 0); |
328 | 694 } |
695 | |
332 | 696 codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap, |
697 codecs_t *start, int audioflag) | |
328 | 698 { |
699 int i, j; | |
700 codecs_t *c; | |
701 | |
628 | 702 #if 0 |
332 | 703 if (start) { |
704 for (/* NOTHING */; start->name; start++) { | |
705 for (j = 0; j < CODECS_MAX_FOURCC; j++) { | |
706 if (start->fourcc[j] == fourcc) { | |
707 if (fourccmap) | |
708 *fourccmap = start->fourccmap[j]; | |
709 return start; | |
710 } | |
711 } | |
712 } | |
628 | 713 } else |
714 #endif | |
715 { | |
332 | 716 if (audioflag) { |
717 i = nr_acodecs; | |
718 c = audio_codecs; | |
719 } else { | |
720 i = nr_vcodecs; | |
721 c = video_codecs; | |
722 } | |
895 | 723 if(!i) return NULL; |
332 | 724 for (/* NOTHING */; i--; c++) { |
628 | 725 if(start && c<=start) continue; |
332 | 726 for (j = 0; j < CODECS_MAX_FOURCC; j++) { |
1391 | 727 if (c->fourcc[j]==fourcc || c->driver==0) { |
332 | 728 if (fourccmap) |
729 *fourccmap = c->fourccmap[j]; | |
730 return c; | |
731 } | |
328 | 732 } |
733 } | |
734 } | |
735 return NULL; | |
303 | 736 } |
737 | |
5325
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
738 void codecs_reset_selection(int audioflag){ |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
739 int i; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
740 codecs_t *c; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
741 if (audioflag) { |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
742 i = nr_acodecs; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
743 c = audio_codecs; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
744 } else { |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
745 i = nr_vcodecs; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
746 c = video_codecs; |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
747 } |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
748 if(i) |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
749 for (/* NOTHING */; i--; c++) |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
750 c->flags&=(~CODECS_FLAG_SELECTED); |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
751 } |
9c326f199060
tagging selected codec to avoid trying the same codec several times
arpi
parents:
5284
diff
changeset
|
752 |
1983 | 753 void list_codecs(int audioflag){ |
2050 | 754 int i; |
1983 | 755 codecs_t *c; |
756 | |
757 if (audioflag) { | |
758 i = nr_acodecs; | |
759 c = audio_codecs; | |
5937 | 760 mp_msg(MSGT_CODECCFG,MSGL_INFO,"ac: afm: status: info: [lib/dll]\n"); |
1983 | 761 } else { |
762 i = nr_vcodecs; | |
763 c = video_codecs; | |
5937 | 764 mp_msg(MSGT_CODECCFG,MSGL_INFO,"vc: vfm: status: info: [lib/dll]\n"); |
1983 | 765 } |
2050 | 766 if(!i) return; |
1983 | 767 for (/* NOTHING */; i--; c++) { |
1984 | 768 char* s="unknown "; |
769 switch(c->status){ | |
770 case CODECS_STATUS_WORKING: s="working ";break; | |
771 case CODECS_STATUS_PROBLEMS: s="problems";break; | |
772 case CODECS_STATUS_NOT_WORKING: s="crashing";break; | |
773 case CODECS_STATUS_UNTESTED: s="untested";break; | |
774 } | |
1983 | 775 if(c->dll) |
5937 | 776 mp_msg(MSGT_CODECCFG,MSGL_INFO,"%-11s%2d %s %s [%s]\n",c->name,c->driver,s,c->info,c->dll); |
1983 | 777 else |
5937 | 778 mp_msg(MSGT_CODECCFG,MSGL_INFO,"%-11s%2d %s %s\n",c->name,c->driver,s,c->info); |
1983 | 779 |
780 } | |
781 | |
782 } | |
783 | |
784 | |
785 | |
607 | 786 #ifdef CODECS2HTML |
787 | |
788 void wrapline(FILE *f2,char *s){ | |
789 int c; | |
790 if(!s){ | |
791 fprintf(f2,"-"); | |
792 return; | |
793 } | |
794 while((c=*s++)){ | |
795 if(c==',') fprintf(f2,"<br>"); else fputc(c,f2); | |
796 } | |
797 } | |
798 | |
799 void parsehtml(FILE *f1,FILE *f2,codecs_t *codec,int section,int dshow){ | |
800 int c,d; | |
801 while((c=fgetc(f1))>=0){ | |
802 if(c!='%'){ | |
803 fputc(c,f2); | |
804 continue; | |
805 } | |
806 d=fgetc(f1); | |
807 | |
808 switch(d){ | |
809 case '.': | |
613 | 810 return; // end of section |
607 | 811 case 'n': |
812 wrapline(f2,codec->name); break; | |
813 case 'i': | |
814 wrapline(f2,codec->info); break; | |
815 case 'c': | |
816 wrapline(f2,codec->comment); break; | |
817 case 'd': | |
818 wrapline(f2,codec->dll); break; | |
819 case 'D': | |
820 fprintf(f2,"%c",codec->driver==dshow?'+':'-'); break; | |
821 case 'F': | |
822 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
|
823 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
|
824 fprintf(f2,"%s%.4s",d?"<br>":"",(codec->fourcc[d]==0xFFFFFFFF || codec->fourcc[d]<0x20202020)?!d?"-":"":(char*) &codec->fourcc[d]); |
607 | 825 break; |
826 case 'f': | |
827 for(d=0;d<CODECS_MAX_FOURCC;d++) | |
828 if(codec->fourcc[d]!=0xFFFFFFFF) | |
829 fprintf(f2,"%s0x%X",d?"<br>":"",codec->fourcc[d]); | |
830 break; | |
831 case 'Y': | |
832 for(d=0;d<CODECS_MAX_OUTFMT;d++) | |
833 if(codec->outfmt[d]!=0xFFFFFFFF){ | |
834 for (c=0; fmt_table[c].name; c++) | |
835 if(fmt_table[c].num==codec->outfmt[d]) break; | |
836 if(fmt_table[c].name) | |
837 fprintf(f2,"%s%s",d?"<br>":"",fmt_table[c].name); | |
838 } | |
839 break; | |
840 default: | |
841 fputc(c,f2); | |
842 fputc(d,f2); | |
843 } | |
844 } | |
845 | |
846 } | |
847 | |
848 void skiphtml(FILE *f1){ | |
849 int c,d; | |
850 while((c=fgetc(f1))>=0){ | |
851 if(c!='%'){ | |
852 continue; | |
853 } | |
854 d=fgetc(f1); | |
855 if(d=='.') return; // end of section | |
856 } | |
857 } | |
858 | |
859 int main(void) | |
860 { | |
4027 | 861 codecs_t *cl; |
607 | 862 FILE *f1; |
863 FILE *f2; | |
864 int c,d,i; | |
865 int pos; | |
866 int section=-1; | |
867 int nr_codecs; | |
868 int win32=-1; | |
869 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
|
870 int win32ex=-1; |
607 | 871 |
4027 | 872 if (!(nr_codecs = parse_codec_cfg("etc/codecs.conf"))) |
607 | 873 return 0; |
874 | |
875 f1=fopen("DOCS/codecs-in.html","rb"); if(!f1) exit(1); | |
1689 | 876 f2=fopen("DOCS/codecs-status.html","wb"); if(!f2) exit(1); |
607 | 877 |
878 while((c=fgetc(f1))>=0){ | |
879 if(c!='%'){ | |
880 fputc(c,f2); | |
881 continue; | |
882 } | |
883 d=fgetc(f1); | |
884 if(d>='0' && d<='9'){ | |
885 // begin section | |
886 section=d-'0'; | |
887 printf("BEGIN %d\n",section); | |
888 if(section>=5){ | |
889 // audio | |
4027 | 890 cl = audio_codecs; |
607 | 891 nr_codecs = nr_acodecs; |
892 dshow=7;win32=4; | |
893 } else { | |
894 // video | |
4027 | 895 cl = video_codecs; |
607 | 896 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
|
897 dshow=4;win32=2;win32ex=6; |
607 | 898 } |
899 pos=ftell(f1); | |
900 for(i=0;i<nr_codecs;i++){ | |
901 fseek(f1,pos,SEEK_SET); | |
902 switch(section){ | |
903 case 0: | |
904 case 5: | |
905 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
|
906 if(!(cl[i].driver==win32 || cl[i].driver==dshow || cl[i].driver==win32ex)) |
607 | 907 parsehtml(f1,f2,&cl[i],section,dshow); |
908 break; | |
909 case 1: | |
910 case 6: | |
911 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
|
912 if(cl[i].driver==win32 || cl[i].driver==dshow || cl[i].driver==win32ex) |
607 | 913 parsehtml(f1,f2,&cl[i],section,dshow); |
914 break; | |
915 case 2: | |
916 case 7: | |
917 if(cl[i].status==CODECS_STATUS_PROBLEMS) | |
918 parsehtml(f1,f2,&cl[i],section,dshow); | |
919 break; | |
920 case 3: | |
921 case 8: | |
922 if(cl[i].status==CODECS_STATUS_NOT_WORKING) | |
923 parsehtml(f1,f2,&cl[i],section,dshow); | |
924 break; | |
925 case 4: | |
926 case 9: | |
927 if(cl[i].status==CODECS_STATUS_UNTESTED) | |
928 parsehtml(f1,f2,&cl[i],section,dshow); | |
929 break; | |
930 default: | |
931 printf("Warning! unimplemented section: %d\n",section); | |
932 } | |
933 } | |
934 fseek(f1,pos,SEEK_SET); | |
935 skiphtml(f1); | |
936 //void parsehtml(FILE *f1,FILE *f2,codecs_t *codec,int section,int dshow){ | |
937 | |
938 continue; | |
939 } | |
940 fputc(c,f2); | |
941 fputc(d,f2); | |
942 } | |
943 | |
944 fclose(f2); | |
945 fclose(f1); | |
946 return 0; | |
947 } | |
948 | |
949 #endif | |
950 | |
297 | 951 #ifdef TESTING |
952 int main(void) | |
953 { | |
4676 | 954 codecs_t *c; |
328 | 955 int i,j, nr_codecs, state; |
297 | 956 |
4676 | 957 if (!(parse_codec_cfg("etc/codecs.conf"))) |
319 | 958 return 0; |
4676 | 959 if (!video_codecs) |
328 | 960 printf("no videoconfig.\n"); |
4676 | 961 if (!audio_codecs) |
328 | 962 printf("no audioconfig.\n"); |
963 | |
964 printf("videocodecs:\n"); | |
4676 | 965 c = video_codecs; |
328 | 966 nr_codecs = nr_vcodecs; |
967 state = 0; | |
968 next: | |
969 if (c) { | |
4676 | 970 printf("number of %scodecs: %d\n", state==0?"video":"audio", |
971 nr_codecs); | |
328 | 972 for(i=0;i<nr_codecs;i++, c++){ |
4676 | 973 printf("\n============== %scodec %02d ===============\n", |
974 state==0?"video":"audio",i); | |
328 | 975 printf("name='%s'\n",c->name); |
976 printf("info='%s'\n",c->info); | |
977 printf("comment='%s'\n",c->comment); | |
978 printf("dll='%s'\n",c->dll); | |
361 | 979 printf("flags=%X driver=%d status=%d cpuflags=%d\n", |
980 c->flags, c->driver, c->status, c->cpuflags); | |
300 | 981 |
328 | 982 for(j=0;j<CODECS_MAX_FOURCC;j++){ |
983 if(c->fourcc[j]!=0xFFFFFFFF){ | |
361 | 984 printf("fourcc %02d: %08X (%.4s) ===> %08X (%.4s)\n",j,c->fourcc[j],(char *) &c->fourcc[j],c->fourccmap[j],(char *) &c->fourccmap[j]); |
328 | 985 } |
986 } | |
987 | |
988 for(j=0;j<CODECS_MAX_OUTFMT;j++){ | |
989 if(c->outfmt[j]!=0xFFFFFFFF){ | |
361 | 990 printf("outfmt %02d: %08X (%.4s) flags: %d\n",j,c->outfmt[j],(char *) &c->outfmt[j],c->outflags[j]); |
328 | 991 } |
992 } | |
300 | 993 |
4676 | 994 for(j=0;j<CODECS_MAX_INFMT;j++){ |
995 if(c->infmt[j]!=0xFFFFFFFF){ | |
996 printf("infmt %02d: %08X (%.4s) flags: %d\n",j,c->infmt[j],(char *) &c->infmt[j],c->inflags[j]); | |
997 } | |
998 } | |
999 | |
328 | 1000 printf("GUID: %08lX %04X %04X",c->guid.f1,c->guid.f2,c->guid.f3); |
1001 for(j=0;j<8;j++) printf(" %02X",c->guid.f4[j]); | |
1002 printf("\n"); | |
300 | 1003 |
328 | 1004 |
1005 } | |
1006 } | |
1007 if (!state) { | |
1008 printf("audiocodecs:\n"); | |
4676 | 1009 c = audio_codecs; |
328 | 1010 nr_codecs = nr_acodecs; |
1011 state = 1; | |
1012 goto next; | |
1013 } | |
297 | 1014 return 0; |
1015 } | |
1016 | |
1017 #endif |