1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-18 12:55:16 +00:00

build, codec-cfg.c: simplify builtin codecs.conf handling

The player can read codec mapping (codecs.conf) from an external file
or use embedded defaults. Before, the defaults were stored in the
player binary in the form of final already-parsed data structures.
Simplify things by storing the text of the codecs.conf file instead,
and parse that at runtime the same way an external file would be
parsed.

To create the previous parsed form, the build system first compiled a
separate binary named "codec-cfg", which parsed etc/codecs.conf and
then wrote the results as a C data structure that could be compiled
into the program. The new simple conversion of codecs.conf into a C
string is handled by the new script TOOLS/file2string.py.

After removing the codec-cfg binary, HOST_CC is no longer used for
anything. Remove the --host-cc configure option and associated logic.

Also remove the codec2html and codec-cfg-test functionality. Building
those was already broken and nobody cared.

There was a broken 3-character-long "fourcc" entry in etc/codecs.conf.
This happened to be accepted before but triggered a parse error after
the changes. Remove the broken entry and make the parsing functions
explicitly test for this error.
This commit is contained in:
Uoti Urpala 2012-07-02 02:35:57 +03:00
parent 39a45c7a17
commit 2ba8b91a97
9 changed files with 96 additions and 598 deletions

2
.gitignore vendored
View File

@ -10,8 +10,6 @@
/version.h
/codecs.conf.h
/codec-cfg
/codec-cfg-test
/codecs2html
/cpuinfo
/tags
/TAGS

View File

