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