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