@ -1,181 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Codec Status Table - MPlayer - The Movie Player</title>
<link rel="stylesheet" type="text/css" href="default.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" link="#666666" vlink="#666666" alink="#666666">
<h1>Status of codecs support</h1>
<ul>
<li><a href="#vc">Video codecs</a></li>
<li><a href="#ac">Audio codecs</a></li>
</ul>
<table width=750 border="0">
<tr>
<td align="center">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="5"><a name="vc">Video codecs:</a></font></b><br><br>
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<tr>
<td colspan=6 bgcolor="#CCCCCC"><b>Working video codecs</b></td>
</tr>
<tr>
<td width=150 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">codec name</font></b></td>
<td width=70 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">fourcc</font></b></td>
<td width=120 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">driver name</font></b></td>
<td width=40 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">out</font></b></td>
<td align=center colspan=2><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">comments</font></b></td>
</tr>
<!-- %0 -->
<tr>
<td align=center><b>%i</b></td>
<td align=center><b>%F</b></td>
<td align=center><b>%d</b></td>
<td align=center><b>%Y</b></td>
<td align=center colspan=2><b>%c</b></td>
</tr>
<!-- %. -->
<tr>
<td colspan=6 bgcolor="#CCCCCC"><b>New / Untested codecs</b></td>
</tr>
<tr>
<td width=150 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">codec name</font></b></td>
<td width=70 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">fourcc</font></b></td>
<td width=120 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">driver name</font></b></td>
<td colspan=3 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">comments</font></b></td>
</tr>
<!-- %4 -->
<tr>
<td align=center><b>%i</b></td>
<td align=center><b>%F</b></td>
<td align=center><b>%d</b></td>
<td align=center colspan=3><b>%c</b></td>
</tr>
<!-- %. -->
<tr>
<td colspan=6 bgcolor="#CCCCCC"><b>Codecs with problems</b></td>
</tr>
<tr>
<td width=150 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">codec name</font></b></td>
<td width=70 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">fourcc</font></b></td>
<td width=120 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">driver name</font></b></td>
<td colspan=3 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">comments</font></b></td>
</tr>
<!-- %2 -->
<tr>
<td align=center><b>%i</b></td>
<td align=center><b>%F</b></td>
<td align=center><b>%d</b></td>
<td align=center colspan=3><b>%c</b></td>
</tr>
<!-- %. -->
<tr>
<td colspan=6 bgcolor="#CCCCCC"><b>Not yet working codecs:</b></td>
</tr>
<tr>
<td width=150 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">codec name</font></b></td>
<td width=70 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">fourcc</font></b></td>
<td width=120 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">driver name</font></b></td>
<td colspan=3 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">comments</font></b></td>
</tr>
<!-- %3 -->
<tr>
<td align=center><b>%i</b></td>
<td align=center><b>%F</b></td>
<td align=center><b>%d</b></td>
<td align=center colspan=3><b>%c</b></td>
</tr>
<!-- %. -->
</table>
<br><b><font face="Verdana, Arial, Helvetica, sans-serif" size="5"><a name="ac">Audio codecs:</a></font></b><br><br>
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<tr>
<td colspan=6 bgcolor="#CCCCCC"><b>Working audio codecs</b></td>
</tr>
<tr>
<td width=150 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">codec name</font></b></td>
<td width=70 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">format</font></b></td>
<td width=120 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">driver name</font></b></td>
<td align=center colspan=3><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">comments</font></b></td>
</tr>
<!-- %5 -->
<tr>
<td align=center><b>%i</b></td>
<td align=center><b>%f</b></td>
<td align=center><b>%d</b></td>
<td align=center colspan=3><b>%c</b></td>
</tr>
<!-- %. -->
<tr>
<td colspan=6 bgcolor="#CCCCCC"><b>New / Untested codecs</b></td>
</tr>
<tr>
<td width=150 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">codec name</font></b></td>
<td width=70 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">format</font></b></td>
<td width=120 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">driver name</font></b></td>
<td colspan=3 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">comments</font></b></td>
</tr>
<!-- %9 -->
<tr>
<td align=center><b>%i</b></td>
<td align=center><b>%f</b></td>
<td align=center><b>%d</b></td>
<td align=center colspan=3><b>%c</b></td>
</tr>
<!-- %. -->
<tr>
<td colspan=6 bgcolor="#CCCCCC"><b>Codecs with problems</b></td>
</tr>
<tr>
<td width=150 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">codec name</font></b></td>
<td width=70 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">format</font></b></td>
<td width=120 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">driver name</font></b></td>
<td colspan=3 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">comments</font></b></td>
</tr>
<!-- %7 -->
<tr>
<td align=center><b>%i</b></td>
<td align=center><b>%f</b></td>
<td align=center><b>%d</b></td>
<td align=center colspan=3><b>%c</b></td>
</tr>
<!-- %. -->
<tr>
<td colspan=6 bgcolor="#CCCCCC"><b>Not yet working codecs</b></td>
</tr>
<tr>
<td width=150 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">codec name</font></b></td>
<td width=70 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">format</font></b></td>
<td width=120 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">driver name</font></b></td>
<td colspan=3 align=center><b><font color="#AAAAAA" face="Verdana, Arial, Helvetica, sans-serif" size="2">comments</font></b></td>
</tr>
<!-- %8 -->
<tr>
<td align=center><b>%i</b></td>
<td align=center><b>%f</b></td>
<td align=center><b>%d</b></td>
<td align=center colspan=3><b>%c</b></td>
</tr>
<!-- %. -->
</table>
</td>
</tr>
</table>
</body>
</html>

View File

