annotate codec-cfg.c @ 297:9b00ddddc0b2

imported codec-cfg, small fixes
author arpi_esp
date Fri, 06 Apr 2001 23:20:46 +0000
parents
children a11ea84cc1ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
1 #include <stdio.h>
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
2 #include <stdlib.h>
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
3 #include <fcntl.h>
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
4 #include <unistd.h>
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
5 #include <errno.h>
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
6 #include <ctype.h>
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
7 #include <assert.h>
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
8 #include <string.h>
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
9
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
10 #include "libvo/video_out.h"
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
11 #include "codec-cfg.h"
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
12
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
13 #define MALLOC_ADD 10
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
14
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
15 #define MAX_LINE_LEN 1000
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
16
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
17 #define STATE_MASK ((1<<7)-1)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
18
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
19 #define GOT_NAME (1<<0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
20 #define GOT_INFO (1<<1)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
21 #define GOT_FOURCC (1<<2)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
22 #define GOT_FORMAT (1<<3)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
23 #define GOT_DRIVER (1<<4)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
24 #define GOT_DLL (1<<5)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
25 #define GOT_OUT (1<<6)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
26
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
27 #define RET_EOF -1
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
28 #define RET_EOL -2
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
29 #define RET_OK 0
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
30
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
31 FILE *fp;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
32 int line_num = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
33 int line_pos; /* line pos */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
34 int firstdef = 1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
35 char *line;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
36 char *token;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
37
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
38 int nr_codecs = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
39
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
40 int get_token(void)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
41 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
42 static int read_nextline = 1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
43
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
44 if (read_nextline) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
45 if (!fgets(line, MAX_LINE_LEN, fp))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
46 goto ret_eof;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
47 line_pos = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
48 ++line_num;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
49 read_nextline = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
50 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
51 while (isspace(line[line_pos]))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
52 ++line_pos;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
53 if (line[line_pos] == '\0' || line[line_pos] == '#' ||
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
54 line[line_pos] == ';') {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
55 read_nextline = 1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
56 goto ret_eol;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
57 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
58 token = line + line_pos;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
59 if (line[line_pos] == '"') {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
60 token++;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
61 for (/* NOTHING */; line[++line_pos] != '"' && line[line_pos];)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
62 /* NOTHING */;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
63 if (!line[line_pos]) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
64 read_nextline = 1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
65 goto ret_eol;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
66 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
67 } else {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
68 for (/* NOTHING */; !isspace(line[line_pos]); line_pos++)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
69 /* NOTHING */;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
70 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
71 line[line_pos] = '\0';
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
72 line_pos++;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
73 #ifdef DEBUG
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
74 printf("get_token ok\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
75 #endif
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
76 return RET_OK;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
77 ret_eof:
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
78 #ifdef DEBUG
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
79 printf("get_token EOF\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
80 #endif
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
81 token = NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
82 return RET_EOF;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
83 ret_eol:
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
84 #ifdef DEBUG
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
85 printf("get_token EOL\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
86 #endif
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
87 token = NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
88 return RET_EOL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
89 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
90
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
91 int add_to_fourcc(char *s, char *alias, unsigned int *fourcc,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
92 unsigned int *map)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
93 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
94 int i;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
95 char **aliasp;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
96
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
97 /* find first unused slot */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
98 for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
99 /* NOTHING */;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
100 if (i == CODECS_MAX_FOURCC) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
101 printf("too many fourcc...\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
102 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
103 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
104 #if 1
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
105 if (alias) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
106 do {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
107 fourcc[i] = *((unsigned int *) s);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
108 map[i] = *((unsigned int *) alias);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
109 s += 4;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
110 i++;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
111 } while (*(s++) == ',');
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
112 } else {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
113 do {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
114 fourcc[i] = *((unsigned int *) s);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
115 map[i] = *((unsigned int *) s);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
116 s += 4;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
117 i++;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
118 } while (*(s++) == ',');
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
119 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
120 #else
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
121 if (alias)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
122 aliasp = &alias;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
123 else
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
124 aliasp = &s;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
125 do {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
126 fourcc[i] = *((unsigned int *) s);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
127 map[i++] = *((unsigned int *) (*aliasp));
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
128 s += 4;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
129 } while (*(s++) == ',');
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
130 #endif
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
131 if (*(--s) != '\0')
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
132 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
133 return 1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
134 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
135
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
136 int add_to_format(char *s, unsigned int *format)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
137 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
138 return 1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
139 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
140
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
141 short get_flags(char *s)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
142 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
143 if (!s)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
144 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
145 return 1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
146 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
147
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
148 int add_to_out(char *sfmt, char *sflags, unsigned int *outfmt,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
149 unsigned char *outflags)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
150 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
151 static char *fmtstr[] = {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
152 "YUY2",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
153 "YV12",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
154 "RGB8",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
155 "RGB15",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
156 "RGB16",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
157 "RGB24",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
158 "RGB32",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
159 "BGR8",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
160 "BGR15",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
161 "BGR16",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
162 "BGR24",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
163 "BGR32",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
164 NULL
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
165 };
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
166 static unsigned int fmtnum[] = {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
167 IMGFMT_YUY2,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
168 IMGFMT_YV12,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
169 IMGFMT_RGB|8,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
170 IMGFMT_RGB|15,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
171 IMGFMT_RGB|16,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
172 IMGFMT_RGB|24,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
173 IMGFMT_RGB|32,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
174 IMGFMT_BGR|8,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
175 IMGFMT_BGR|15,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
176 IMGFMT_BGR|16,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
177 IMGFMT_BGR|24,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
178 IMGFMT_BGR|32
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
179 };
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
180 int i, j;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
181 unsigned char flags;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
182
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
183 for (i = 0; i < CODECS_MAX_OUTFMT && outfmt[i] != 0xffffffff; i++)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
184 /* NOTHING */;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
185 if (i == CODECS_MAX_FOURCC) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
186 printf("too many out...\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
187 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
188 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
189
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
190 flags = get_flags(sflags);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
191
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
192 do {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
193 for (j = 0; fmtstr[i] != NULL; j++)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
194 if (!strncmp(sfmt, fmtstr[j], strlen(fmtstr[j])))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
195 break;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
196 if (fmtstr[j] == NULL)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
197 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
198 outfmt[i] = fmtnum[j];
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
199 outflags[i] = flags;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
200 sfmt+=strlen(fmtstr[j]);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
201 } while (*(sfmt++) == ',');
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
202 if (*(--sfmt) != '\0')
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
203 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
204 return 1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
205 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
206
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
207 short get_driver(char *s)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
208 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
209 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
210 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
211
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
212 #define DEBUG
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
213
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
214 codecs_t *parse_codec_cfg(char *cfgfile)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
215 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
216 #define PRINT_LINENUM printf("%s(%d): ", cfgfile, line_num)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
217 #define GET_MEM\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
218 do {\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
219 if (!(codecs = (codecs_t *) realloc(codecs,\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
220 sizeof(codecs_t) * (nr_codecs + 1)))) {\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
221 perror("parse_codec_cfg: can't realloc 'codecs'");\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
222 goto err_out;\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
223 }\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
224 } while (0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
225
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
226 codecs_t *codecs = NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
227 int free_slots = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
228 int tmp, i;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
229 int state = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
230 char *param1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
231
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
232 #ifdef DEBUG
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
233 assert(cfgfile != NULL);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
234 #endif
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
235
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
236 printf("Reading codec config file: %s\n", cfgfile);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
237
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
238 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
239 perror("parse_codec_cfg: can't get memory for 'line'");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
240 return NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
241 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
242
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
243 if ((fp = fopen(cfgfile, "r")) == NULL) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
244 printf("parse_codec_cfg: can't open '%s': %s\n", cfgfile, strerror(errno));
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
245 free(line);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
246 return NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
247 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
248 line_pos = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
249 line[0] = '\0'; /* forces get_token to read next line */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
250
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
251 for (;;) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
252 tmp = get_token();
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
253 if (tmp == RET_EOF)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
254 goto eof_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
255 if (tmp == RET_EOL)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
256 continue;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
257 if (!strcmp(token, "audiocodec") || !strcmp(token, "videocodec")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
258 if (codecs) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
259 // tmp = ~state & STATE_MASK;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
260 // if (tmp != GOT_FOURCC && tmp != GOT_FORMAT)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
261 // goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
262 nr_codecs++;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
263 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
264 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
265 GET_MEM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
266 state = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
267 codecs[nr_codecs].comment = NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
268 memset(codecs[nr_codecs].fourcc, 0xff,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
269 sizeof(codecs[nr_codecs].fourcc) );
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
270 /*
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
271 memset(codecs[nr_codecs].fourccmap, 0xff,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
272 sizeof(codecs[nr_codecs].fourccmap) *
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
273 CODECS_MAX_FOURCC);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
274 */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
275 memset(codecs[nr_codecs].outfmt, 0xff,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
276 sizeof(codecs[nr_codecs].outfmt) );
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
277 if (*token == 'a') { /* audiocodec */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
278 printf("audio");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
279 codecs[nr_codecs].flags |= CODECS_FLAG_AUDIO;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
280 } else if (*token == 'v') { /* videocodec */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
281 printf("video");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
282 codecs[nr_codecs].flags &= !CODECS_FLAG_AUDIO;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
283 } else {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
284 printf("itt valami nagyon el van baszva\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
285 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
286 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
287 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
288 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
289 codecs[nr_codecs].name = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
290 state |= GOT_NAME;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
291 printf(" %s\n", codecs[nr_codecs].name);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
292 } else if (!strcmp(token, "info")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
293 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
294 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
295 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
296 printf("info");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
297 if (state & GOT_INFO || get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
298 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
299 codecs[nr_codecs].info = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
300 state |= GOT_INFO;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
301 printf(" %s\n", codecs[nr_codecs].info);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
302 } else if (!strcmp(token, "comment")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
303 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
304 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
305 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
306 printf("comment");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
307 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
308 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
309 #if 1
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
310 if (!codecs[nr_codecs].comment)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
311 codecs[nr_codecs].comment = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
312 printf(" %s\n", codecs[nr_codecs].comment);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
313 #else
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
314 add_comment(token, &codecs[nr_codecs].comment);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
315 printf(" FIXMEEEEEEEEEEEEEEE\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
316 #endif
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
317 } else if (!strcmp(token, "fourcc")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
318 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
319 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
320 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
321 printf("fourcc");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
322 if (codecs[nr_codecs].flags & CODECS_FLAG_AUDIO) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
323 printf("\n'fourcc' in audiocodec definition!\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
324 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
325 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
326 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
327 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
328 param1 = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
329 get_token();
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
330 if (!add_to_fourcc(param1, token,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
331 codecs[nr_codecs].fourcc,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
332 codecs[nr_codecs].fourccmap))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
333 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
334 state |= GOT_FOURCC;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
335 printf(" %s: %s\n", param1, token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
336 free(param1);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
337 } else if (!strcmp(token, "format")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
338 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
339 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
340 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
341 printf("format");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
342 if (!(codecs[nr_codecs].flags & CODECS_FLAG_AUDIO)) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
343 printf("\n'format' in videocodec definition!\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
344 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
345 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
346 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
347 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
348 if (!add_to_format(token, codecs[nr_codecs].fourcc))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
349 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
350 state |= GOT_FORMAT;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
351 printf(" %s\n", token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
352 } else if (!strcmp(token, "driver")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
353 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
354 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
355 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
356 printf("driver");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
357 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
358 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
359 if ((codecs[nr_codecs].driver = get_driver(token)) == -1)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
360 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
361 printf(" %s\n", token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
362 } else if (!strcmp(token, "dll")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
363 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
364 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
365 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
366 printf("dll");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
367 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
368 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
369 codecs[nr_codecs].dll = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
370 printf(" %s\n", codecs[nr_codecs].dll);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
371 } else if (!strcmp(token, "guid")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
372 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
373 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
374 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
375 printf("guid");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
376 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
377 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
378 sscanf(token, "%ld,", &codecs[nr_codecs].guid.f1);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
379 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
380 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
381 sscanf(token, "%d,", &tmp);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
382 codecs[nr_codecs].guid.f2 = tmp;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
383 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
384 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
385 sscanf(token, "%d,", &tmp);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
386 codecs[nr_codecs].guid.f3 = tmp;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
387 for (i = 0; i < 7; i++) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
388 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
389 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
390 sscanf(token, "%d,", &tmp);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
391 codecs[nr_codecs].guid.f4[i] = tmp;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
392 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
393 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
394 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
395 sscanf(token, "%d", &tmp);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
396 codecs[nr_codecs].guid.f4[7] = tmp;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
397 printf(" %s\n", token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
398 } else if (!strcmp(token, "out")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
399 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
400 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
401 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
402 printf("out");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
403 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
404 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
405 param1 = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
406 get_token();
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
407 if (!add_to_out(param1, token, codecs[nr_codecs].outfmt,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
408 codecs[nr_codecs].outflags))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
409 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
410 printf(" %s: %s\n", param1, token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
411 free(param1);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
412 } else if (!strcmp(token, "flags")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
413 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
414 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
415 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
416 printf("flags");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
417 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
418 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
419 printf(" %s\n", token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
420 } else
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
421 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
422 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
423 out:
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
424 free(line);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
425 fclose(fp);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
426 return codecs;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
427 parse_error_out:
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
428 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
429 printf("parse error\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
430 err_out:
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
431 printf("\nOops\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
432 if (codecs)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
433 free(codecs);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
434 codecs = NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
435 goto out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
436 eof_out:
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
437 /* FIXME teljes az utolso config?? */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
438 goto out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
439 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
440
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
441 #ifdef TESTING
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
442 int main(void)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
443 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
444 codecs_t *codecs;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
445 int i,j;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
446
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
447 codecs = parse_codec_cfg("codecs.conf");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
448
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
449 printf("total %d codecs parsed\n",nr_codecs);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
450 for(i=0;i<nr_codecs;i++){
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
451 codecs_t *c=&codecs[i];
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
452 printf("\n============== codec %02d ===============\n",i);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
453 printf("name='%s'\n",c->name);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
454 printf("info='%s'\n",c->info);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
455 printf("comment='%s'\n",c->comment);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
456 printf("dll='%s'\n",c->dll);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
457 printf("flags=%X driver=%d\n",c->flags,c->driver);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
458 for(j=0;j<CODECS_MAX_FOURCC;j++){
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
459 if(c->fourcc[j]!=0xFFFFFFFF){
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
460 printf("fourcc %02d: %08X (%.4s) ===> %08X (%.4s)\n",j,c->fourcc[j],&c->fourcc[j],c->fourccmap[j],&c->fourccmap[j]);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
461 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
462 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
463 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
464
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
465 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
466 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
467
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
468 #endif