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