3 * by Szabolcs Berecz <szabi@inf.elte.hu>
6 * to compile tester app: gcc -Iloader/ -DTESTING -o codec-cfg codec-cfg.c
7 * to compile CODECS2HTML: gcc -Iloader/ -DCODECS2HTML -o codecs2html codecs-cfg.c
9 * TODO: implement informat in CODECS2HTML too
30 #include "wine/avifmt.h"
32 #include "libvo/img_format.h"
33 #include "codec-cfg.h"
36 #include "codecs.conf.h"
39 #define PRINT_LINENUM mp_msg(MSGT_CODECCFG,MSGL_ERR," at line %d\n", line_num)
41 #define MAX_NR_TOKEN 16
43 #define MAX_LINE_LEN 1000
51 static int add_to_fourcc(char *s
, char *alias
, unsigned int *fourcc
,
57 /* find first unused slot */
58 for (i
= 0; i
< CODECS_MAX_FOURCC
&& fourcc
[i
] != 0xffffffff; i
++)
60 freeslots
= CODECS_MAX_FOURCC
- i
;
62 goto err_out_too_many
;
65 tmp
= mmioFOURCC(s
[0], s
[1], s
[2], s
[3]);
66 for (j
= 0; j
< i
; j
++)
68 goto err_out_duplicated
;
70 map
[i
] = alias
? mmioFOURCC(alias
[0], alias
[1], alias
[2], alias
[3]) : tmp
;
73 } while ((*(s
++) == ',') && --freeslots
);
76 goto err_out_too_many
;
78 goto err_out_parse_error
;
81 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"duplicated FourCC");
84 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"too many FourCCs/formats...");
87 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"parse error");
91 static int add_to_format(char *s
, char *alias
,unsigned int *fourcc
, unsigned int *fourccmap
)
96 /* find first unused slot */
97 for (i
= 0; i
< CODECS_MAX_FOURCC
&& fourcc
[i
] != 0xffffffff; i
++)
99 if (i
== CODECS_MAX_FOURCC
) {
100 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"too many FourCCs/formats...");
104 fourcc
[i
]=strtoul(s
,&endptr
,0);
105 if (*endptr
!= '\0') {
106 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"parse error (format ID not a number?)");
111 fourccmap
[i
]=strtoul(alias
,&endptr
,0);
112 if (*endptr
!= '\0') {
113 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"parse error (format ID alias not a number?)");
117 fourccmap
[i
]=fourcc
[i
];
119 for (j
= 0; j
< i
; j
++)
120 if (fourcc
[j
] == fourcc
[i
]) {
121 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"duplicated format ID");
130 const unsigned int num
;
132 {"YV12", IMGFMT_YV12
},
133 {"I420", IMGFMT_I420
},
134 {"IYUV", IMGFMT_IYUV
},
135 {"NV12", IMGFMT_NV12
},
136 {"NV21", IMGFMT_NV21
},
137 {"YVU9", IMGFMT_YVU9
},
138 {"IF09", IMGFMT_IF09
},
139 {"444P", IMGFMT_444P
},
140 {"422P", IMGFMT_422P
},
141 {"411P", IMGFMT_411P
},
143 {"YUY2", IMGFMT_YUY2
},
144 {"UYVY", IMGFMT_UYVY
},
145 {"YVYU", IMGFMT_YVYU
},
147 {"RGB4", IMGFMT_RGB
|4},
148 {"RGB8", IMGFMT_RGB
|8},
149 {"RGB15", IMGFMT_RGB
|15},
150 {"RGB16", IMGFMT_RGB
|16},
151 {"RGB24", IMGFMT_RGB
|24},
152 {"RGB32", IMGFMT_RGB
|32},
153 {"BGR4", IMGFMT_BGR
|4},
154 {"BGR8", IMGFMT_BGR
|8},
155 {"BGR15", IMGFMT_BGR
|15},
156 {"BGR16", IMGFMT_BGR
|16},
157 {"BGR24", IMGFMT_BGR
|24},
158 {"BGR32", IMGFMT_BGR
|32},
159 {"RGB1", IMGFMT_RGB
|1},
160 {"BGR1", IMGFMT_BGR
|1},
162 {"MPES", IMGFMT_MPEGPES
},
163 {"ZRMJPEGNI", IMGFMT_ZRMJPEGNI
},
164 {"ZRMJPEGIT", IMGFMT_ZRMJPEGIT
},
165 {"ZRMJPEGIB", IMGFMT_ZRMJPEGIB
},
167 {"IDCT_MPEG2",IMGFMT_XVMC_IDCT_MPEG2
},
168 {"MOCO_MPEG2",IMGFMT_XVMC_MOCO_MPEG2
},
174 static int add_to_inout(char *sfmt
, char *sflags
, unsigned int *outfmt
,
175 unsigned char *outflags
)
178 static char *flagstr
[] = {
190 for (i
= 0; i
< CODECS_MAX_OUTFMT
&& outfmt
[i
] != 0xffffffff; i
++)
192 freeslots
= CODECS_MAX_OUTFMT
- i
;
194 goto err_out_too_many
;
199 for (j
= 0; flagstr
[j
] != NULL
; j
++)
200 if (!strncmp(sflags
, flagstr
[j
],
203 if (flagstr
[j
] == NULL
)
204 goto err_out_parse_error
;
206 sflags
+=strlen(flagstr
[j
]);
207 } while (*(sflags
++) == ',');
209 if (*(--sflags
) != '\0')
210 goto err_out_parse_error
;
214 for (j
= 0; fmt_table
[j
].name
!= NULL
; j
++)
215 if (!strncmp(sfmt
, fmt_table
[j
].name
, strlen(fmt_table
[j
].name
)))
217 if (fmt_table
[j
].name
== NULL
)
218 goto err_out_parse_error
;
219 outfmt
[i
] = fmt_table
[j
].num
;
222 sfmt
+=strlen(fmt_table
[j
].name
);
223 } while ((*(sfmt
++) == ',') && --freeslots
);
226 goto err_out_too_many
;
228 if (*(--sfmt
) != '\0')
229 goto err_out_parse_error
;
233 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"too many out...");
236 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"parse error");
241 static short get_driver(char *s
,int audioflag
)
243 static char *audiodrv
[] = {
269 static char *videodrv
[] = {
301 char **drv
=audioflag
?audiodrv
:videodrv
;
304 for(i
=0;drv
[i
];i
++) if(!strcmp(s
,drv
[i
])) return i
;
310 static int validate_codec(codecs_t
*c
, int type
)
313 char *tmp_name
= c
->name
;
315 for (i
= 0; i
< strlen(tmp_name
) && isalnum(tmp_name
[i
]); i
++)
318 if (i
< strlen(tmp_name
)) {
319 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"\ncodec(%s) name is not valid!\n", c
->name
);
324 c
->info
= strdup(c
->name
);
327 if (c
->fourcc
[0] == 0xffffffff) {
328 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"\ncodec(%s) does not have FourCC/format!\n", c
->name
);
332 /* XXX fix this: shitty with 'null' codec */
334 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"\ncodec(%s) does not have a driver!\n", c
->name
);
340 #warning codec->driver == 4;... <- ezt nem kellene belehegeszteni...
341 #warning HOL VANNAK DEFINIALVA????????????
342 if (!c
->dll
&& (c
->driver
== 4 ||
343 (c
->driver
== 2 && type
== TYPE_VIDEO
))) {
344 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"\ncodec(%s) needs a 'dll'!\n", c
->name
);
347 #warning guid.f1 lehet 0? honnan lehet tudni, hogy nem adtak meg?
348 // if (!(codec->flags & CODECS_FLAG_AUDIO) && codec->driver == 4)
350 if (type
== TYPE_VIDEO
)
351 if (c
->outfmt
[0] == 0xffffffff) {
352 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"\ncodec(%s) needs an 'outfmt'!\n", c
->name
);
359 static int add_comment(char *s
, char **d
)
369 if (!(*d
= (char *) realloc(*d
, pos
+ strlen(s
) + 1))) {
370 mp_msg(MSGT_CODECCFG
,MSGL_FATAL
,"Can't allocate memory for comment. ");
377 static short get_cpuflags(char *s
)
379 static char *flagstr
[] = {
389 for (i
= 0; flagstr
[i
]; i
++)
390 if (!strncmp(s
, flagstr
[i
], strlen(flagstr
[i
])))
393 goto err_out_parse_error
;
395 s
+= strlen(flagstr
[i
]);
396 } while (*(s
++) == ',');
399 goto err_out_parse_error
;
407 static int line_num
= 0;
409 static char *token
[MAX_NR_TOKEN
];
410 static int read_nextline
= 1;
412 static int get_token(int min
, int max
)
418 if (max
>= MAX_NR_TOKEN
) {
419 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"get_token(): max >= MAX_NR_TOKEN!");
423 memset(token
, 0x00, sizeof(*token
) * max
);
426 if (!fgets(line
, MAX_LINE_LEN
, fp
))
432 for (i
= 0; i
< max
; i
++) {
433 while (isspace(line
[line_pos
]))
435 if (line
[line_pos
] == '\0' || line
[line_pos
] == '#' ||
436 line
[line_pos
] == ';') {
442 token
[i
] = line
+ line_pos
;
444 if (c
== '"' || c
== '\'') {
446 while (line
[++line_pos
] != c
&& line
[line_pos
])
449 for (/* NOTHING */; !isspace(line
[line_pos
]) &&
450 line
[line_pos
]; line_pos
++)
453 if (!line
[line_pos
]) {
459 line
[line_pos
] = '\0';
471 static codecs_t
*video_codecs
=NULL
;
472 static codecs_t
*audio_codecs
=NULL
;
473 static int nr_vcodecs
= 0;
474 static int nr_acodecs
= 0;
476 int parse_codec_cfg(char *cfgfile
)
478 codecs_t
*codec
= NULL
; // current codec
479 codecs_t
**codecsp
= NULL
;// points to audio_codecs or to video_codecs
480 char *endptr
; // strtoul()...
482 int codec_type
; /* TYPE_VIDEO/TYPE_AUDIO */
485 // in case we call it a second time
486 if(video_codecs
!=NULL
)free(video_codecs
);
489 if(audio_codecs
!=NULL
)free(audio_codecs
);
499 video_codecs
= builtin_video_codecs
;
500 audio_codecs
= builtin_audio_codecs
;
501 nr_vcodecs
= sizeof(builtin_video_codecs
)/sizeof(codecs_t
);
502 nr_acodecs
= sizeof(builtin_audio_codecs
)/sizeof(codecs_t
);
507 mp_msg(MSGT_CODECCFG
,MSGL_INFO
,"Reading %s: ", cfgfile
);
509 if ((fp
= fopen(cfgfile
, "r")) == NULL
) {
510 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"Can't open '%s': %s\n", cfgfile
, strerror(errno
));
514 if ((line
= (char *) malloc(MAX_LINE_LEN
+ 1)) == NULL
) {
515 mp_msg(MSGT_CODECCFG
,MSGL_FATAL
,"Can't get memory for 'line': %s\n", strerror(errno
));
521 * this only catches release lines at the start of
522 * codecs.conf, before audiocodecs and videocodecs.
524 while ((tmp
= get_token(1, 1)) == RET_EOL
)
528 if (!strcmp(token
[0], "release")) {
529 if (get_token(1, 2) < 0)
530 goto err_out_parse_error
;
531 tmp
= atoi(token
[0]);
532 if (tmp
< CODEC_CFG_MIN
)
533 goto err_out_release_num
;
534 while ((tmp
= get_token(1, 1)) == RET_EOL
)
539 goto err_out_release_num
;
542 * check if the next block starts with 'audiocodec' or
545 if (!strcmp(token
[0], "audiocodec") || !strcmp(token
[0], "videocodec"))
547 goto err_out_parse_error
;
549 while ((tmp
= get_token(1, 1)) != RET_EOF
) {
552 if (!strcmp(token
[0], "audiocodec") ||
553 !strcmp(token
[0], "videocodec")) {
554 if (!validate_codec(codec
, codec_type
))
555 goto err_out_not_valid
;
557 if (*token
[0] == 'v') {
558 codec_type
= TYPE_VIDEO
;
559 nr_codecsp
= &nr_vcodecs
;
560 codecsp
= &video_codecs
;
561 } else if (*token
[0] == 'a') {
562 codec_type
= TYPE_AUDIO
;
563 nr_codecsp
= &nr_acodecs
;
564 codecsp
= &audio_codecs
;
567 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"picsba\n");
571 if (!(*codecsp
= (codecs_t
*) realloc(*codecsp
,
572 sizeof(codecs_t
) * (*nr_codecsp
+ 2)))) {
573 mp_msg(MSGT_CODECCFG
,MSGL_FATAL
,"Can't realloc '*codecsp': %s\n", strerror(errno
));
576 codec
=*codecsp
+ *nr_codecsp
;
578 memset(codec
,0,sizeof(codecs_t
));
579 memset(codec
->fourcc
, 0xff, sizeof(codec
->fourcc
));
580 memset(codec
->outfmt
, 0xff, sizeof(codec
->outfmt
));
581 memset(codec
->infmt
, 0xff, sizeof(codec
->infmt
));
583 if (get_token(1, 1) < 0)
584 goto err_out_parse_error
;
585 for (i
= 0; i
< *nr_codecsp
- 1; i
++) {
586 if(( (*codecsp
)[i
].name
!=NULL
) &&
587 (!strcmp(token
[0], (*codecsp
)[i
].name
)) ) {
588 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"Codec name '%s' isn't unique.", token
[0]);
589 goto err_out_print_linenum
;
592 if (!(codec
->name
= strdup(token
[0]))) {
593 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"Can't strdup -> 'name': %s\n", strerror(errno
));
596 } else if (!strcmp(token
[0], "info")) {
597 if (codec
->info
|| get_token(1, 1) < 0)
598 goto err_out_parse_error
;
599 if (!(codec
->info
= strdup(token
[0]))) {
600 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"Can't strdup -> 'info': %s\n", strerror(errno
));
603 } else if (!strcmp(token
[0], "comment")) {
604 if (get_token(1, 1) < 0)
605 goto err_out_parse_error
;
606 add_comment(token
[0], &codec
->comment
);
607 } else if (!strcmp(token
[0], "fourcc")) {
608 if (get_token(1, 2) < 0)
609 goto err_out_parse_error
;
610 if (!add_to_fourcc(token
[0], token
[1],
613 goto err_out_print_linenum
;
614 } else if (!strcmp(token
[0], "format")) {
615 if (get_token(1, 2) < 0)
616 goto err_out_parse_error
;
617 if (!add_to_format(token
[0], token
[1],
618 codec
->fourcc
,codec
->fourccmap
))
619 goto err_out_print_linenum
;
620 } else if (!strcmp(token
[0], "driver")) {
621 if (get_token(1, 1) < 0)
622 goto err_out_parse_error
;
623 if (!(codec
->drv
= strdup(token
[0]))) {
624 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"Can't strdup -> 'driver': %s\n", strerror(errno
));
627 } else if (!strcmp(token
[0], "dll")) {
628 if (get_token(1, 1) < 0)
629 goto err_out_parse_error
;
630 if (!(codec
->dll
= strdup(token
[0]))) {
631 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"Can't strdup -> 'dll': %s\n", strerror(errno
));
634 } else if (!strcmp(token
[0], "guid")) {
635 if (get_token(11, 11) < 0)
636 goto err_out_parse_error
;
637 codec
->guid
.f1
=strtoul(token
[0],&endptr
,0);
638 if ((*endptr
!= ',' || *(endptr
+ 1) != '\0') &&
640 goto err_out_parse_error
;
641 codec
->guid
.f2
=strtoul(token
[1],&endptr
,0);
642 if ((*endptr
!= ',' || *(endptr
+ 1) != '\0') &&
644 goto err_out_parse_error
;
645 codec
->guid
.f3
=strtoul(token
[2],&endptr
,0);
646 if ((*endptr
!= ',' || *(endptr
+ 1) != '\0') &&
648 goto err_out_parse_error
;
649 for (i
= 0; i
< 8; i
++) {
650 codec
->guid
.f4
[i
]=strtoul(token
[i
+ 3],&endptr
,0);
651 if ((*endptr
!= ',' || *(endptr
+ 1) != '\0') &&
653 goto err_out_parse_error
;
655 } else if (!strcmp(token
[0], "out")) {
656 if (get_token(1, 2) < 0)
657 goto err_out_parse_error
;
658 if (!add_to_inout(token
[0], token
[1], codec
->outfmt
,
660 goto err_out_print_linenum
;
661 } else if (!strcmp(token
[0], "in")) {
662 if (get_token(1, 2) < 0)
663 goto err_out_parse_error
;
664 if (!add_to_inout(token
[0], token
[1], codec
->infmt
,
666 goto err_out_print_linenum
;
667 } else if (!strcmp(token
[0], "flags")) {
668 if (get_token(1, 1) < 0)
669 goto err_out_parse_error
;
670 if (!strcmp(token
[0], "seekable"))
671 codec
->flags
|= CODECS_FLAG_SEEKABLE
;
673 if (!strcmp(token
[0], "align16"))
674 codec
->flags
|= CODECS_FLAG_ALIGN16
;
676 goto err_out_parse_error
;
677 } else if (!strcmp(token
[0], "status")) {
678 if (get_token(1, 1) < 0)
679 goto err_out_parse_error
;
680 if (!strcasecmp(token
[0], "working"))
681 codec
->status
= CODECS_STATUS_WORKING
;
682 else if (!strcasecmp(token
[0], "crashing"))
683 codec
->status
= CODECS_STATUS_NOT_WORKING
;
684 else if (!strcasecmp(token
[0], "untested"))
685 codec
->status
= CODECS_STATUS_UNTESTED
;
686 else if (!strcasecmp(token
[0], "buggy"))
687 codec
->status
= CODECS_STATUS_PROBLEMS
;
689 goto err_out_parse_error
;
690 } else if (!strcmp(token
[0], "cpuflags")) {
691 if (get_token(1, 1) < 0)
692 goto err_out_parse_error
;
693 if (!(codec
->cpuflags
= get_cpuflags(token
[0])))
694 goto err_out_parse_error
;
696 goto err_out_parse_error
;
698 if (!validate_codec(codec
, codec_type
))
699 goto err_out_not_valid
;
700 mp_msg(MSGT_CODECCFG
,MSGL_INFO
,"%d audio & %d video codecs\n", nr_acodecs
, nr_vcodecs
);
701 if(video_codecs
) video_codecs
[nr_vcodecs
].name
= NULL
;
702 if(audio_codecs
) audio_codecs
[nr_acodecs
].name
= NULL
;
710 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"parse error");
711 err_out_print_linenum
:
727 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"Codec is not defined correctly.");
728 goto err_out_print_linenum
;
730 mp_msg(MSGT_CODECCFG
,MSGL_ERR
,"This codecs.conf is too old and incompatible with this MPlayer release!");
731 goto err_out_print_linenum
;
734 codecs_t
*find_audio_codec(unsigned int fourcc
, unsigned int *fourccmap
,
737 return find_codec(fourcc
, fourccmap
, start
, 1);
740 codecs_t
*find_video_codec(unsigned int fourcc
, unsigned int *fourccmap
,
743 return find_codec(fourcc
, fourccmap
, start
, 0);
746 codecs_t
* find_codec(unsigned int fourcc
,unsigned int *fourccmap
,
747 codecs_t
*start
, int audioflag
)
754 for (/* NOTHING */; start
->name
; start
++) {
755 for (j
= 0; j
< CODECS_MAX_FOURCC
; j
++) {
756 if (start
->fourcc
[j
] == fourcc
) {
758 *fourccmap
= start
->fourccmap
[j
];
774 for (/* NOTHING */; i
--; c
++) {
775 if(start
&& c
<=start
) continue;
776 for (j
= 0; j
< CODECS_MAX_FOURCC
; j
++) {
777 // FIXME: do NOT hardwire 'null' name here:
778 if (c
->fourcc
[j
]==fourcc
|| !strcmp(c
->drv
,"null")) {
780 *fourccmap
= c
->fourccmap
[j
];
789 void select_codec(char* codecname
,int audioflag
){
792 // printf("select_codec('%s')\n",codecname);
801 for (/* NOTHING */; i
--; c
++)
802 if(!strcmp(c
->name
,codecname
))
803 c
->flags
|=CODECS_FLAG_SELECTED
;
806 void codecs_reset_selection(int audioflag
){
817 for (/* NOTHING */; i
--; c
++)
818 c
->flags
&=(~CODECS_FLAG_SELECTED
);
821 void list_codecs(int audioflag
){
828 mp_msg(MSGT_CODECCFG
,MSGL_INFO
,"ac: afm: status: info: [lib/dll]\n");
832 mp_msg(MSGT_CODECCFG
,MSGL_INFO
,"vc: vfm: status: info: [lib/dll]\n");
835 for (/* NOTHING */; i
--; c
++) {
838 case CODECS_STATUS_WORKING
: s
="working ";break;
839 case CODECS_STATUS_PROBLEMS
: s
="problems";break;
840 case CODECS_STATUS_NOT_WORKING
: s
="crashing";break;
841 case CODECS_STATUS_UNTESTED
: s
="untested";break;
844 mp_msg(MSGT_CODECCFG
,MSGL_INFO
,"%-11s %-9s %s %s [%s]\n",c
->name
,c
->drv
,s
,c
->info
,c
->dll
);
846 mp_msg(MSGT_CODECCFG
,MSGL_INFO
,"%-11s %-9s %s %s\n",c
->name
,c
->drv
,s
,c
->info
);
856 * Fake out GUI references when building the codecs2html utility.
859 void gtkMessageBox( int type
,char * str
) { return; }
863 void wrapline(FILE *f2
,char *s
){
870 if(c
==',') fprintf(f2
,"<br>"); else fputc(c
,f2
);
874 void parsehtml(FILE *f1
,FILE *f2
,codecs_t
*codec
,int section
,int dshow
){
876 while((c
=fgetc(f1
))>=0){
885 return; // end of section
887 wrapline(f2
,codec
->name
); break;
889 wrapline(f2
,codec
->info
); break;
891 wrapline(f2
,codec
->comment
); break;
893 wrapline(f2
,codec
->dll
); break;
895 fprintf(f2
,"%c",!strcmp(codec
->drv
,"dshow")?'+':'-'); break;
897 for(d
=0;d
<CODECS_MAX_FOURCC
;d
++)
898 if(!d
|| codec
->fourcc
[d
]!=0xFFFFFFFF)
899 fprintf(f2
,"%s%.4s",d
?"<br>":"",(codec
->fourcc
[d
]==0xFFFFFFFF || codec
->fourcc
[d
]<0x20202020)?!d
?"-":"":(char*) &codec
->fourcc
[d
]);
902 for(d
=0;d
<CODECS_MAX_FOURCC
;d
++)
903 if(codec
->fourcc
[d
]!=0xFFFFFFFF)
904 fprintf(f2
,"%s0x%X",d
?"<br>":"",codec
->fourcc
[d
]);
907 for(d
=0;d
<CODECS_MAX_OUTFMT
;d
++)
908 if(codec
->outfmt
[d
]!=0xFFFFFFFF){
909 for (c
=0; fmt_table
[c
].name
; c
++)
910 if(fmt_table
[c
].num
==codec
->outfmt
[d
]) break;
911 if(fmt_table
[c
].name
)
912 fprintf(f2
,"%s%s",d
?"<br>":"",fmt_table
[c
].name
);
923 void skiphtml(FILE *f1
){
925 while((c
=fgetc(f1
))>=0){
930 if(d
=='.') return; // end of section
934 static void print_int_array(const int* a
, int size
)
939 printf("%d%s", *a
++, size
?", ":"");
941 printf("0x%X%s", *a
++, size
?", ":"");
945 static void print_char_array(const unsigned char* a
, int size
)
950 printf("%d%s", *a
++, size
?", ":"");
952 printf("0x%02x%s", *a
++, size
?", ":"");
956 static void print_string(const char* s
)
958 if (!s
) printf("NULL");
959 else printf("\"%s\"", s
);
962 int main(int argc
, char* argv
[])
976 * Take path to codecs.conf from command line, or fall back on
979 if (!(nr_codecs
= parse_codec_cfg((argc
>1)?argv
[1]:"etc/codecs.conf")))
988 nm
[0] = "builtin_video_codecs";
989 cod
[0] = video_codecs
;
992 nm
[1] = "builtin_audio_codecs";
993 cod
[1] = audio_codecs
;
996 printf("/* GENERATED FROM %s, DO NOT EDIT! */\n\n",argv
[1]);
998 for (i
=0; i
<2; i
++) {
999 printf("codecs_t %s[] = {\n", nm
[i
]);
1000 for (j
= 0; j
< nr
[i
]; j
++) {
1003 print_int_array(cod
[i
][j
].fourcc
, CODECS_MAX_FOURCC
);
1004 printf(", /* fourcc */\n");
1006 print_int_array(cod
[i
][j
].fourccmap
, CODECS_MAX_FOURCC
);
1007 printf(", /* fourccmap */\n");
1009 print_int_array(cod
[i
][j
].outfmt
, CODECS_MAX_OUTFMT
);
1010 printf(", /* outfmt */\n");
1012 print_char_array(cod
[i
][j
].outflags
, CODECS_MAX_OUTFMT
);
1013 printf(", /* outflags */\n");
1015 print_int_array(cod
[i
][j
].infmt
, CODECS_MAX_INFMT
);
1016 printf(", /* infmt */\n");
1018 print_char_array(cod
[i
][j
].inflags
, CODECS_MAX_INFMT
);
1019 printf(", /* inflags */\n");
1021 print_string(cod
[i
][j
].name
); printf(", /* name */\n");
1022 print_string(cod
[i
][j
].info
); printf(", /* info */\n");
1023 print_string(cod
[i
][j
].comment
); printf(", /* comment */\n");
1024 print_string(cod
[i
][j
].dll
); printf(", /* dll */\n");
1025 print_string(cod
[i
][j
].drv
); printf(", /* drv */\n");
1027 printf("{ 0x%08lx, %hu, %hu,",
1031 print_char_array(cod
[i
][j
].guid
.f4
, sizeof(cod
[i
][j
].guid
.f4
));
1032 printf(" }, /* GUID */\n");
1033 printf("%hd /* flags */, %hd /* status */, %hd /* cpuflags */ }\n",
1036 cod
[i
][j
].cpuflags
);
1037 if (j
< nr
[i
]) printf(",\n");
1044 f1
=fopen("DOCS/tech/codecs-in.html","rb"); if(!f1
) exit(1);
1045 f2
=fopen("DOCS/en/codecs-status.html","wb"); if(!f2
) exit(1);
1047 while((c
=fgetc(f1
))>=0){
1053 if(d
>='0' && d
<='9'){
1056 printf("BEGIN %d\n",section
);
1060 nr_codecs
= nr_acodecs
;
1065 nr_codecs
= nr_vcodecs
;
1066 dshow
=4;win32
=2;win32ex
=6;
1069 for(i
=0;i
<nr_codecs
;i
++){
1070 fseek(f1
,pos
,SEEK_SET
);
1074 if(cl
[i
].status
==CODECS_STATUS_WORKING
)
1075 // if(!(!strcmp(cl[i].drv,"vfw") || !strcmp(cl[i].drv,"dshow") || !strcmp(cl[i].drv,"vfwex") || !strcmp(cl[i].drv,"acm")))
1076 parsehtml(f1
,f2
,&cl
[i
],section
,dshow
);
1081 if(cl
[i
].status
==CODECS_STATUS_WORKING
)
1082 if((!strcmp(cl
[i
].drv
,"vfw") || !strcmp(cl
[i
].drv
,"dshow") || !strcmp(cl
[i
].drv
,"vfwex") || !strcmp(cl
[i
].drv
,"acm")))
1083 parsehtml(f1
,f2
,&cl
[i
],section
,dshow
);
1088 if(cl
[i
].status
==CODECS_STATUS_PROBLEMS
)
1089 parsehtml(f1
,f2
,&cl
[i
],section
,dshow
);
1093 if(cl
[i
].status
==CODECS_STATUS_NOT_WORKING
)
1094 parsehtml(f1
,f2
,&cl
[i
],section
,dshow
);
1098 if(cl
[i
].status
==CODECS_STATUS_UNTESTED
)
1099 parsehtml(f1
,f2
,&cl
[i
],section
,dshow
);
1102 printf("Warning! unimplemented section: %d\n",section
);
1105 fseek(f1
,pos
,SEEK_SET
);
1107 //void parsehtml(FILE *f1,FILE *f2,codecs_t *codec,int section,int dshow){
1126 int i
,j
, nr_codecs
, state
;
1128 if (!(parse_codec_cfg("etc/codecs.conf")))
1131 printf("no videoconfig.\n");
1133 printf("no audioconfig.\n");
1135 printf("videocodecs:\n");
1137 nr_codecs
= nr_vcodecs
;
1141 printf("number of %scodecs: %d\n", state
==0?"video":"audio",
1143 for(i
=0;i
<nr_codecs
;i
++, c
++){
1144 printf("\n============== %scodec %02d ===============\n",
1145 state
==0?"video":"audio",i
);
1146 printf("name='%s'\n",c
->name
);
1147 printf("info='%s'\n",c
->info
);
1148 printf("comment='%s'\n",c
->comment
);
1149 printf("dll='%s'\n",c
->dll
);
1150 printf("flags=%X driver=%d status=%d cpuflags=%d\n",
1151 c
->flags
, c
->driver
, c
->status
, c
->cpuflags
);
1153 for(j
=0;j
<CODECS_MAX_FOURCC
;j
++){
1154 if(c
->fourcc
[j
]!=0xFFFFFFFF){
1155 printf("fourcc %02d: %08X (%.4s) ===> %08X (%.4s)\n",j
,c
->fourcc
[j
],(char *) &c
->fourcc
[j
],c
->fourccmap
[j
],(char *) &c
->fourccmap
[j
]);
1159 for(j
=0;j
<CODECS_MAX_OUTFMT
;j
++){
1160 if(c
->outfmt
[j
]!=0xFFFFFFFF){
1161 printf("outfmt %02d: %08X (%.4s) flags: %d\n",j
,c
->outfmt
[j
],(char *) &c
->outfmt
[j
],c
->outflags
[j
]);
1165 for(j
=0;j
<CODECS_MAX_INFMT
;j
++){
1166 if(c
->infmt
[j
]!=0xFFFFFFFF){
1167 printf("infmt %02d: %08X (%.4s) flags: %d\n",j
,c
->infmt
[j
],(char *) &c
->infmt
[j
],c
->inflags
[j
]);
1171 printf("GUID: %08lX %04X %04X",c
->guid
.f1
,c
->guid
.f2
,c
->guid
.f3
);
1172 for(j
=0;j
<8;j
++) printf(" %02X",c
->guid
.f4
[j
]);
1179 printf("audiocodecs:\n");
1181 nr_codecs
= nr_acodecs
;