@ -592,11 +592,8 @@ mplayer$(EXESUF): EXTRALIBS += $(EXTRALIBS_MPLAYER)
mplayer$(EXESUF):
$(CC) -o $@ $^ $(EXTRALIBS)
codec-cfg$(EXESUF): codec-cfg.c codec-cfg.h
$(HOST_CC) -O -DCODECS2HTML -I. -o $@ $<
codecs.conf.h: codec-cfg$(EXESUF) etc/codecs.conf
./$^ > $@
codecs.conf.h: TOOLS/file2string.py etc/codecs.conf
./$^ >$@
libvo/vdpau_template.c: TOOLS/vdpau_functions.py
./$< > $@
@ -716,7 +713,7 @@ distclean: clean testsclean toolsclean driversclean
-$(RM) config.log config.mak config.h codecs.conf.h version.h TAGS tags
-$(RM) libvo/vdpau_template.c
-$(RM) libmpdemux/ebml_types.h libmpdemux/ebml_defs.c
-$(RM) $(call ADD_ALL_EXESUFS,codec-cfg cpuinfo)
-$(RM) $(call ADD_ALL_EXESUFS,cpuinfo)
doxygen:
doxygen DOCS/tech/Doxyfile
@ -731,18 +728,12 @@ tags:
TEST_OBJS = mp_msg.o mp_fifo.o osdep/$(GETCH) osdep/$(TIMER) -ltermcap -lm
codec-cfg-test$(EXESUF): codec-cfg.c codecs.conf.h $(TEST_OBJS)
$(CC) -I. -DTESTING -o $@ $^
codecs2html$(EXESUF): codec-cfg.c $(TEST_OBJS)
$(CC) -I. -DCODECS2HTML -o $@ $^
LOADER_TEST_OBJS = $(SRCS_WIN32_EMULATION:.c=.o) $(SRCS_QTX_EMULATION:.S=.o) libavutil/libavutil.a osdep/mmap_anon.o cpudetect.o path.o $(TEST_OBJS)
loader/qtx/list$(EXESUF) loader/qtx/qtxload$(EXESUF): CFLAGS += -g
loader/qtx/list$(EXESUF) loader/qtx/qtxload$(EXESUF): $(LOADER_TEST_OBJS)
TESTS = codecs2html codec-cfg-test
TESTS =
ifdef ARCH_X86
TESTS += loader/qtx/list loader/qtx/qtxload

23
TOOLS/file2string.py Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python3
# Convert the contents of a file into a C string constant.
# Note that the compiler will implicitly add an extra 0 byte at the end
# of every string, so code using the string may need to remove that to get
# the exact contents of the original file.
import sys
def main(infile):
conv = ['\\' + oct(c)[2:] for c in range(256)]
safe_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" \
"0123456789!#%&'()*+,-./:;<=>?[]^_{|}~ "
for c in safe_chars:
conv[ord(c)] = c
for c, esc in ("\nn", "\tt", r"\\", '""'):
conv[ord(c)] = '\\' + esc
for line in infile:
sys.stdout.write('"' + ''.join(conv[c] for c in line) + '"\n')
with open(sys.argv[1], 'rb') as infile:
sys.stdout.write("// Generated from %s\n\n" % sys.argv[1])
main(infile)

10
bstr.c
View File

@ -185,6 +185,16 @@ struct bstr *bstr_splitlines(void *talloc_ctx, struct bstr str)
return r;
}
struct bstr bstr_getline(struct bstr str, struct bstr *rest)
{
int pos = bstrchr(str, '\n');
if (pos < 0)
pos = str.len;
if (rest)
*rest = bstr_cut(str, pos + 1);
return bstr_splice(str, 0, pos + 1);
}
bool bstr_eatstart(struct bstr *s, struct bstr prefix)
{
if (!bstr_startswith(*s, prefix))

6
bstr.h
View File

@ -64,6 +64,7 @@ int bstrcspn(struct bstr str, const char *reject);
int bstr_find(struct bstr haystack, struct bstr needle);
struct bstr *bstr_splitlines(void *talloc_ctx, struct bstr str);
struct bstr bstr_getline(struct bstr str, struct bstr *rest);
struct bstr bstr_lstrip(struct bstr str);
struct bstr bstr_strip(struct bstr str);
struct bstr bstr_split(struct bstr str, const char *sep, struct bstr *rest);
@ -135,6 +136,11 @@ static inline int bstr_find0(struct bstr haystack, const char *needle)
return bstr_find(haystack, bstr(needle));
}
static inline int bstr_eatstart0(struct bstr *s, char *prefix)
{
return bstr_eatstart(s, bstr(prefix));
}
#endif
// create a pair (not single value!) for "%.*s" printf syntax

