#include #include #include #include #include #include #include #include #include "libvo/video_out.h" #include "codec-cfg.h" #define MALLOC_ADD 10 #define MAX_LINE_LEN 1000 #define STATE_MASK ((1<<7)-1) #define GOT_NAME (1<<0) #define GOT_INFO (1<<1) #define GOT_FOURCC (1<<2) #define GOT_FORMAT (1<<3) #define GOT_DRIVER (1<<4) #define GOT_DLL (1<<5) #define GOT_OUT (1<<6) #define RET_EOF -1 #define RET_EOL -2 #define RET_OK 0 FILE *fp; int line_num = 0; int line_pos; /* line pos */ int firstdef = 1; char *line; char *token; int nr_codecs = 0; int get_token(void) { static int read_nextline = 1; if (read_nextline) { if (!fgets(line, MAX_LINE_LEN, fp)) goto ret_eof; line_pos = 0; ++line_num; read_nextline = 0; } while (isspace(line[line_pos])) ++line_pos; if (line[line_pos] == '\0' || line[line_pos] == '#' || line[line_pos] == ';') { read_nextline = 1; goto ret_eol; } token = line + line_pos; if (line[line_pos] == '"') { token++; for (/* NOTHING */; line[++line_pos] != '"' && line[line_pos];) /* NOTHING */; if (!line[line_pos]) { read_nextline = 1; goto ret_eol; } } else { for (/* NOTHING */; !isspace(line[line_pos]); line_pos++) /* NOTHING */; } line[line_pos] = '\0'; line_pos++; #ifdef DEBUG printf("get_token ok\n"); #endif return RET_OK; ret_eof: #ifdef DEBUG printf("get_token EOF\n"); #endif token = NULL; return RET_EOF; ret_eol: #ifdef DEBUG printf("get_token EOL\n"); #endif token = NULL; return RET_EOL; } int add_to_fourcc(char *s, char *alias, unsigned int *fourcc, unsigned int *map) { int i; char **aliasp; /* find first unused slot */ for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++) /* NOTHING */; if (i == CODECS_MAX_FOURCC) { printf("too many fourcc...\n"); return 0; } #if 1 if (alias) { do { fourcc[i] = *((unsigned int *) s); map[i] = *((unsigned int *) alias); s += 4; i++; } while (*(s++) == ','); } else { do { fourcc[i] = *((unsigned int *) s); map[i] = *((unsigned int *) s); s += 4; i++; } while (*(s++) == ','); } #else if (alias) aliasp = &alias; else aliasp = &s; do { fourcc[i] = *((unsigned int *) s); map[i++] = *((unsigned int *) (*aliasp)); s += 4; } while (*(s++) == ','); #endif if (*(--s) != '\0') return 0; return 1; } int add_to_format(char *s, unsigned int *format) { return 1; } /* short get_flags(char *s) { static char *flagstr[] = { "flip", "noflip", "yuvhack", NULL }; int j; printf("flags='%s'\n",s); if (!s) return 0; return 1; } */ int add_to_out(char *sfmt, char *sflags, unsigned int *outfmt, unsigned char *outflags) { static char *fmtstr[] = { "YUY2", "YV12", "RGB8", "RGB15", "RGB16", "RGB24", "RGB32", "BGR8", "BGR15", "BGR16", "BGR24", "BGR32", NULL }; static unsigned int fmtnum[] = { IMGFMT_YUY2, IMGFMT_YV12, IMGFMT_RGB|8, IMGFMT_RGB|15, IMGFMT_RGB|16, IMGFMT_RGB|24, IMGFMT_RGB|32, IMGFMT_BGR|8, IMGFMT_BGR|15, IMGFMT_BGR|16, IMGFMT_BGR|24, IMGFMT_BGR|32 }; static char *flagstr[] = { "flip", "noflip", "yuvhack", NULL }; int i, j; unsigned char flags; for (i = 0; i < CODECS_MAX_OUTFMT && outfmt[i] != 0xffffffff; i++) /* NOTHING */; if (i == CODECS_MAX_FOURCC) { printf("too many out...\n"); return 0; } flags = 0; //get_flags(sflags); if(sflags) do { for (j = 0; flagstr[j] != NULL; j++) if (!strncmp(sflags, flagstr[j], strlen(flagstr[j]))) break; if (flagstr[j] == NULL) return 0; // error! flags|=(1<name); printf("info='%s'\n",c->info); printf("comment='%s'\n",c->comment); printf("dll='%s'\n",c->dll); printf("flags=%X driver=%d\n",c->flags,c->driver); for(j=0;jfourcc[j]!=0xFFFFFFFF){ printf("fourcc %02d: %08X (%.4s) ===> %08X (%.4s)\n",j,c->fourcc[j],&c->fourcc[j],c->fourccmap[j],&c->fourccmap[j]); } } for(j=0;joutfmt[j]!=0xFFFFFFFF){ printf("outfmt %02d: %08X (%.4s) flags: %d\n",j,c->outfmt[j],&c->outfmt[j],c->outflags[j]); } } } return 0; } #endif