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