comparison codec-cfg.c @ 8467:3ca9cc46df5c

Fallback to builtin (generated from etc/codecs.conf at compile time) codecs.conf if no ext configfile found. Based on patch by Sidik Isani <lksi@cfht.hawaii.edu>
author arpi
date Sun, 15 Dec 2002 23:45:19 +0000
parents e371e59dff41
children e241942f6aee
comparison
equal deleted inserted replaced
8466:ab7c1be4ba74 8467:3ca9cc46df5c
29 // for mmioFOURCC: 29 // for mmioFOURCC:
30 #include "wine/avifmt.h" 30 #include "wine/avifmt.h"
31 31
32 #include "libvo/img_format.h" 32 #include "libvo/img_format.h"
33 #include "codec-cfg.h" 33 #include "codec-cfg.h"
34
35 #ifndef CODECS2HTML
36 #include "codecs.conf.h"
37 #endif
34 38
35 #define PRINT_LINENUM mp_msg(MSGT_CODECCFG,MSGL_ERR," at line %d\n", line_num) 39 #define PRINT_LINENUM mp_msg(MSGT_CODECCFG,MSGL_ERR," at line %d\n", line_num)
36 40
37 #define MAX_NR_TOKEN 16 41 #define MAX_NR_TOKEN 16
38 42
478 audio_codecs=NULL; 482 audio_codecs=NULL;
479 483
480 nr_vcodecs = 0; 484 nr_vcodecs = 0;
481 nr_acodecs = 0; 485 nr_acodecs = 0;
482 486
483 if(cfgfile==NULL)return 0; 487 if(cfgfile==NULL) {
488 #ifdef CODECS2HTML
489 return 0;
490 #else
491 video_codecs = builtin_video_codecs;
492 audio_codecs = builtin_audio_codecs;
493 nr_vcodecs = sizeof(builtin_video_codecs)/sizeof(codecs_t) - 1;
494 nr_acodecs = sizeof(builtin_audio_codecs)/sizeof(codecs_t) - 1;
495 return 1;
496 #endif
497 }
484 498
485 mp_msg(MSGT_CODECCFG,MSGL_INFO,"Reading %s: ", cfgfile); 499 mp_msg(MSGT_CODECCFG,MSGL_INFO,"Reading %s: ", cfgfile);
486 500
487 if ((fp = fopen(cfgfile, "r")) == NULL) { 501 if ((fp = fopen(cfgfile, "r")) == NULL) {
488 mp_msg(MSGT_CODECCFG,MSGL_ERR,"can't open '%s': %s\n", cfgfile, strerror(errno)); 502 mp_msg(MSGT_CODECCFG,MSGL_ERR,"can't open '%s': %s\n", cfgfile, strerror(errno));
907 d=fgetc(f1); 921 d=fgetc(f1);
908 if(d=='.') return; // end of section 922 if(d=='.') return; // end of section
909 } 923 }
910 } 924 }
911 925
912 int main(void) 926 static void print_int_array(const int* a, int size)
927 {
928 printf("{ ");
929 while (size--)
930 if(abs(*a)<256)
931 printf("%d%s", *a++, size?", ":"");
932 else
933 printf("0x%X%s", *a++, size?", ":"");
934 printf(" }");
935 }
936
937 static void print_char_array(const unsigned char* a, int size)
938 {
939 printf("{ ");
940 while (size--)
941 if((*a)<10)
942 printf("%d%s", *a++, size?", ":"");
943 else
944 printf("0x%02x%s", *a++, size?", ":"");
945 printf(" }");
946 }
947
948 static void print_string(const char* s)
949 {
950 if (!s) printf("NULL");
951 else printf("\"%s\"", s);
952 }
953
954 int main(int argc, char* argv[])
913 { 955 {
914 codecs_t *cl; 956 codecs_t *cl;
915 FILE *f1; 957 FILE *f1;
916 FILE *f2; 958 FILE *f2;
917 int c,d,i; 959 int c,d,i;
920 int nr_codecs; 962 int nr_codecs;
921 int win32=-1; 963 int win32=-1;
922 int dshow=-1; 964 int dshow=-1;
923 int win32ex=-1; 965 int win32ex=-1;
924 966
925 if (!(nr_codecs = parse_codec_cfg("etc/codecs.conf"))) 967 /*
926 return 0; 968 * Take path to codecs.conf from command line, or fall back on
969 * etc/codecs.conf
970 */
971 if (!(nr_codecs = parse_codec_cfg((argc>1)?argv[1]:"etc/codecs.conf")))
972 exit(1);
973
974 if (argc > 1) {
975 int i, j;
976 const char* nm[2];
977 codecs_t* cod[2];
978 int nr[2];
979
980 nm[0] = "builtin_video_codecs";
981 cod[0] = video_codecs;
982 nr[0] = nr_vcodecs;
983
984 nm[1] = "builtin_audio_codecs";
985 cod[1] = audio_codecs;
986 nr[1] = nr_acodecs;
987
988 printf("/* GENERATED FROM %s, DO NOT EDIT! */\n\n",argv[1]);
989
990 for (i=0; i<2; i++) {
991 printf("codecs_t %s[] = {\n", nm[i]);
992 for (j = 0; j <= nr[i]; j++) {
993 printf("{");
994
995 print_int_array(cod[i][j].fourcc, CODECS_MAX_FOURCC);
996 printf(", /* fourcc */\n");
997
998 print_int_array(cod[i][j].fourccmap, CODECS_MAX_FOURCC);
999 printf(", /* fourccmap */\n");
1000
1001 print_int_array(cod[i][j].outfmt, CODECS_MAX_OUTFMT);
1002 printf(", /* outfmt */\n");
1003
1004 print_char_array(cod[i][j].outflags, CODECS_MAX_OUTFMT);
1005 printf(", /* outflags */\n");
1006
1007 print_int_array(cod[i][j].infmt, CODECS_MAX_INFMT);
1008 printf(", /* infmt */\n");
1009
1010 print_char_array(cod[i][j].inflags, CODECS_MAX_INFMT);
1011 printf(", /* inflags */\n");
1012
1013 print_string(cod[i][j].name); printf(", /* name */\n");
1014 print_string(cod[i][j].info); printf(", /* info */\n");
1015 print_string(cod[i][j].comment); printf(", /* comment */\n");
1016 print_string(cod[i][j].dll); printf(", /* dll */\n");
1017 print_string(cod[i][j].drv); printf(", /* drv */\n");
1018
1019 printf("{ 0x%08lx, %hu, %hu,",
1020 cod[i][j].guid.f1,
1021 cod[i][j].guid.f2,
1022 cod[i][j].guid.f3);
1023 print_char_array(cod[i][j].guid.f4, sizeof(cod[i][j].guid.f4));
1024 printf(" }, /* GUID */\n");
1025 printf("%hd /* flags */, %hd /* status */, %hd /* cpuflags */ }\n",
1026 cod[i][j].flags,
1027 cod[i][j].status,
1028 cod[i][j].cpuflags);
1029 if (j < nr[i]) printf(",\n");
1030 }
1031 printf("};\n\n");
1032 }
1033 exit(0);
1034 }
927 1035
928 f1=fopen("DOCS/codecs-in.html","rb"); if(!f1) exit(1); 1036 f1=fopen("DOCS/codecs-in.html","rb"); if(!f1) exit(1);
929 f2=fopen("DOCS/codecs-status.html","wb"); if(!f2) exit(1); 1037 f2=fopen("DOCS/codecs-status.html","wb"); if(!f2) exit(1);
930 1038
931 while((c=fgetc(f1))>=0){ 1039 while((c=fgetc(f1))>=0){