[MPlayer-dev-eng] [PATCH] codec-cfg.c fallbacks
Sidik Isani
lksi at cfht.hawaii.edu
Mon Nov 11 05:02:01 CET 2002
Hello -
Here's something which makes it possible to test CVS
versions of mplayer on a stable system without swapping
codecs.conf around (not even the one in $HOME). If no
suitable codecs.conf is found, instead of exiting, mplayer
uses a compiled-in version of "etc/codecs.conf" from the
source directory at the time it was built. Since it
was going to give up and exit anyway, this shouldn't break
anything. Though we may still want/need a strong warning
reminding the user they are running an "uninstalled" version?
The built-in codecs do not need to be maintained. The
makefile will generate them from the config file using
the "codec-cfg" utility automatically. The previous patch
I just posted has to be applied to get codec-cfg working
again first.
Be seeing you,
- Sidik
-------------- next part --------------
diff -ru MPlayer-cvs-pre10.DIST/Makefile MPlayer-cvs-pre10/Makefile
--- MPlayer-cvs-pre10.DIST/Makefile Sun Nov 10 13:44:39 2002
+++ MPlayer-cvs-pre10/Makefile Sun Nov 10 03:12:34 2002
@@ -10,6 +10,8 @@
PRG_FIBMAP = fibmap_mplayer
PRG_CFG = codec-cfg
PRG_MENCODER = mencoder
+CFG_FILE = ./etc/codecs.conf # Location of uninstalled config file.
+CFG_FALLBACK = cfg-fallback.h # Generated from CFG_FILE
# Do not strip the binaries at installation
ifeq ($(STRIPBINARIES),yes)
@@ -212,6 +214,11 @@
$(PRG_CFG): version.h codec-cfg.c codec-cfg.h
$(CC) $(CFLAGS) -g codec-cfg.c mp_msg.c -o $(PRG_CFG) -DCODECS2HTML
+# This uses the configuration program to generate a fallback
+# include file of codecs.conf that matches this version of mplayer.
+$(CFG_FALLBACK): $(PRG_CFG)
+ $< $(CFG_FILE) > $@~ && mv $@~ $@
+
install: $(ALL_PRG)
ifeq ($(VIDIX),yes)
$(DO_MAKE)
@@ -283,7 +290,7 @@
dep: depend
-depend:
+depend: $(CFG_FALLBACK)
./version.sh `$(CC) -dumpversion`
$(CC) -MM $(CFLAGS) mplayer.c mencoder.c $(SRCS_MPLAYER) $(SRCS_MENCODER) 1>.depend
@for a in $(PARTS); do $(MAKE) -C $$a dep; done
diff -ru MPlayer-cvs-pre10.DIST/codec-cfg.c MPlayer-cvs-pre10/codec-cfg.c
--- MPlayer-cvs-pre10.DIST/codec-cfg.c Sun Nov 10 13:45:25 2002
+++ MPlayer-cvs-pre10/codec-cfg.c Sun Nov 10 14:07:27 2002
@@ -32,6 +32,10 @@
#include "libvo/img_format.h"
#include "codec-cfg.h"
+#ifndef CODECS2HTML
+#include "cfg-fallback.h"
+#endif
+
#define PRINT_LINENUM mp_msg(MSGT_CODECCFG,MSGL_ERR," at line %d\n", line_num)
#define MAX_NR_TOKEN 16
@@ -480,7 +484,17 @@
nr_vcodecs = 0;
nr_acodecs = 0;
- if(cfgfile==NULL)return 0;
+ if(cfgfile==NULL) {
+#ifdef CODECS2HTML
+ return 0;
+#else
+ video_codecs = builtin_video_codecs;
+ audio_codecs = builtin_audio_codecs;
+ nr_vcodecs = sizeof(builtin_video_codecs)/sizeof(codecs_t) - 1;
+ nr_acodecs = sizeof(builtin_audio_codecs)/sizeof(codecs_t) - 1;
+ return 1;
+#endif
+ }
mp_msg(MSGT_CODECCFG,MSGL_INFO,"Reading %s: ", cfgfile);
@@ -909,7 +923,27 @@
}
}
-int main(void)
+static void print_int_array(const unsigned int* a, int size)
+{
+ printf("{ ");
+ while (size--) printf("0x%08x%s", *a++, size?", ":"");
+ printf(" }");
+}
+
+static void print_char_array(const unsigned char* a, int size)
+{
+ printf("{ ");
+ while (size--) 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;
@@ -922,8 +956,72 @@
int dshow=-1;
int win32ex=-1;
- if (!(nr_codecs = parse_codec_cfg("etc/codecs.conf")))
- return 0;
+ /*
+ * 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 (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;
+
+ for (i=0; i<2; i++) {
+ printf("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/codecs-in.html","rb"); if(!f1) exit(1);
f2=fopen("DOCS/codecs-status.html","wb"); if(!f2) exit(1);
More information about the MPlayer-dev-eng
mailing list