319
|
1 /*
|
|
2 * codec.conf parser
|
|
3 * by Szabolcs Berecz <szabi@inf.elte.hu>
|
|
4 * (C) 2001
|
|
5 */
|
303
|
6
|
319
|
7 #define DEBUG
|
303
|
8
|
297
|
9 #include <stdio.h>
|
|
10 #include <stdlib.h>
|
|
11 #include <fcntl.h>
|
|
12 #include <unistd.h>
|
|
13 #include <errno.h>
|
|
14 #include <ctype.h>
|
|
15 #include <assert.h>
|
|
16 #include <string.h>
|
|
17
|
|
18 #include "libvo/video_out.h"
|
|
19 #include "codec-cfg.h"
|
|
20
|
328
|
21 #ifdef DEBUG
|
|
22 # define DBG(str, args...) printf(str, ##args)
|
|
23 #else
|
|
24 # define DBG(str, args...) do {} while (0)
|
|
25 #endif
|
|
26
|
|
27 #define PRINT_LINENUM printf("%s(%d): ", cfgfile, line_num)
|
|
28
|
319
|
29 #define MAX_NR_TOKEN 16
|
297
|
30
|
|
31 #define MAX_LINE_LEN 1000
|
|
32
|
|
33 #define RET_EOF -1
|
|
34 #define RET_EOL -2
|
|
35
|
328
|
36 #define TYPE_VIDEO 0
|
|
37 #define TYPE_AUDIO 1
|
297
|
38
|
303
|
39 static int add_to_fourcc(char *s, char *alias, unsigned int *fourcc,
|
297
|
40 unsigned int *map)
|
|
41 {
|
319
|
42 int i, j, freeslots;
|
297
|
43 char **aliasp;
|
319
|
44 unsigned int tmp;
|
|
45
|
|
46 /* find first unused slot */
|
|
47 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++)
|
|
48 /* NOTHING */;
|
|
49 freeslots = CODECS_MAX_FOURCC - i;
|
|
50 if (!freeslots)
|
328
|
51 goto err_out_too_many;
|
319
|
52
|
|
53 aliasp = (alias) ? &alias : &s;
|
|
54 do {
|
|
55 tmp = *((unsigned int *) s);
|
|
56 for (j = 0; j < i; j++)
|
|
57 if (tmp == fourcc[j])
|
328
|
58 goto err_out_duplicated;
|
319
|
59 fourcc[i] = tmp;
|
|
60 map[i] = *((unsigned int *) (*aliasp));
|
|
61 s += 4;
|
|
62 i++;
|
|
63 } while ((*(s++) == ',') && --freeslots);
|
|
64
|
|
65 if (!freeslots)
|
328
|
66 goto err_out_too_many;
|
319
|
67 if (*(--s) != '\0')
|
|
68 return 0;
|
|
69 return 1;
|
328
|
70 err_out_duplicated:
|
319
|
71 printf("\nduplicated fourcc/format\n");
|
|
72 return 0;
|
328
|
73 err_out_too_many:
|
319
|
74 printf("\ntoo many fourcc/format...\n");
|
|
75 return 0;
|
|
76 }
|
|
77
|
|
78 static int add_to_format(char *s, unsigned int *fourcc, unsigned int *fourccmap)
|
|
79 {
|
|
80 int i, j;
|
297
|
81
|
|
82 /* find first unused slot */
|
|
83 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++)
|
|
84 /* NOTHING */;
|
|
85 if (i == CODECS_MAX_FOURCC) {
|
319
|
86 printf("\ntoo many fourcc/format...\n");
|
297
|
87 return 0;
|
|
88 }
|
|
89
|
300
|
90 fourcc[i]=fourccmap[i]=strtoul(s,NULL,0);
|
319
|
91 for (j = 0; j < i; j++)
|
|
92 if (fourcc[j] == fourcc[i]) {
|
|
93 printf("\nduplicated fourcc/format\n");
|
|
94 return 0;
|
|
95 }
|
300
|
96
|
297
|
97 return 1;
|
|
98 }
|
|
99
|
303
|
100 static int add_to_out(char *sfmt, char *sflags, unsigned int *outfmt,
|
297
|
101 unsigned char *outflags)
|
|
102 {
|
|
103 static char *fmtstr[] = {
|
|
104 "YUY2",
|
|
105 "YV12",
|
|
106 "RGB8",
|
|
107 "RGB15",
|
|
108 "RGB16",
|
|
109 "RGB24",
|
|
110 "RGB32",
|
|
111 "BGR8",
|
|
112 "BGR15",
|
|
113 "BGR16",
|
|
114 "BGR24",
|
|
115 "BGR32",
|
|
116 NULL
|
|
117 };
|
|
118 static unsigned int fmtnum[] = {
|
|
119 IMGFMT_YUY2,
|
|
120 IMGFMT_YV12,
|
|
121 IMGFMT_RGB|8,
|
|
122 IMGFMT_RGB|15,
|
|
123 IMGFMT_RGB|16,
|
|
124 IMGFMT_RGB|24,
|
|
125 IMGFMT_RGB|32,
|
|
126 IMGFMT_BGR|8,
|
|
127 IMGFMT_BGR|15,
|
|
128 IMGFMT_BGR|16,
|
|
129 IMGFMT_BGR|24,
|
|
130 IMGFMT_BGR|32
|
|
131 };
|
299
|
132 static char *flagstr[] = {
|
|
133 "flip",
|
|
134 "noflip",
|
|
135 "yuvhack",
|
|
136 NULL
|
|
137 };
|
|
138
|
319
|
139 int i, j, freeslots;
|
297
|
140 unsigned char flags;
|
|
141
|
|
142 for (i = 0; i < CODECS_MAX_OUTFMT && outfmt[i] != 0xffffffff; i++)
|
|
143 /* NOTHING */;
|
319
|
144 freeslots = CODECS_MAX_OUTFMT - i;
|
|
145 if (!freeslots)
|
328
|
146 goto err_out_too_many;
|
297
|
147
|
319
|
148 flags = 0;
|
299
|
149 if(sflags) do {
|
|
150 for (j = 0; flagstr[j] != NULL; j++)
|
|
151 if (!strncmp(sflags, flagstr[j], strlen(flagstr[j])))
|
|
152 break;
|
|
153 if (flagstr[j] == NULL) return 0; // error!
|
|
154 flags|=(1<<j);
|
|
155 sflags+=strlen(flagstr[j]);
|
|
156 } while (*(sflags++) == ',');
|
297
|
157
|
|
158 do {
|
299
|
159 for (j = 0; fmtstr[j] != NULL; j++)
|
297
|
160 if (!strncmp(sfmt, fmtstr[j], strlen(fmtstr[j])))
|
|
161 break;
|
|
162 if (fmtstr[j] == NULL)
|
|
163 return 0;
|
|
164 outfmt[i] = fmtnum[j];
|
|
165 outflags[i] = flags;
|
299
|
166 ++i;
|
297
|
167 sfmt+=strlen(fmtstr[j]);
|
319
|
168 } while ((*(sfmt++) == ',') && --freeslots);
|
|
169
|
|
170 if (!freeslots)
|
328
|
171 goto err_out_too_many;
|
319
|
172
|
299
|
173 if (*(--sfmt) != '\0') return 0;
|
|
174
|
297
|
175 return 1;
|
328
|
176 err_out_too_many:
|
319
|
177 printf("\ntoo many out...\n");
|
|
178 return 0;
|
297
|
179 }
|
|
180
|
303
|
181 static short get_driver(char *s,int audioflag)
|
297
|
182 {
|
301
|
183 static char *audiodrv[] = {
|
|
184 "mp3lib",
|
|
185 "pcm",
|
|
186 "libac3",
|
|
187 "acm",
|
|
188 "alaw",
|
|
189 "msgsm",
|
|
190 "dshow",
|
|
191 NULL
|
|
192 };
|
|
193 static char *videodrv[] = {
|
|
194 "libmpeg2",
|
|
195 "vfw",
|
|
196 "odivx",
|
|
197 "dshow",
|
|
198 NULL
|
|
199 };
|
|
200 char **drv=audioflag?audiodrv:videodrv;
|
|
201 int i;
|
|
202
|
|
203 for(i=0;drv[i];i++) if(!strcmp(s,drv[i])) return i+1;
|
|
204
|
297
|
205 return 0;
|
|
206 }
|
|
207
|
328
|
208 static int validate_codec(codecs_t *c, int type)
|
319
|
209 {
|
329
|
210 #if 0
|
328
|
211 int i;
|
|
212
|
|
213 for (i = 0; i < strlen(c->name) && isalnum(c->name[i]); i++)
|
|
214 /* NOTHING */;
|
|
215 if (i < strlen(c->name)) {
|
|
216 printf("\ncodec(%s)->name is not valid!\n", c->name);
|
|
217 return 0;
|
|
218 }
|
|
219 #warning codec->info = codec->name; ez ok, vagy strdup()?
|
|
220 if (!c->info)
|
|
221 c->info = c->name;
|
|
222 if (c->fourcc[0] == 0xffffffff) {
|
|
223 printf("\ncodec(%s) does not have fourcc/format!\n", c->name);
|
|
224 return 0;
|
|
225 }
|
|
226 if (!c->driver) {
|
|
227 printf("\ncodec(%s) does not have a driver!\n", c->name);
|
|
228 return 0;
|
|
229 }
|
|
230 #warning codec->driver == 4;... <- ezt nem kellene belehegeszteni...
|
|
231 #warning HOL VANNAK DEFINIALVA????????????
|
|
232 if (!c->dll && (c->driver == 4 ||
|
|
233 (c->driver == 2 && type == TYPE_VIDEO))) {
|
|
234 printf("\ncodec(%s) needs a 'dll'!\n", c->name);
|
|
235 return 0;
|
|
236 }
|
|
237 #warning guid.f1 lehet 0? honnan lehet tudni, hogy nem adtak meg?
|
|
238 // if (!(codec->flags & CODECS_FLAG_AUDIO) && codec->driver == 4)
|
|
239
|
|
240 if (type == TYPE_VIDEO)
|
|
241 if (c->outfmt[0] == 0xffffffff) {
|
|
242 printf("\ncodec(%s) needs an 'outfmt'!\n", c->name);
|
|
243 return 0;
|
|
244 }
|
329
|
245 #endif
|
319
|
246 return 1;
|
|
247 }
|
|
248
|
|
249 static int add_comment(char *s, char **d)
|
|
250 {
|
|
251 int pos;
|
|
252
|
|
253 if (!*d)
|
|
254 pos = 0;
|
|
255 else {
|
|
256 pos = strlen(*d);
|
|
257 (*d)[pos++] = '\n';
|
|
258 }
|
|
259 if (!(*d = (char *) realloc(*d, pos + strlen(s) + 1))) {
|
|
260 printf("can't allocate mem for comment\n");
|
|
261 return 0;
|
|
262 }
|
|
263 strcpy(*d + pos, s);
|
|
264 return 1;
|
|
265 }
|
297
|
266
|
328
|
267 static FILE *fp;
|
|
268 static int line_num = 0;
|
|
269 static char *line;
|
|
270 static char *token[MAX_NR_TOKEN];
|
|
271
|
|
272 static int get_token(int min, int max)
|
297
|
273 {
|
328
|
274 static int read_nextline = 1;
|
|
275 static int line_pos;
|
|
276 int i;
|
|
277 char c;
|
|
278
|
|
279 if (max >= MAX_NR_TOKEN) {
|
|
280 printf("\nget_token(): max >= MAX_NR_TOKEN!\n");
|
|
281 goto out_eof;
|
|
282 }
|
|
283
|
|
284 memset(token, 0x00, sizeof(*token) * max);
|
|
285
|
|
286 if (read_nextline) {
|
|
287 if (!fgets(line, MAX_LINE_LEN, fp))
|
|
288 goto out_eof;
|
|
289 line_pos = 0;
|
|
290 ++line_num;
|
|
291 read_nextline = 0;
|
|
292 }
|
|
293 for (i = 0; i < max; i++) {
|
|
294 while (isspace(line[line_pos]))
|
|
295 ++line_pos;
|
|
296 if (line[line_pos] == '\0' || line[line_pos] == '#' ||
|
|
297 line[line_pos] == ';') {
|
|
298 read_nextline = 1;
|
|
299 if (i >= min)
|
|
300 goto out_ok;
|
|
301 goto out_eol;
|
|
302 }
|
|
303 token[i] = line + line_pos;
|
|
304 c = line[line_pos];
|
|
305 if (c == '"' || c == '\'') {
|
|
306 token[i]++;
|
|
307 while (line[++line_pos] != c && line[line_pos])
|
|
308 /* NOTHING */;
|
|
309 } else {
|
|
310 for (/* NOTHING */; !isspace(line[line_pos]) &&
|
|
311 line[line_pos]; line_pos++)
|
|
312 /* NOTHING */;
|
|
313 }
|
|
314 if (!line[line_pos]) {
|
|
315 read_nextline = 1;
|
|
316 if (i >= min - 1)
|
|
317 goto out_ok;
|
|
318 goto out_eol;
|
|
319 }
|
|
320 line[line_pos] = '\0';
|
|
321 line_pos++;
|
|
322 }
|
|
323 out_ok:
|
|
324 return i;
|
|
325 out_eof:
|
|
326 return RET_EOF;
|
|
327 out_eol:
|
|
328 return RET_EOL;
|
|
329 }
|
|
330
|
|
331 static codecs_t *video_codecs=NULL;
|
|
332 static codecs_t *audio_codecs=NULL;
|
|
333 static int nr_vcodecs = 0;
|
|
334 static int nr_acodecs = 0;
|
|
335
|
|
336 codecs_t **parse_codec_cfg(char *cfgfile)
|
|
337 {
|
|
338 codecs_t *codec = NULL; // current codec
|
|
339 codecs_t **codecsp = NULL;// points to audio_codecs or to video_codecs
|
|
340 static codecs_t *ret_codecs[2] = {NULL,NULL};
|
335
|
341 char *endptr; // strtoul()...
|
328
|
342 int *nr_codecsp;
|
|
343 int codec_type; /* TYPE_VIDEO/TYPE_AUDIO */
|
297
|
344 int tmp, i;
|
|
345
|
|
346 #ifdef DEBUG
|
|
347 assert(cfgfile != NULL);
|
|
348 #endif
|
|
349
|
|
350 printf("Reading codec config file: %s\n", cfgfile);
|
|
351
|
301
|
352 if ((fp = fopen(cfgfile, "r")) == NULL) {
|
328
|
353 printf("can't open '%s': %s\n", cfgfile, strerror(errno));
|
297
|
354 return NULL;
|
|
355 }
|
|
356
|
301
|
357 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) {
|
328
|
358 perror("can't get memory for 'line'");
|
297
|
359 return NULL;
|
|
360 }
|
|
361
|
328
|
362 /*
|
|
363 * check if the cfgfile starts with 'audiocodec' or
|
|
364 * with 'videocodec'
|
|
365 */
|
|
366 while ((tmp = get_token(1, 1)) == RET_EOL)
|
|
367 /* NOTHING */;
|
|
368 if (tmp != RET_EOF && (!strcmp(token[0], "audiocodec") ||
|
|
369 !strcmp(token[0], "videocodec")))
|
|
370 goto loop_enter;
|
|
371 goto out;
|
|
372
|
319
|
373 while ((tmp = get_token(1, 1)) != RET_EOF) {
|
297
|
374 if (tmp == RET_EOL)
|
|
375 continue;
|
328
|
376 if (!strcmp(token[0], "audiocodec") ||
|
|
377 !strcmp(token[0], "videocodec")) {
|
|
378 if (!validate_codec(codec, codec_type))
|
|
379 goto err_out_not_valid;
|
|
380 loop_enter:
|
|
381 if (*token[0] == 'v') {
|
|
382 codec_type = TYPE_VIDEO;
|
|
383 nr_codecsp = &nr_vcodecs;
|
|
384 codecsp = &video_codecs;
|
|
385 } else if (*token[0] == 'a') {
|
|
386 codec_type = TYPE_AUDIO;
|
|
387 nr_codecsp = &nr_acodecs;
|
|
388 codecsp = &audio_codecs;
|
|
389 } else {
|
|
390 printf("rohattkurva\n");
|
|
391 goto err_out;
|
|
392 }
|
|
393 if (!(*codecsp = (codecs_t *) realloc(*codecsp,
|
332
|
394 sizeof(codecs_t) * (*nr_codecsp + 2)))) {
|
328
|
395 perror("can't realloc '*codecsp'");
|
300
|
396 goto err_out;
|
|
397 }
|
328
|
398 codec=*codecsp + *nr_codecsp;
|
|
399 ++*nr_codecsp;
|
300
|
400 memset(codec,0,sizeof(codecs_t));
|
|
401 memset(codec->fourcc, 0xff, sizeof(codec->fourcc));
|
|
402 memset(codec->outfmt, 0xff, sizeof(codec->outfmt));
|
|
403
|
319
|
404 if (get_token(1, 1) < 0)
|
328
|
405 goto err_out_parse_error;
|
|
406 for (i = 0; i < *nr_codecsp - 1; i++) {
|
|
407 if (!strcmp(token[0], (*codecsp)[i].name)) {
|
319
|
408 PRINT_LINENUM;
|
|
409 printf("codec name '%s' isn't unique\n", token[0]);
|
|
410 goto err_out;
|
|
411 }
|
|
412 }
|
328
|
413 if (!(codec->name = strdup(token[0]))) {
|
|
414 perror("can't strdup -> 'name'");
|
|
415 goto err_out;
|
|
416 }
|
319
|
417 } else if (!strcmp(token[0], "info")) {
|
328
|
418 if (codec->info || get_token(1, 1) < 0)
|
|
419 goto err_out_parse_error;
|
|
420 if (!(codec->info = strdup(token[0]))) {
|
|
421 perror("can't strdup -> 'info'");
|
|
422 goto err_out;
|
|
423 }
|
319
|
424 } else if (!strcmp(token[0], "comment")) {
|
|
425 if (get_token(1, 1) < 0)
|
328
|
426 goto err_out_parse_error;
|
319
|
427 if (!add_comment(token[0], &codec->comment)) {
|
|
428 PRINT_LINENUM;
|
|
429 printf("add_comment()-tel valami sux\n");
|
|
430 }
|
|
431 } else if (!strcmp(token[0], "fourcc")) {
|
|
432 if (get_token(1, 2) < 0)
|
328
|
433 goto err_out_parse_error;
|
319
|
434 if (!add_to_fourcc(token[0], token[1],
|
300
|
435 codec->fourcc,
|
|
436 codec->fourccmap))
|
328
|
437 goto err_out_parse_error;
|
319
|
438 } else if (!strcmp(token[0], "format")) {
|
|
439 if (get_token(1, 1) < 0)
|
328
|
440 goto err_out_parse_error;
|
319
|
441 if (!add_to_format(token[0], codec->fourcc,codec->fourccmap))
|
328
|
442 goto err_out_parse_error;
|
319
|
443 } else if (!strcmp(token[0], "driver")) {
|
|
444 if (get_token(1, 1) < 0)
|
328
|
445 goto err_out_parse_error;
|
|
446 if ((codec->driver = get_driver(token[0],codec_type)) == -1)
|
297
|
447 goto err_out;
|
319
|
448 } else if (!strcmp(token[0], "dll")) {
|
|
449 if (get_token(1, 1) < 0)
|
328
|
450 goto err_out_parse_error;
|
|
451 if (!(codec->dll = strdup(token[0]))) {
|
|
452 perror("can't strdup -> 'dll'");
|
|
453 goto err_out;
|
|
454 }
|
319
|
455 } else if (!strcmp(token[0], "guid")) {
|
328
|
456 if (get_token(11, 11) < 0)
|
|
457 goto err_out_parse_error;
|
335
|
458 codec->guid.f1=strtoul(token[0],&endptr,0);
|
|
459 if (*endptr != '\0' && *endptr != ',')
|
|
460 goto err_out_parse_error;
|
|
461 codec->guid.f2=strtoul(token[1],&endptr,0);
|
|
462 if (*endptr != '\0' && *endptr != ',')
|
|
463 goto err_out_parse_error;
|
|
464 codec->guid.f3=strtoul(token[2],&endptr,0);
|
|
465 if (*endptr != '\0' && *endptr != ',')
|
|
466 goto err_out_parse_error;
|
|
467 for (i = 0; i < 8; i++) {
|
|
468 codec->guid.f4[i]=strtoul(token[i + 3],&endptr,0);
|
|
469 if (*endptr != '\0' && *endptr != ',')
|
328
|
470 goto err_out_parse_error;
|
297
|
471 }
|
319
|
472 } else if (!strcmp(token[0], "out")) {
|
|
473 if (get_token(1, 2) < 0)
|
328
|
474 goto err_out_parse_error;
|
319
|
475 if (!add_to_out(token[0], token[1], codec->outfmt,
|
300
|
476 codec->outflags))
|
297
|
477 goto err_out;
|
319
|
478 } else if (!strcmp(token[0], "flags")) {
|
|
479 if (get_token(1, 1) < 0)
|
328
|
480 goto err_out_parse_error;
|
321
|
481 if (!strcmp(token[0], "seekable"))
|
|
482 codec->flags |= CODECS_FLAG_SEEKABLE;
|
|
483 else
|
328
|
484 goto err_out_parse_error;
|
319
|
485 } else if (!strcmp(token[0], "status")) {
|
|
486 if (get_token(1, 1) < 0)
|
328
|
487 goto err_out_parse_error;
|
332
|
488 if (!strcasecmp(token[0], "working"))
|
316
|
489 codec->status = CODECS_STATUS_WORKING;
|
332
|
490 else if (!strcasecmp(token[0], "crashing"))
|
316
|
491 codec->status = CODECS_STATUS_NOT_WORKING;
|
332
|
492 else if (!strcasecmp(token[0], "untested"))
|
316
|
493 codec->status = CODECS_STATUS_UNTESTED;
|
332
|
494 else if (!strcasecmp(token[0], "buggy"))
|
316
|
495 codec->status = CODECS_STATUS_PROBLEMS;
|
|
496 else
|
328
|
497 goto err_out_parse_error;
|
297
|
498 } else
|
328
|
499 goto err_out_parse_error;
|
297
|
500 }
|
328
|
501 if (!validate_codec(codec, codec_type))
|
|
502 goto err_out_not_valid;
|
332
|
503 video_codecs[nr_vcodecs].name = NULL;
|
|
504 audio_codecs[nr_acodecs].name = NULL;
|
328
|
505 ret_codecs[0] = video_codecs;
|
|
506 ret_codecs[1] = audio_codecs;
|
297
|
507 out:
|
|
508 free(line);
|
|
509 fclose(fp);
|
328
|
510 return ret_codecs;
|
|
511 err_out_parse_error:
|
297
|
512 PRINT_LINENUM;
|
|
513 printf("parse error\n");
|
|
514 err_out:
|
|
515 printf("\nOops\n");
|
328
|
516 if (audio_codecs)
|
|
517 free(audio_codecs);
|
|
518 if (video_codecs)
|
|
519 free(video_codecs);
|
|
520 free(line);
|
|
521 free(fp);
|
|
522 return NULL;
|
|
523 err_out_not_valid:
|
319
|
524 PRINT_LINENUM;
|
|
525 printf("codec is not definied correctly\n");
|
|
526 goto err_out;
|
297
|
527 }
|
|
528
|
332
|
529 codecs_t *find_audio_codec(unsigned int fourcc, unsigned int *fourccmap,
|
|
530 codecs_t *start)
|
328
|
531 {
|
332
|
532 return find_codec(fourcc, fourccmap, start, 1);
|
328
|
533 }
|
|
534
|
332
|
535 codecs_t *find_video_codec(unsigned int fourcc, unsigned int *fourccmap,
|
|
536 codecs_t *start)
|
328
|
537 {
|
332
|
538 return find_codec(fourcc, fourccmap, start, 0);
|
328
|
539 }
|
|
540
|
332
|
541 codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,
|
|
542 codecs_t *start, int audioflag)
|
328
|
543 {
|
|
544 int i, j;
|
|
545 codecs_t *c;
|
|
546
|
332
|
547 if (start) {
|
|
548 for (/* NOTHING */; start->name; start++) {
|
|
549 for (j = 0; j < CODECS_MAX_FOURCC; j++) {
|
|
550 if (start->fourcc[j] == fourcc) {
|
|
551 if (fourccmap)
|
|
552 *fourccmap = start->fourccmap[j];
|
|
553 return start;
|
|
554 }
|
|
555 }
|
|
556 }
|
328
|
557 } else {
|
332
|
558 if (audioflag) {
|
|
559 i = nr_acodecs;
|
|
560 c = audio_codecs;
|
|
561 } else {
|
|
562 i = nr_vcodecs;
|
|
563 c = video_codecs;
|
|
564 }
|
|
565 for (/* NOTHING */; i--; c++) {
|
|
566 for (j = 0; j < CODECS_MAX_FOURCC; j++) {
|
|
567 if (c->fourcc[j] == fourcc) {
|
|
568 if (fourccmap)
|
|
569 *fourccmap = c->fourccmap[j];
|
|
570 return c;
|
|
571 }
|
328
|
572 }
|
|
573 }
|
|
574 }
|
|
575 return NULL;
|
303
|
576 }
|
|
577
|
297
|
578 #ifdef TESTING
|
|
579 int main(void)
|
|
580 {
|
328
|
581 codecs_t **codecs, *c;
|
|
582 int i,j, nr_codecs, state;
|
297
|
583
|
319
|
584 if (!(codecs = parse_codec_cfg("DOCS/codecs.conf")))
|
|
585 return 0;
|
328
|
586 if (!codecs[0])
|
|
587 printf("no videoconfig.\n");
|
|
588 if (!codecs[1])
|
|
589 printf("no audioconfig.\n");
|
|
590
|
|
591 printf("videocodecs:\n");
|
|
592 c = codecs[0];
|
|
593 nr_codecs = nr_vcodecs;
|
|
594 state = 0;
|
|
595 next:
|
|
596 if (c) {
|
|
597 printf("number of codecs: %d\n", nr_codecs);
|
|
598 for(i=0;i<nr_codecs;i++, c++){
|
|
599 printf("\n============== codec %02d ===============\n",i);
|
|
600 printf("name='%s'\n",c->name);
|
|
601 printf("info='%s'\n",c->info);
|
|
602 printf("comment='%s'\n",c->comment);
|
|
603 printf("dll='%s'\n",c->dll);
|
|
604 printf("flags=%X driver=%d\n",c->flags,c->driver);
|
300
|
605
|
328
|
606 for(j=0;j<CODECS_MAX_FOURCC;j++){
|
|
607 if(c->fourcc[j]!=0xFFFFFFFF){
|
|
608 printf("fourcc %02d: %08X (%.4s) ===> %08X (%.4s)\n",j,c->fourcc[j],&c->fourcc[j],c->fourccmap[j],&c->fourccmap[j]);
|
|
609 }
|
|
610 }
|
|
611
|
|
612 for(j=0;j<CODECS_MAX_OUTFMT;j++){
|
|
613 if(c->outfmt[j]!=0xFFFFFFFF){
|
|
614 printf("outfmt %02d: %08X (%.4s) flags: %d\n",j,c->outfmt[j],&c->outfmt[j],c->outflags[j]);
|
|
615 }
|
|
616 }
|
300
|
617
|
328
|
618 printf("GUID: %08lX %04X %04X",c->guid.f1,c->guid.f2,c->guid.f3);
|
|
619 for(j=0;j<8;j++) printf(" %02X",c->guid.f4[j]);
|
|
620 printf("\n");
|
300
|
621
|
328
|
622
|
|
623 }
|
|
624 }
|
|
625 if (!state) {
|
|
626 printf("audiocodecs:\n");
|
|
627 c = codecs[1];
|
|
628 nr_codecs = nr_acodecs;
|
|
629 state = 1;
|
|
630 goto next;
|
|
631 }
|
297
|
632 return 0;
|
|
633 }
|
|
634
|
|
635 #endif
|