View File

@ -1,12 +1,5 @@
/*
* codec.conf parser
*
* to compile test application:
* cc -I. -DTESTING -o codec-cfg-test codec-cfg.c mp_msg.o osdep/getch2.o -ltermcap
* to compile CODECS2HTML:
* gcc -DCODECS2HTML -o codecs2html codec-cfg.c mp_msg.o
*
* TODO: implement informat in CODECS2HTML too
* codecs.conf parser
*
* Copyright (C) 2001 Szabolcs Berecz <szabi@inf.elte.hu>
*
@ -44,24 +37,18 @@
#include "config.h"
#include "mp_msg.h"
#ifdef CODECS2HTML
#define mp_tmsg mp_msg
#ifdef __GNUC__
#define mp_msg(t, l, m, args...) fprintf(stderr, m, ##args)
#else
#define mp_msg(t, l, ...) fprintf(stderr, __VA_ARGS__)
#endif
#endif
#include "libmpcodecs/img_format.h"
#include "codec-cfg.h"
#include "bstr.h"
#include "stream/stream.h"
#include "path.h"
#ifdef CODECS2HTML
#define CODEC_CFG_MIN 20100000
#else
static const char embedded_file[] =
#include "codecs.conf.h"
#endif
;
static const struct bstr builtin_codecs_conf = {
.start = (char *)embedded_file, .len = sizeof(embedded_file) - 1
};
#define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
( (uint32_t)(uint8_t)(ch0) | ( (uint32_t)(uint8_t)(ch1) << 8 ) | \
@ -71,8 +58,6 @@
#define MAX_NR_TOKEN 16
#define MAX_LINE_LEN 1000
#define RET_EOF -1
#define RET_EOL -2
@ -96,6 +81,8 @@ static int add_to_fourcc(char *s, char *alias, unsigned int *fourcc,
goto err_out_too_many;
do {
if (strlen(s) < 4)
goto err_out_parse_error;
tmp = mmioFOURCC(s[0], s[1], s[2], s[3]);
for (j = 0; j < i; j++)
if (tmp == fourcc[j])
@ -393,7 +380,7 @@ err_out_parse_error:
return 0;
}
static FILE *fp;
static struct bstr filetext;
static int line_num = 0;
static char *line;
static char *token[MAX_NR_TOKEN];
@ -413,8 +400,11 @@ static int get_token(int min, int max)
memset(token, 0x00, sizeof(*token) * max);
if (read_nextline) {
if (!fgets(line, MAX_LINE_LEN, fp))
if (!filetext.len)
goto out_eof;
struct bstr nextline = bstr_getline(filetext, &filetext);
line = nextline.start;
line[nextline.len - 1] = 0;
line_pos = 0;
++line_num;
read_nextline = 0;
@ -471,6 +461,16 @@ int parse_codec_cfg(const char *cfgfile)
int *nr_codecsp;
int codec_type; /* TYPE_VIDEO/TYPE_AUDIO */
int tmp, i;
int codec_cfg_min;
for (struct bstr s = builtin_codecs_conf; ; bstr_getline(s, &s)) {
if (!s.len)
abort();
if (bstr_eatstart0(&s, "release ")) {
codec_cfg_min = atoi(s.start);
break;
}
}
// in case we call it a second time
codecs_uninit_free();
@ -478,31 +478,27 @@ int parse_codec_cfg(const char *cfgfile)
nr_vcodecs = 0;
nr_acodecs = 0;
if(cfgfile==NULL) {
#ifdef CODECS2HTML
return 0;
#else
/* following casts are harmless since {video,audio}_codecs will stay
* untouched in this case */
video_codecs = (codecs_t *)builtin_video_codecs;
audio_codecs = (codecs_t *)builtin_audio_codecs;
nr_vcodecs = sizeof(builtin_video_codecs)/sizeof(codecs_t);
nr_acodecs = sizeof(builtin_audio_codecs)/sizeof(codecs_t);
return 1;
#endif
}
if (cfgfile) {
// Avoid printing errors from open_stream when trying optional files
if (!mp_path_exists(cfgfile)) {
mp_tmsg(MSGT_CODECCFG, MSGL_V,
"No optional codecs config file: %s\n", cfgfile);
return 0;
}
mp_msg(MSGT_CODECCFG, MSGL_V, "Reading codec config file: %s\n",
cfgfile);
struct stream *s = open_stream(cfgfile, NULL, NULL);
if (!s)
return 0;
filetext = stream_read_complete(s, NULL, 10000000, 1);
free_stream(s);
if (!filetext.start)
return 0;
} else
// Parsing modifies the data
filetext = bstrdup(NULL, builtin_codecs_conf);
void *tmpmem = filetext.start;
mp_tmsg(MSGT_CODECCFG,MSGL_V,"Reading %s: ", cfgfile);
if ((fp = fopen(cfgfile, "r")) == NULL) {
mp_tmsg(MSGT_CODECCFG,MSGL_V,"Can't open '%s': %s\n", cfgfile, strerror(errno));
return 0;
}
if ((line = malloc(MAX_LINE_LEN + 1)) == NULL) {
mp_tmsg(MSGT_CODECCFG,MSGL_FATAL,"Can't get memory for 'line': %s\n", strerror(errno));
return 0;
}
read_nextline = 1;
/*
@ -517,7 +513,7 @@ int parse_codec_cfg(const char *cfgfile)
if (get_token(1, 2) < 0)
goto err_out_parse_error;
tmp = atoi(token[0]);
if (tmp < CODEC_CFG_MIN)
if (tmp < codec_cfg_min)
goto err_out_release_num;
codecs_conf_release = tmp;
while ((tmp = get_token(1, 1)) == RET_EOL)
@ -685,13 +681,13 @@ int parse_codec_cfg(const char *cfgfile)
}
if (!validate_codec(codec, codec_type))
goto err_out_not_valid;
mp_tmsg(MSGT_CODECCFG,MSGL_INFO,"%d audio & %d video codecs\n", nr_acodecs, nr_vcodecs);
mp_tmsg(MSGT_CODECCFG, MSGL_V, "%d audio & %d video codecs\n", nr_acodecs,
nr_vcodecs);
if(video_codecs) video_codecs[nr_vcodecs].name = NULL;
if(audio_codecs) audio_codecs[nr_acodecs].name = NULL;
out:
free(line);
talloc_free(tmpmem);
line=NULL;
fclose(fp);
return 1;
err_out_parse_error:
@ -701,10 +697,9 @@ err_out_print_linenum:
err_out:
codecs_uninit_free();
free(line);
talloc_free(tmpmem);
line=NULL;
line_num = 0;
fclose(fp);
return 0;
err_out_not_valid:
mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Codec is not defined correctly.");
@ -848,337 +843,3 @@ void list_codecs(int audioflag){
mp_msg(MSGT_CODECCFG,MSGL_INFO,"%-11s %-9s %s %s\n",c->name,c->drv,s,c->info);
}
}
#ifdef CODECS2HTML
static void wrapline(FILE *f2,char *s){
int c;
if(!s){
fprintf(f2,"-");
return;
}
while((c=*s++)){
if(c==',') fprintf(f2,"<br>"); else fputc(c,f2);
}
}
static void parsehtml(FILE *f1,FILE *f2,codecs_t *codec){
int c,d;
while((c=fgetc(f1))>=0){
if(c!='%'){
fputc(c,f2);
continue;
}
d=fgetc(f1);
switch(d){
case '.':
return; // end of section
case 'n':
wrapline(f2,codec->name); break;
case 'i':
wrapline(f2,codec->info); break;
case 'c':
wrapline(f2,codec->comment); break;
case 'd':
wrapline(f2,codec->dll); break;
case 'D':
fprintf(f2,"%c",!strcmp(codec->drv,"dshow")?'+':'-'); break;
case 'F':
for(d=0;d<CODECS_MAX_FOURCC;d++)
if(!d || codec->fourcc[d]!=0xFFFFFFFF)
fprintf(f2,"%s%.4s",d?"<br>":"",(codec->fourcc[d]==0xFFFFFFFF || codec->fourcc[d]<0x20202020)?!d?"-":"":(char*) &codec->fourcc[d]);
break;
case 'f':
for(d=0;d<CODECS_MAX_FOURCC;d++)
if(codec->fourcc[d]!=0xFFFFFFFF)
fprintf(f2,"%s0x%X",d?"<br>":"",codec->fourcc[d]);
break;
case 'Y':
for(d=0;d<CODECS_MAX_OUTFMT;d++)
if(codec->outfmt[d]!=0xFFFFFFFF){
for (c=0; fmt_table[c].name; c++)
if(fmt_table[c].num==codec->outfmt[d]) break;
if(fmt_table[c].name)
fprintf(f2,"%s%s",d?"<br>":"",fmt_table[c].name);
}
break;
default:
fputc(c,f2);
fputc(d,f2);
}
}
}
void skiphtml(FILE *f1){
int c,d;
while((c=fgetc(f1))>=0){
if(c!='%'){
continue;
}
d=fgetc(f1);
if(d=='.') return; // end of section
}
}
static void print_int_array(const unsigned int* a, int size)
{
printf("{ ");
while (size--)
if(abs(*a)<256)
printf("%d%s", *a++, size?", ":"");
else
printf("0x%X%s", *a++, size?", ":"");
printf(" }");
}
static void print_char_array(const unsigned char* a, int size)
{
printf("{ ");
while (size--)
if((*a)<10)
printf("%d%s", *a++, size?", ":"");
else
printf("0x%02x%s", *a++, size?", ":"");
printf(" }");
}
static void print_string(const char* s)
{
if (!s) printf("NULL");
else printf("\"%s\"", s);
}
int main(int argc, char* argv[])
{
codecs_t *cl;
FILE *f1;
FILE *f2;
int c,d,i;
int pos;
int section=-1;
int nr_codecs;
int win32=-1;
int dshow=-1;
int win32ex=-1;
/*
* Take path to codecs.conf from command line, or fall back on
* etc/codecs.conf
*/
if (!(nr_codecs = parse_codec_cfg((argc>1)?argv[1]:"etc/codecs.conf")))
exit(1);
if (codecs_conf_release < CODEC_CFG_MIN)
exit(1);
if (argc > 1) {
int i, j;
const char* nm[2];
codecs_t* cod[2];
int nr[2];
nm[0] = "builtin_video_codecs";
cod[0] = video_codecs;
nr[0] = nr_vcodecs;
nm[1] = "builtin_audio_codecs";
cod[1] = audio_codecs;
nr[1] = nr_acodecs;
printf("/* GENERATED FROM %s, DO NOT EDIT! */\n\n",argv[1]);
printf("#include <stddef.h>\n");
printf("#include \"codec-cfg.h\"\n\n");
printf("#define CODEC_CFG_MIN %i\n\n", codecs_conf_release);
for (i=0; i<2; i++) {
printf("const codecs_t %s[] = {\n", nm[i]);
for (j = 0; j < nr[i]; j++) {
printf("{");
print_int_array(cod[i][j].fourcc, CODECS_MAX_FOURCC);
printf(", /* fourcc */\n");
print_int_array(cod[i][j].fourccmap, CODECS_MAX_FOURCC);
printf(", /* fourccmap */\n");
print_int_array(cod[i][j].outfmt, CODECS_MAX_OUTFMT);
printf(", /* outfmt */\n");
print_char_array(cod[i][j].outflags, CODECS_MAX_OUTFMT);
printf(", /* outflags */\n");
print_int_array(cod[i][j].infmt, CODECS_MAX_INFMT);
printf(", /* infmt */\n");
print_char_array(cod[i][j].inflags, CODECS_MAX_INFMT);
printf(", /* inflags */\n");
print_string(cod[i][j].name); printf(", /* name */\n");
print_string(cod[i][j].info); printf(", /* info */\n");
print_string(cod[i][j].comment); printf(", /* comment */\n");
print_string(cod[i][j].dll); printf(", /* dll */\n");
print_string(cod[i][j].drv); printf(", /* drv */\n");
printf("{ 0x%08lx, %hu, %hu,",
cod[i][j].guid.f1,
cod[i][j].guid.f2,
cod[i][j].guid.f3);
print_char_array(cod[i][j].guid.f4, sizeof(cod[i][j].guid.f4));
printf(" }, /* GUID */\n");
printf("%hd /* flags */, %hd /* status */, %hd /* cpuflags */ }\n",
cod[i][j].flags,
cod[i][j].status,
cod[i][j].cpuflags);
if (j < nr[i]) printf(",\n");
}
printf("};\n\n");
}
exit(0);
}
f1=fopen("DOCS/tech/codecs-in.html","rb"); if(!f1) exit(1);
f2=fopen("DOCS/codecs-status.html","wb"); if(!f2) exit(1);
while((c=fgetc(f1))>=0){
if(c!='%'){
fputc(c,f2);
continue;
}
d=fgetc(f1);
if(d>='0' && d<='9'){
// begin section
section=d-'0';
//printf("BEGIN %d\n",section);
if(section>=5){
// audio
cl = audio_codecs;
nr_codecs = nr_acodecs;
dshow=7;win32=4;
} else {
// video
cl = video_codecs;
nr_codecs = nr_vcodecs;
dshow=4;win32=2;win32ex=6;
}
pos=ftell(f1);
for(i=0;i<nr_codecs;i++){
fseek(f1,pos,SEEK_SET);
switch(section){
case 0:
case 5:
if(cl[i].status==CODECS_STATUS_WORKING)
// if(!(!strcmp(cl[i].drv,"vfw") || !strcmp(cl[i].drv,"dshow") || !strcmp(cl[i].drv,"vfwex") || !strcmp(cl[i].drv,"acm")))
parsehtml(f1,f2,&cl[i]);
break;
#if 0
case 1:
case 6:
if(cl[i].status==CODECS_STATUS_WORKING)
if((!strcmp(cl[i].drv,"vfw") || !strcmp(cl[i].drv,"dshow") || !strcmp(cl[i].drv,"vfwex") || !strcmp(cl[i].drv,"acm")))
parsehtml(f1,f2,&cl[i]);
break;
#endif
case 2:
case 7:
if(cl[i].status==CODECS_STATUS_PROBLEMS)
parsehtml(f1,f2,&cl[i]);
break;
case 3:
case 8:
if(cl[i].status==CODECS_STATUS_NOT_WORKING)
parsehtml(f1,f2,&cl[i]);
break;
case 4:
case 9:
if(cl[i].status==CODECS_STATUS_UNTESTED)
parsehtml(f1,f2,&cl[i]);
break;
default:
printf("Warning! unimplemented section: %d\n",section);
}
}
fseek(f1,pos,SEEK_SET);
skiphtml(f1);
continue;
}
fputc(c,f2);
fputc(d,f2);
}
fclose(f2);
fclose(f1);
return 0;
}
#endif
#ifdef TESTING
int main(void)
{
codecs_t *c;
int i,j, nr_codecs, state;
if (!(parse_codec_cfg("etc/codecs.conf")))
return 0;
if (!video_codecs)
printf("no videoconfig.\n");
if (!audio_codecs)
printf("no audioconfig.\n");
printf("videocodecs:\n");
c = video_codecs;
nr_codecs = nr_vcodecs;
state = 0;
next:
if (c) {
printf("number of %scodecs: %d\n", state==0?"video":"audio",
nr_codecs);
for(i=0;i<nr_codecs;i++, c++){
printf("\n============== %scodec %02d ===============\n",
state==0?"video":"audio",i);
printf("name='%s'\n",c->name);
printf("info='%s'\n",c->info);
printf("comment='%s'\n",c->comment);
printf("dll='%s'\n",c->dll);
/* printf("flags=%X driver=%d status=%d cpuflags=%d\n",
c->flags, c->driver, c->status, c->cpuflags); */
printf("flags=%X status=%d cpuflags=%d\n",
c->flags, c->status, c->cpuflags);
for(j=0;j<CODECS_MAX_FOURCC;j++){
if(c->fourcc[j]!=0xFFFFFFFF){
printf("fourcc %02d: %08X (%.4s) ===> %08X (%.4s)\n",j,c->fourcc[j],(char *) &c->fourcc[j],c->fourccmap[j],(char *) &c->fourccmap[j]);
}
}
for(j=0;j<CODECS_MAX_OUTFMT;j++){
if(c->outfmt[j]!=0xFFFFFFFF){
printf("outfmt %02d: %08X (%.4s) flags: %d\n",j,c->outfmt[j],(char *) &c->outfmt[j],c->outflags[j]);
}
}
for(j=0;j<CODECS_MAX_INFMT;j++){
if(c->infmt[j]!=0xFFFFFFFF){
printf("infmt %02d: %08X (%.4s) flags: %d\n",j,c->infmt[j],(char *) &c->infmt[j],c->inflags[j]);
}
}
printf("GUID: %08lX %04X %04X",c->guid.f1,c->guid.f2,c->guid.f3);
for(j=0;j<8;j++) printf(" %02X",c->guid.f4[j]);
printf("\n");
}
}
if (!state) {
printf("audiocodecs:\n");
c = audio_codecs;
nr_codecs = nr_acodecs;
state = 1;
goto next;
}
return 0;
}
#endif

