comparison codec-cfg.c @ 319:6472ab2051c7

lots of changes
author szabii
date Mon, 09 Apr 2001 20:21:07 +0000
parents 589a93489054
children 5427ff3e2e9d
comparison
equal deleted inserted replaced
318:194ba80a8c69 319:6472ab2051c7
1 1 /*
2 //#define DEBUG 2 * codec.conf parser
3 #define PRINT_LINENUM 3 * by Szabolcs Berecz <szabi@inf.elte.hu>
4 // printf("%s(%d): ", cfgfile, line_num) 4 * (C) 2001
5 5 */
6
7 #define DEBUG
8
9 #ifdef DEBUG
10 #define DBG(str, args...) printf(str, ##args)
11 #else
12 #define DBG(str, args...) do {} while (0)
13 #endif
14
15 #define PRINT_LINENUM printf("%s(%d): ", cfgfile, line_num)
6 16
7 #include <stdio.h> 17 #include <stdio.h>
8 #include <stdlib.h> 18 #include <stdlib.h>
9 #include <fcntl.h> 19 #include <fcntl.h>
10 #include <unistd.h> 20 #include <unistd.h>
14 #include <string.h> 24 #include <string.h>
15 25
16 #include "libvo/video_out.h" 26 #include "libvo/video_out.h"
17 #include "codec-cfg.h" 27 #include "codec-cfg.h"
18 28
19 #define MALLOC_ADD 10 29 #define MAX_NR_TOKEN 16
20 30
21 #define MAX_LINE_LEN 1000 31 #define MAX_LINE_LEN 1000
22 32
23 #define STATE_MASK ((1<<7)-1) 33 #define STATE_MASK ((1<<7)-1)
24 34
30 #define GOT_DLL (1<<5) 40 #define GOT_DLL (1<<5)
31 #define GOT_OUT (1<<6) 41 #define GOT_OUT (1<<6)
32 42
33 #define RET_EOF -1 43 #define RET_EOF -1
34 #define RET_EOL -2 44 #define RET_EOL -2
35 #define RET_OK 0
36 45
37 static FILE *fp; 46 static FILE *fp;
38 static int line_num = 0; 47 static int line_num = 0;
39 static int line_pos; /* line pos */ 48 static int line_pos; /* line pos */
40 static int firstdef = 1;
41 static char *line; 49 static char *line;
42 static char *token; 50 static char *token[MAX_NR_TOKEN];
43 51
44 static codecs_t *codecs=NULL; 52 static codecs_t *codecs=NULL;
45 static int nr_codecs = 0; 53 static int nr_codecs = 0;
46 54
47 static int get_token(void) 55 static int get_token(int min, int max)
48 { 56 {
49 static int read_nextline = 1; 57 static int read_nextline = 1;
58 int i;
59 char c;
60
61 if (max >= MAX_NR_TOKEN) {
62 printf("\nget_token(): max >= MAX_NR_TOKEN!\n");
63 goto ret_eof;
64 }
65
66 memset(token, 0x00, sizeof(*token) * max);
50 67
51 if (read_nextline) { 68 if (read_nextline) {
52 if (!fgets(line, MAX_LINE_LEN, fp)) 69 if (!fgets(line, MAX_LINE_LEN, fp))
53 goto ret_eof; 70 goto ret_eof;
54 line_pos = 0; 71 line_pos = 0;
55 ++line_num; 72 ++line_num;
56 read_nextline = 0; 73 read_nextline = 0;
57 } 74 }
58 while (isspace(line[line_pos])) 75 for (i = 0; i < max; i++) {
59 ++line_pos; 76 while (isspace(line[line_pos]))
60 if (line[line_pos] == '\0' || line[line_pos] == '#' || 77 ++line_pos;
61 line[line_pos] == ';') { 78 if (line[line_pos] == '\0' || line[line_pos] == '#' ||
62 read_nextline = 1; 79 line[line_pos] == ';') {
63 goto ret_eol; 80 read_nextline = 1;
64 } 81 if (i >= min)
65 token = line + line_pos; 82 goto ret_ok;
66 if (line[line_pos] == '"') { 83 goto ret_eol;
67 token++; 84 }
68 for (/* NOTHING */; line[++line_pos] != '"' && line[line_pos];) 85 token[i] = line + line_pos;
69 /* NOTHING */; 86 c = line[line_pos];
87 if (c == '"' || c == '\'') {
88 token[i]++;
89 while (line[++line_pos] != c && line[line_pos])
90 /* NOTHING */;
91 } else {
92 for (/* NOTHING */; !isspace(line[line_pos]) &&
93 line[line_pos]; line_pos++)
94 /* NOTHING */;
95 }
70 if (!line[line_pos]) { 96 if (!line[line_pos]) {
71 read_nextline = 1; 97 read_nextline = 1;
98 if (i >= min - 1)
99 goto ret_ok;
72 goto ret_eol; 100 goto ret_eol;
73 } 101 }
74 } else { 102 line[line_pos] = '\0';
75 for (/* NOTHING */; !isspace(line[line_pos]); line_pos++) 103 line_pos++;
76 /* NOTHING */; 104 }
77 } 105 ret_ok:
78 line[line_pos] = '\0'; 106 return i;
79 line_pos++;
80 #ifdef DEBUG
81 printf("get_token ok\n");
82 #endif
83 return RET_OK;
84 ret_eof: 107 ret_eof:
85 #ifdef DEBUG
86 printf("get_token EOF\n");
87 #endif
88 token = NULL;
89 return RET_EOF; 108 return RET_EOF;
90 ret_eol: 109 ret_eol:
91 #ifdef DEBUG
92 printf("get_token EOL\n");
93 #endif
94 token = NULL;
95 return RET_EOL; 110 return RET_EOL;
96 } 111 }
97 112
98 static int add_to_fourcc(char *s, char *alias, unsigned int *fourcc, 113 static int add_to_fourcc(char *s, char *alias, unsigned int *fourcc,
99 unsigned int *map) 114 unsigned int *map)
100 { 115 {
101 int i; 116 int i, j, freeslots;
102 char **aliasp; 117 char **aliasp;
118 unsigned int tmp;
119
120 /* find first unused slot */
121 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++)
122 /* NOTHING */;
123 freeslots = CODECS_MAX_FOURCC - i;
124 if (!freeslots)
125 goto too_many_error_out;
126
127 aliasp = (alias) ? &alias : &s;
128 do {
129 tmp = *((unsigned int *) s);
130 for (j = 0; j < i; j++)
131 if (tmp == fourcc[j])
132 goto duplicated_error_out;
133 fourcc[i] = tmp;
134 map[i] = *((unsigned int *) (*aliasp));
135 s += 4;
136 i++;
137 } while ((*(s++) == ',') && --freeslots);
138
139 if (!freeslots)
140 goto too_many_error_out;
141 if (*(--s) != '\0')
142 return 0;
143 return 1;
144 duplicated_error_out:
145 printf("\nduplicated fourcc/format\n");
146 return 0;
147 too_many_error_out:
148 printf("\ntoo many fourcc/format...\n");
149 return 0;
150 }
151
152 static int add_to_format(char *s, unsigned int *fourcc, unsigned int *fourccmap)
153 {
154 //printf("\n-----[%s][%s]-----\n",s,format);
155
156 int i, j;
103 157
104 /* find first unused slot */ 158 /* find first unused slot */
105 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++) 159 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++)
106 /* NOTHING */; 160 /* NOTHING */;
107 if (i == CODECS_MAX_FOURCC) { 161 if (i == CODECS_MAX_FOURCC) {
108 printf("too many fourcc...\n"); 162 printf("\ntoo many fourcc/format...\n");
109 return 0; 163 return 0;
110 } 164 }
111 #if 1 165
112 if (alias) {
113 do {
114 fourcc[i] = *((unsigned int *) s);
115 map[i] = *((unsigned int *) alias);
116 s += 4;
117 i++;
118 } while (*(s++) == ',');
119 } else {
120 do {
121 fourcc[i] = *((unsigned int *) s);
122 map[i] = *((unsigned int *) s);
123 s += 4;
124 i++;
125 } while (*(s++) == ',');
126 }
127 #else
128 if (alias)
129 aliasp = &alias;
130 else
131 aliasp = &s;
132 do {
133 fourcc[i] = *((unsigned int *) s);
134 map[i++] = *((unsigned int *) (*aliasp));
135 s += 4;
136 } while (*(s++) == ',');
137 #endif
138 if (*(--s) != '\0')
139 return 0;
140 return 1;
141 }
142
143 static int add_to_format(char *s, unsigned int *fourcc, unsigned int *fourccmap)
144 {
145 // printf("\n-----[%s][%s]-----\n",s,format);
146
147 int i;
148
149 /* find first unused slot */
150 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++)
151 /* NOTHING */;
152 if (i == CODECS_MAX_FOURCC) {
153 printf("too many fourcc...\n");
154 return 0;
155 }
156
157 fourcc[i]=fourccmap[i]=strtoul(s,NULL,0); 166 fourcc[i]=fourccmap[i]=strtoul(s,NULL,0);
167 for (j = 0; j < i; j++)
168 if (fourcc[j] == fourcc[i]) {
169 printf("\nduplicated fourcc/format\n");
170 return 0;
171 }
158 172
159 return 1; 173 return 1;
160 } 174 }
161 175
162 176
197 "noflip", 211 "noflip",
198 "yuvhack", 212 "yuvhack",
199 NULL 213 NULL
200 }; 214 };
201 215
202 int i, j; 216 int i, j, freeslots;
203 unsigned char flags; 217 unsigned char flags;
204 218
205 for (i = 0; i < CODECS_MAX_OUTFMT && outfmt[i] != 0xffffffff; i++) 219 for (i = 0; i < CODECS_MAX_OUTFMT && outfmt[i] != 0xffffffff; i++)
206 /* NOTHING */; 220 /* NOTHING */;
207 if (i == CODECS_MAX_FOURCC) { 221 freeslots = CODECS_MAX_OUTFMT - i;
208 printf("too many out...\n"); 222 if (!freeslots)
209 return 0; 223 goto too_many_error_out;
210 } 224
211 225 flags = 0;
212 flags = 0; //get_flags(sflags);
213 if(sflags) do { 226 if(sflags) do {
214 for (j = 0; flagstr[j] != NULL; j++) 227 for (j = 0; flagstr[j] != NULL; j++)
215 if (!strncmp(sflags, flagstr[j], strlen(flagstr[j]))) 228 if (!strncmp(sflags, flagstr[j], strlen(flagstr[j])))
216 break; 229 break;
217 if (flagstr[j] == NULL) return 0; // error! 230 if (flagstr[j] == NULL) return 0; // error!
218 flags|=(1<<j); 231 flags|=(1<<j);
219 sflags+=strlen(flagstr[j]); 232 sflags+=strlen(flagstr[j]);
220 } while (*(sflags++) == ','); 233 } while (*(sflags++) == ',');
221
222 234
223 do { 235 do {
224 for (j = 0; fmtstr[j] != NULL; j++) 236 for (j = 0; fmtstr[j] != NULL; j++)
225 if (!strncmp(sfmt, fmtstr[j], strlen(fmtstr[j]))) 237 if (!strncmp(sfmt, fmtstr[j], strlen(fmtstr[j])))
226 break; 238 break;
228 return 0; 240 return 0;
229 outfmt[i] = fmtnum[j]; 241 outfmt[i] = fmtnum[j];
230 outflags[i] = flags; 242 outflags[i] = flags;
231 ++i; 243 ++i;
232 sfmt+=strlen(fmtstr[j]); 244 sfmt+=strlen(fmtstr[j]);
233 } while (*(sfmt++) == ','); 245 } while ((*(sfmt++) == ',') && --freeslots);
246
247 if (!freeslots)
248 goto too_many_error_out;
249
234 if (*(--sfmt) != '\0') return 0; 250 if (*(--sfmt) != '\0') return 0;
235 251
236 return 1; 252 return 1;
253 too_many_error_out:
254 printf("\ntoo many out...\n");
255 return 0;
237 } 256 }
238 257
239 static short get_driver(char *s,int audioflag) 258 static short get_driver(char *s,int audioflag)
240 { 259 {
241 static char *audiodrv[] = { 260 static char *audiodrv[] = {
261 for(i=0;drv[i];i++) if(!strcmp(s,drv[i])) return i+1; 280 for(i=0;drv[i];i++) if(!strcmp(s,drv[i])) return i+1;
262 281
263 return 0; 282 return 0;
264 } 283 }
265 284
285 static int valid_codec(codecs_t *codec)
286 {
287 #warning FIXME mi is kell egy codec-be?
288 return 1;
289 }
290
291 static int add_comment(char *s, char **d)
292 {
293 int pos;
294
295 if (!*d)
296 pos = 0;
297 else {
298 pos = strlen(*d);
299 (*d)[pos++] = '\n';
300 }
301 if (!(*d = (char *) realloc(*d, pos + strlen(s) + 1))) {
302 printf("can't allocate mem for comment\n");
303 return 0;
304 }
305 strcpy(*d + pos, s);
306 return 1;
307 }
266 308
267 codecs_t *parse_codec_cfg(char *cfgfile) 309 codecs_t *parse_codec_cfg(char *cfgfile)
268 { 310 {
269 311 codecs_t *codec = NULL; // current codec
270 // codecs_t *codecs = NULL; // array of codecs
271 codecs_t *codec = NULL; // currect codec
272 int free_slots = 0;
273 int tmp, i; 312 int tmp, i;
274 int state = 0; 313 int state = 0;
275 char *param1;
276 314
277 #ifdef DEBUG 315 #ifdef DEBUG
278 assert(cfgfile != NULL); 316 assert(cfgfile != NULL);
279 #endif 317 #endif
280 318
287 325
288 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) { 326 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) {
289 perror("parse_codec_cfg: can't get memory for 'line'"); 327 perror("parse_codec_cfg: can't get memory for 'line'");
290 return NULL; 328 return NULL;
291 } 329 }
292 line_pos = 0; 330
293 line[0] = '\0'; /* forces get_token to read next line */ 331 while ((tmp = get_token(1, 1)) != RET_EOF) {
294
295 for (;;) {
296 tmp = get_token();
297 if (tmp == RET_EOF)
298 goto eof_out;
299 if (tmp == RET_EOL) 332 if (tmp == RET_EOL)
300 continue; 333 continue;
301 if (!strcmp(token, "audiocodec") || !strcmp(token, "videocodec")) { 334 if (!strcmp(token[0], "audiocodec") || !strcmp(token[0], "videocodec")) {
302 PRINT_LINENUM; 335 if (nr_codecs)
303 336 if (!valid_codec(codec))
337 goto not_valid_error_out;
304 if (!(codecs = (codecs_t *) realloc(codecs, 338 if (!(codecs = (codecs_t *) realloc(codecs,
305 sizeof(codecs_t) * (nr_codecs + 1)))) { 339 sizeof(codecs_t) * (nr_codecs + 1)))) {
306 perror("parse_codec_cfg: can't realloc 'codecs'"); 340 perror("parse_codec_cfg: can't realloc 'codecs'");
307 goto err_out; 341 goto err_out;
308 } 342 }
309 codec=&codecs[nr_codecs]; 343 codec=&codecs[nr_codecs];
310 nr_codecs++; 344 nr_codecs++;
311 memset(codec,0,sizeof(codecs_t)); 345 memset(codec,0,sizeof(codecs_t));
312 memset(codec->fourcc, 0xff, sizeof(codec->fourcc)); 346 memset(codec->fourcc, 0xff, sizeof(codec->fourcc));
313 memset(codec->outfmt, 0xff, sizeof(codec->outfmt)); 347 memset(codec->outfmt, 0xff, sizeof(codec->outfmt));
314 state = 0; 348 state = 0;
315 349
316 if (*token == 'a') { /* audiocodec */ 350 if (*token[0] == 'a') { /* audiocodec */
317 //printf("audio");
318 codec->flags |= CODECS_FLAG_AUDIO; 351 codec->flags |= CODECS_FLAG_AUDIO;
319 } else if (*token == 'v') { /* videocodec */ 352 } else if (*token[0] == 'v') { /* videocodec */
320 //printf("video");
321 codec->flags &= !CODECS_FLAG_AUDIO; 353 codec->flags &= !CODECS_FLAG_AUDIO;
322 } else { 354 } else {
323 printf("itt valami nagyon el van baszva\n"); 355 printf("itt valami nagyon el van baszva\n");
324 goto err_out; 356 goto err_out;
325 } 357 }
326 if (get_token() < 0) 358 if (get_token(1, 1) < 0)
327 goto parse_error_out; 359 goto parse_error_out;
328 codec->name = strdup(token); 360 for (i = 0; i < nr_codecs - 1; i++) {
361 #warning audio meg videocodecnek lehet ugyanaz a neve?
362 if ((codec->flags & CODECS_FLAG_AUDIO) !=
363 (codecs[i].flags & CODECS_FLAG_AUDIO))
364 continue;
365 if (!strcmp(token[0], codecs[i].name)) {
366 PRINT_LINENUM;
367 printf("codec name '%s' isn't unique\n", token[0]);
368 goto err_out;
369 }
370 }
371 codec->name = strdup(token[0]);
329 state |= GOT_NAME; 372 state |= GOT_NAME;
330 //printf(" %s\n", codec->name); 373 } else if (!strcmp(token[0], "info")) {
331 } else if (!strcmp(token, "info")) { 374 if (!(state & GOT_NAME))
332 if (!(state & GOT_NAME)) 375 goto parse_error_out;
333 goto parse_error_out; 376 if (state & GOT_INFO || get_token(1, 1) < 0)
334 PRINT_LINENUM; 377 goto parse_error_out;
335 //printf("info"); 378 codec->info = strdup(token[0]);
336 if (state & GOT_INFO || get_token() < 0)
337 goto parse_error_out;
338 codec->info = strdup(token);
339 state |= GOT_INFO; 379 state |= GOT_INFO;
340 //printf(" %s\n", codec->info); 380 } else if (!strcmp(token[0], "comment")) {
341 } else if (!strcmp(token, "comment")) { 381 if (!(state & GOT_NAME))
342 if (!(state & GOT_NAME)) 382 goto parse_error_out;
343 goto parse_error_out; 383 if (get_token(1, 1) < 0)
344 PRINT_LINENUM; 384 goto parse_error_out;
345 //printf("comment"); 385 if (!add_comment(token[0], &codec->comment)) {
346 if (get_token() < 0) 386 PRINT_LINENUM;
347 goto parse_error_out; 387 printf("add_comment()-tel valami sux\n");
348 #if 1 388 }
349 if (!codec->comment) 389 } else if (!strcmp(token[0], "fourcc")) {
350 codec->comment = strdup(token); 390 if (!(state & GOT_NAME))
351 //printf(" %s\n", codec->comment); 391 goto parse_error_out;
352 #else 392 if (get_token(1, 2) < 0)
353 add_comment(token, &codec->comment); 393 goto parse_error_out;
354 printf(" FIXMEEEEEEEEEEEEEEE\n"); 394 if (!add_to_fourcc(token[0], token[1],
355 #endif
356 } else if (!strcmp(token, "fourcc")) {
357 if (!(state & GOT_NAME))
358 goto parse_error_out;
359 PRINT_LINENUM;
360 //printf("fourcc");
361 // if (codec->flags & CODECS_FLAG_AUDIO) {
362 // printf("\n'fourcc' in audiocodec definition!\n");
363 // goto err_out;
364 // }
365 if (get_token() < 0)
366 goto parse_error_out;
367 param1 = strdup(token);
368 get_token();
369 if (!add_to_fourcc(param1, token,
370 codec->fourcc, 395 codec->fourcc,
371 codec->fourccmap)) 396 codec->fourccmap))
397 goto parse_error_out;
398 state |= GOT_FOURCC;
399 } else if (!strcmp(token[0], "format")) {
400 if (!(state & GOT_NAME))
401 goto parse_error_out;
402 if (get_token(1, 1) < 0)
403 goto parse_error_out;
404 if (!add_to_format(token[0], codec->fourcc,codec->fourccmap))
405 goto parse_error_out;
406 state |= GOT_FORMAT;
407 } else if (!strcmp(token[0], "driver")) {
408 if (!(state & GOT_NAME))
409 goto parse_error_out;
410 if (get_token(1, 1) < 0)
411 goto parse_error_out;
412 if ((codec->driver = get_driver(token[0],codec->flags&CODECS_FLAG_AUDIO)) == -1)
372 goto err_out; 413 goto err_out;
373 state |= GOT_FOURCC; 414 } else if (!strcmp(token[0], "dll")) {
374 //printf(" %s: %s\n", param1, token); 415 if (!(state & GOT_NAME))
375 free(param1); 416 goto parse_error_out;
376 } else if (!strcmp(token, "format")) { 417 if (get_token(1, 1) < 0)
377 if (!(state & GOT_NAME)) 418 goto parse_error_out;
378 goto parse_error_out; 419 codec->dll = strdup(token[0]);
379 PRINT_LINENUM; 420 } else if (!strcmp(token[0], "guid")) {
380 //printf("format"); 421 if (!(state & GOT_NAME))
381 // if (!(codec->flags & CODECS_FLAG_AUDIO)) { 422 goto parse_error_out;
382 // printf("\n'format' in videocodec definition!\n"); 423 if (get_token(11, 11) < 0) goto parse_error_out;
383 // goto err_out; 424 codec->guid.f1=strtoul(token[0],NULL,0);
384 // } 425 codec->guid.f2=strtoul(token[1],NULL,0);
385 if (get_token() < 0) 426 codec->guid.f3=strtoul(token[2],NULL,0);
386 goto parse_error_out;
387 if (!add_to_format(token, codec->fourcc,codec->fourccmap))
388 goto err_out;
389 state |= GOT_FORMAT;
390 //printf(" %s\n", token);
391 } else if (!strcmp(token, "driver")) {
392 if (!(state & GOT_NAME))
393 goto parse_error_out;
394 PRINT_LINENUM;
395 //printf("driver");
396 if (get_token() < 0)
397 goto parse_error_out;
398 if ((codec->driver = get_driver(token,codec->flags&CODECS_FLAG_AUDIO)) == -1)
399 goto err_out;
400 //printf(" %s\n", token);
401 } else if (!strcmp(token, "dll")) {
402 if (!(state & GOT_NAME))
403 goto parse_error_out;
404 PRINT_LINENUM;
405 //printf("dll");
406 if (get_token() < 0)
407 goto parse_error_out;
408 codec->dll = strdup(token);
409 //printf(" %s\n", codec->dll);
410 } else if (!strcmp(token, "guid")) {
411 if (!(state & GOT_NAME))
412 goto parse_error_out;
413 PRINT_LINENUM;
414 //printf("guid");
415 if (get_token() < 0) goto parse_error_out;
416 //printf("'%s'",token);
417 codec->guid.f1=strtoul(token,NULL,0);
418 if (get_token() < 0) goto parse_error_out;
419 codec->guid.f2=strtoul(token,NULL,0);
420 if (get_token() < 0) goto parse_error_out;
421 codec->guid.f3=strtoul(token,NULL,0);
422 for (i = 0; i < 8; i++) { 427 for (i = 0; i < 8; i++) {
423 if (get_token() < 0) goto parse_error_out; 428 codec->guid.f4[i]=strtoul(token[i + 3],NULL,0);
424 codec->guid.f4[i]=strtoul(token,NULL,0);
425 } 429 }
426 } else if (!strcmp(token, "out")) { 430 } else if (!strcmp(token[0], "out")) {
427 if (!(state & GOT_NAME)) 431 if (!(state & GOT_NAME))
428 goto parse_error_out; 432 goto parse_error_out;
429 PRINT_LINENUM; 433 if (get_token(1, 2) < 0)
430 //printf("out"); 434 goto parse_error_out;
431 if (get_token() < 0) 435 if (!add_to_out(token[0], token[1], codec->outfmt,
432 goto parse_error_out;
433 param1 = strdup(token);
434 get_token();
435 if (!add_to_out(param1, token, codec->outfmt,
436 codec->outflags)) 436 codec->outflags))
437 goto err_out; 437 goto err_out;
438 //printf(" %s: %s\n", param1, token); 438 } else if (!strcmp(token[0], "flags")) {
439 free(param1); 439 if (!(state & GOT_NAME))
440 } else if (!strcmp(token, "flags")) { 440 goto parse_error_out;
441 if (!(state & GOT_NAME)) 441 if (get_token(1, 1) < 0)
442 goto parse_error_out; 442 goto parse_error_out;
443 PRINT_LINENUM; 443 #warning FIXME flags meg nincs implementalva...
444 //printf("flags"); 444 printf("\n\nUssetek!!!\n\n");
445 if (get_token() < 0) 445 } else if (!strcmp(token[0], "status")) {
446 goto parse_error_out; 446 if (!(state & GOT_NAME))
447 //printf(" %s\n", token); 447 goto parse_error_out;
448 } else if (!strcmp(token, "status")) { 448 if (get_token(1, 1) < 0)
449 if (!(state & GOT_NAME)) 449 goto parse_error_out;
450 goto parse_error_out; 450 if (!strcasecmp(token[0], "rulz"))
451 if (get_token() < 0)
452 goto parse_error_out;
453 if (!strcasecmp(token, "rulz"))
454 codec->status = CODECS_STATUS_WORKING; 451 codec->status = CODECS_STATUS_WORKING;
455 else if (!strcasecmp(token, "suxx")) 452 else if (!strcasecmp(token[0], "suxx"))
456 codec->status = CODECS_STATUS_NOT_WORKING; 453 codec->status = CODECS_STATUS_NOT_WORKING;
457 else if (!strcasecmp(token, "checkthiz")) 454 else if (!strcasecmp(token[0], "checkthiz"))
458 codec->status = CODECS_STATUS_UNTESTED; 455 codec->status = CODECS_STATUS_UNTESTED;
459 else if (!strcasecmp(token, "notsogood")) 456 else if (!strcasecmp(token[0], "notsogood"))
460 codec->status = CODECS_STATUS_PROBLEMS; 457 codec->status = CODECS_STATUS_PROBLEMS;
461 else 458 else
462 goto parse_error_out; 459 goto parse_error_out;
463 } else 460 } else
464 goto parse_error_out; 461 goto parse_error_out;
465 } 462 }
463 if (!valid_codec(codec))
464 goto not_valid_error_out;
466 out: 465 out:
467 free(line); 466 free(line);
468 fclose(fp); 467 fclose(fp);
469 return codecs; 468 return codecs;
470 parse_error_out: 469 parse_error_out:
474 printf("\nOops\n"); 473 printf("\nOops\n");
475 if (codecs) 474 if (codecs)
476 free(codecs); 475 free(codecs);
477 codecs = NULL; 476 codecs = NULL;
478 goto out; 477 goto out;
479 eof_out: 478 not_valid_error_out:
480 /* FIXME teljes az utolso config?? */ 479 PRINT_LINENUM;
481 goto out; 480 printf("codec is not definied correctly\n");
481 goto err_out;
482 } 482 }
483 483
484 codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,int audioflag){ 484 codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,int audioflag){
485 int i,j; 485 int i,j;
486 for(i=0;i<nr_codecs;i++){ 486 for(i=0;i<nr_codecs;i++){
502 int main(void) 502 int main(void)
503 { 503 {
504 codecs_t *codecs; 504 codecs_t *codecs;
505 int i,j; 505 int i,j;
506 506
507 codecs = parse_codec_cfg("DOCS/codecs.conf"); 507 if (!(codecs = parse_codec_cfg("DOCS/codecs.conf")))
508 return 0;
508 509
509 printf("total %d codecs parsed\n",nr_codecs); 510 printf("total %d codecs parsed\n",nr_codecs);
510 for(i=0;i<nr_codecs;i++){ 511 for(i=0;i<nr_codecs;i++){
511 codecs_t *c=&codecs[i]; 512 codecs_t *c=&codecs[i];
512 printf("\n============== codec %02d ===============\n",i); 513 printf("\n============== codec %02d ===============\n",i);
526 if(c->outfmt[j]!=0xFFFFFFFF){ 527 if(c->outfmt[j]!=0xFFFFFFFF){
527 printf("outfmt %02d: %08X (%.4s) flags: %d\n",j,c->outfmt[j],&c->outfmt[j],c->outflags[j]); 528 printf("outfmt %02d: %08X (%.4s) flags: %d\n",j,c->outfmt[j],&c->outfmt[j],c->outflags[j]);
528 } 529 }
529 } 530 }
530 531
531 printf("GUID: %08X %04X %04X",c->guid.f1,c->guid.f2,c->guid.f3); 532 printf("GUID: %08lX %04X %04X",c->guid.f1,c->guid.f2,c->guid.f3);
532 for(j=0;j<8;j++) printf(" %02X",c->guid.f4[j]); 533 for(j=0;j<8;j++) printf(" %02X",c->guid.f4[j]);
533 printf("\n"); 534 printf("\n");
534 535
535 536
536 } 537 }