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