10
configure vendored
View File

@ -471,7 +471,6 @@ Miscellaneous options:
--enable-runtime-cpudetection enable runtime CPU detection [disable]
--enable-cross-compile enable cross-compilation [disable]
--cc=COMPILER C compiler to build MPlayer [gcc]
--host-cc=COMPILER C compiler for tools needed while building [gcc]
--as=ASSEMBLER assembler to build MPlayer [as]
--nm=NM nm tool to build MPlayer [nm]
--yasm=YASM Yasm assembler to build MPlayer [yasm]
@ -774,9 +773,6 @@ for ac_option do
--cc=*)
_cc=$(echo $ac_option | cut -d '=' -f 2)
;;
--host-cc=*)
_host_cc=$(echo $ac_option | cut -d '=' -f 2)
;;
--as=*)
_as=$(echo $ac_option | cut -d '=' -f 2)
;;
@ -1207,7 +1203,6 @@ if test $_cross_compile = yes; then
tmp_run() {
return 0
}
test "$_host_cc" || _host_cc=cc
fi
tool_prefix=""
@ -1471,10 +1466,6 @@ EOF
cc_check && host_arch=x86_64 || host_arch=i386
fi
echocheck "host cc"
test "$_host_cc" || _host_cc=$_cc
echores $_host_cc
echo "Detected operating system: $system_name"
echo "Detected host architecture: $host_arch"
@ -6239,7 +6230,6 @@ AR = $_ar
AS = $_cc
CC = $_cc
CXX = $_cc
HOST_CC = $_host_cc
INSTALL = $_install
INSTALLSTRIP = $_install_strip
WINDRES = $_windres

View File

@ -3,7 +3,7 @@
; Before editing this file, please read DOCS/tech/codecs.conf.txt !
;=============================================================================
release 20110311
release 20120702
;=============================================================================
; VIDEO CODECS
@ -777,7 +777,7 @@ videocodec ffindeo2
videocodec ffflv
info "FFmpeg Flash video"
status working
fourcc FLV1,flv
fourcc FLV1
driver ffmpeg
dll flv