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