annotate codec-cfg.c @ 299:3343fb3e4f49

outflags[] reading fixed
author arpi_esp
date Fri, 06 Apr 2001 23:56:42 +0000
parents a11ea84cc1ad
children df3f7a25584c
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
299
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
141 /*
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
142 short get_flags(char *s)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
143 {
299
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
144 static char *flagstr[] = {
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
145 "flip",
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
146 "noflip",
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
147 "yuvhack",
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
148 NULL
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
149 };
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
150 int j;
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
151
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
152 printf("flags='%s'\n",s);
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
153
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
154 if (!s)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
155 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
156 return 1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
157 }
299
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
158 */
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
159
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
160 int add_to_out(char *sfmt, char *sflags, unsigned int *outfmt,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
161 unsigned char *outflags)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
162 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
163 static char *fmtstr[] = {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
164 "YUY2",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
165 "YV12",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
166 "RGB8",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
167 "RGB15",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
168 "RGB16",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
169 "RGB24",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
170 "RGB32",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
171 "BGR8",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
172 "BGR15",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
173 "BGR16",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
174 "BGR24",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
175 "BGR32",
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
176 NULL
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
177 };
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
178 static unsigned int fmtnum[] = {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
179 IMGFMT_YUY2,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
180 IMGFMT_YV12,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
181 IMGFMT_RGB|8,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
182 IMGFMT_RGB|15,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
183 IMGFMT_RGB|16,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
184 IMGFMT_RGB|24,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
185 IMGFMT_RGB|32,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
186 IMGFMT_BGR|8,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
187 IMGFMT_BGR|15,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
188 IMGFMT_BGR|16,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
189 IMGFMT_BGR|24,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
190 IMGFMT_BGR|32
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
191 };
299
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
192 static char *flagstr[] = {
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
193 "flip",
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
194 "noflip",
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
195 "yuvhack",
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
196 NULL
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
197 };
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
198
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
199 int i, j;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
200 unsigned char flags;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
201
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
202 for (i = 0; i < CODECS_MAX_OUTFMT && outfmt[i] != 0xffffffff; i++)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
203 /* NOTHING */;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
204 if (i == CODECS_MAX_FOURCC) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
205 printf("too many out...\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
206 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
207 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
208
299
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
209 flags = 0; //get_flags(sflags);
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
210 if(sflags) do {
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
211 for (j = 0; flagstr[j] != NULL; j++)
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
212 if (!strncmp(sflags, flagstr[j], strlen(flagstr[j])))
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
213 break;
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
214 if (flagstr[j] == NULL) return 0; // error!
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
215 flags|=(1<<j);
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
216 sflags+=strlen(flagstr[j]);
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
217 } while (*(sflags++) == ',');
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
218
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
219
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
220 do {
299
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
221 for (j = 0; fmtstr[j] != NULL; j++)
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
222 if (!strncmp(sfmt, fmtstr[j], strlen(fmtstr[j])))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
223 break;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
224 if (fmtstr[j] == NULL)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
225 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
226 outfmt[i] = fmtnum[j];
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
227 outflags[i] = flags;
299
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
228 ++i;
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
229 sfmt+=strlen(fmtstr[j]);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
230 } while (*(sfmt++) == ',');
299
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
231 if (*(--sfmt) != '\0') return 0;
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
232
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
233 return 1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
234 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
235
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
236 short get_driver(char *s)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
237 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
238 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
239 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
240
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
241 #define DEBUG
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
242
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
243 codecs_t *parse_codec_cfg(char *cfgfile)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
244 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
245 #define PRINT_LINENUM printf("%s(%d): ", cfgfile, line_num)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
246 #define GET_MEM\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
247 do {\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
248 if (!(codecs = (codecs_t *) realloc(codecs,\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
249 sizeof(codecs_t) * (nr_codecs + 1)))) {\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
250 perror("parse_codec_cfg: can't realloc 'codecs'");\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
251 goto err_out;\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
252 }\
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
253 } while (0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
254
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
255 codecs_t *codecs = NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
256 int free_slots = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
257 int tmp, i;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
258 int state = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
259 char *param1;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
260
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
261 #ifdef DEBUG
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
262 assert(cfgfile != NULL);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
263 #endif
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
264
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
265 printf("Reading codec config file: %s\n", cfgfile);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
266
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
267 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
268 perror("parse_codec_cfg: can't get memory for 'line'");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
269 return NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
270 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
271
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
272 if ((fp = fopen(cfgfile, "r")) == NULL) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
273 printf("parse_codec_cfg: can't open '%s': %s\n", cfgfile, strerror(errno));
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
274 free(line);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
275 return NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
276 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
277 line_pos = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
278 line[0] = '\0'; /* forces get_token to read next line */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
279
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
280 for (;;) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
281 tmp = get_token();
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
282 if (tmp == RET_EOF)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
283 goto eof_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
284 if (tmp == RET_EOL)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
285 continue;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
286 if (!strcmp(token, "audiocodec") || !strcmp(token, "videocodec")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
287 if (codecs) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
288 // tmp = ~state & STATE_MASK;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
289 // if (tmp != GOT_FOURCC && tmp != GOT_FORMAT)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
290 // goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
291 nr_codecs++;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
292 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
293 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
294 GET_MEM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
295 state = 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
296 codecs[nr_codecs].comment = NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
297 memset(codecs[nr_codecs].fourcc, 0xff,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
298 sizeof(codecs[nr_codecs].fourcc) );
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
299 /*
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
300 memset(codecs[nr_codecs].fourccmap, 0xff,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
301 sizeof(codecs[nr_codecs].fourccmap) *
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
302 CODECS_MAX_FOURCC);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
303 */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
304 memset(codecs[nr_codecs].outfmt, 0xff,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
305 sizeof(codecs[nr_codecs].outfmt) );
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
306 if (*token == 'a') { /* audiocodec */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
307 printf("audio");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
308 codecs[nr_codecs].flags |= CODECS_FLAG_AUDIO;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
309 } else if (*token == 'v') { /* videocodec */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
310 printf("video");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
311 codecs[nr_codecs].flags &= !CODECS_FLAG_AUDIO;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
312 } else {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
313 printf("itt valami nagyon el van baszva\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
314 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
315 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
316 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
317 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
318 codecs[nr_codecs].name = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
319 state |= GOT_NAME;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
320 printf(" %s\n", codecs[nr_codecs].name);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
321 } else if (!strcmp(token, "info")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
322 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
323 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
324 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
325 printf("info");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
326 if (state & GOT_INFO || 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 codecs[nr_codecs].info = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
329 state |= GOT_INFO;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
330 printf(" %s\n", codecs[nr_codecs].info);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
331 } else if (!strcmp(token, "comment")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
332 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
333 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
334 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
335 printf("comment");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
336 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
337 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
338 #if 1
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
339 if (!codecs[nr_codecs].comment)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
340 codecs[nr_codecs].comment = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
341 printf(" %s\n", codecs[nr_codecs].comment);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
342 #else
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
343 add_comment(token, &codecs[nr_codecs].comment);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
344 printf(" FIXMEEEEEEEEEEEEEEE\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
345 #endif
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
346 } else if (!strcmp(token, "fourcc")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
347 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
348 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
349 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
350 printf("fourcc");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
351 if (codecs[nr_codecs].flags & CODECS_FLAG_AUDIO) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
352 printf("\n'fourcc' in audiocodec definition!\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
353 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
354 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
355 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
356 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
357 param1 = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
358 get_token();
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
359 if (!add_to_fourcc(param1, token,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
360 codecs[nr_codecs].fourcc,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
361 codecs[nr_codecs].fourccmap))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
362 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
363 state |= GOT_FOURCC;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
364 printf(" %s: %s\n", param1, token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
365 free(param1);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
366 } else if (!strcmp(token, "format")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
367 if (!(state & GOT_NAME))
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 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
370 printf("format");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
371 if (!(codecs[nr_codecs].flags & CODECS_FLAG_AUDIO)) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
372 printf("\n'format' in videocodec definition!\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
373 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
374 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
375 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
376 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
377 if (!add_to_format(token, codecs[nr_codecs].fourcc))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
378 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
379 state |= GOT_FORMAT;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
380 printf(" %s\n", token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
381 } else if (!strcmp(token, "driver")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
382 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
383 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
384 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
385 printf("driver");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
386 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
387 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
388 if ((codecs[nr_codecs].driver = get_driver(token)) == -1)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
389 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
390 printf(" %s\n", token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
391 } else if (!strcmp(token, "dll")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
392 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
393 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
394 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
395 printf("dll");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
396 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
397 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
398 codecs[nr_codecs].dll = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
399 printf(" %s\n", codecs[nr_codecs].dll);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
400 } else if (!strcmp(token, "guid")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
401 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
402 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
403 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
404 printf("guid");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
405 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
406 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
407 sscanf(token, "%ld,", &codecs[nr_codecs].guid.f1);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
408 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
409 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
410 sscanf(token, "%d,", &tmp);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
411 codecs[nr_codecs].guid.f2 = tmp;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
412 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
413 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
414 sscanf(token, "%d,", &tmp);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
415 codecs[nr_codecs].guid.f3 = tmp;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
416 for (i = 0; i < 7; i++) {
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 sscanf(token, "%d,", &tmp);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
420 codecs[nr_codecs].guid.f4[i] = tmp;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
421 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
422 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
423 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
424 sscanf(token, "%d", &tmp);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
425 codecs[nr_codecs].guid.f4[7] = tmp;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
426 printf(" %s\n", token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
427 } else if (!strcmp(token, "out")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
428 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
429 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
430 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
431 printf("out");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
432 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
433 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
434 param1 = strdup(token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
435 get_token();
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
436 if (!add_to_out(param1, token, codecs[nr_codecs].outfmt,
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
437 codecs[nr_codecs].outflags))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
438 goto err_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
439 printf(" %s: %s\n", param1, token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
440 free(param1);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
441 } else if (!strcmp(token, "flags")) {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
442 if (!(state & GOT_NAME))
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
443 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
444 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
445 printf("flags");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
446 if (get_token() < 0)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
447 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
448 printf(" %s\n", token);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
449 } else
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
450 goto parse_error_out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
451 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
452 out:
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
453 free(line);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
454 fclose(fp);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
455 return codecs;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
456 parse_error_out:
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
457 PRINT_LINENUM;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
458 printf("parse error\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
459 err_out:
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
460 printf("\nOops\n");
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
461 if (codecs)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
462 free(codecs);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
463 codecs = NULL;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
464 goto out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
465 eof_out:
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
466 /* FIXME teljes az utolso config?? */
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
467 goto out;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
468 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
469
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
470 #ifdef TESTING
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
471 int main(void)
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
472 {
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
473 codecs_t *codecs;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
474 int i,j;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
475
298
a11ea84cc1ad codecs.conf was already at DOCS...
arpi_esp
parents: 297
diff changeset
476 codecs = parse_codec_cfg("DOCS/codecs.conf");
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
477
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
478 printf("total %d codecs parsed\n",nr_codecs);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
479 for(i=0;i<nr_codecs;i++){
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
480 codecs_t *c=&codecs[i];
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
481 printf("\n============== codec %02d ===============\n",i);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
482 printf("name='%s'\n",c->name);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
483 printf("info='%s'\n",c->info);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
484 printf("comment='%s'\n",c->comment);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
485 printf("dll='%s'\n",c->dll);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
486 printf("flags=%X driver=%d\n",c->flags,c->driver);
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
487 for(j=0;j<CODECS_MAX_FOURCC;j++){
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
488 if(c->fourcc[j]!=0xFFFFFFFF){
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
489 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
490 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
491 }
299
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
492 for(j=0;j<CODECS_MAX_OUTFMT;j++){
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
493 if(c->outfmt[j]!=0xFFFFFFFF){
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
494 printf("outfmt %02d: %08X (%.4s) flags: %d\n",j,c->outfmt[j],&c->outfmt[j],c->outflags[j]);
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
495 }
3343fb3e4f49 outflags[] reading fixed
arpi_esp
parents: 298
diff changeset
496 }
297
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
497 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
498
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
499 return 0;
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
500 }
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
501
9b00ddddc0b2 imported codec-cfg, small fixes
arpi_esp
parents:
diff changeset
502 #endif