diff options
Diffstat (limited to 'codec-cfg.c')
-rw-r--r-- | codec-cfg.c | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/codec-cfg.c b/codec-cfg.c index 5d796275ce..ae84af4c1a 100644 --- a/codec-cfg.c +++ b/codec-cfg.c @@ -40,10 +40,12 @@ #include <ctype.h> #include <assert.h> #include <string.h> +#include <stdint.h> #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 @@ -53,9 +55,6 @@ #include "help_mp.h" -// for mmioFOURCC: -#include "libmpdemux/aviheader.h" - #include "libmpcodecs/img_format.h" #include "codec-cfg.h" @@ -63,6 +62,10 @@ #include "codecs.conf.h" #endif +#define mmioFOURCC( ch0, ch1, ch2, ch3 ) \ + ( (uint32_t)(uint8_t)(ch0) | ( (uint32_t)(uint8_t)(ch1) << 8 ) | \ + ( (uint32_t)(uint8_t)(ch2) << 16 ) | ( (uint32_t)(uint8_t)(ch3) << 24 ) ) + #define PRINT_LINENUM mp_msg(MSGT_CODECCFG,MSGL_ERR," at line %d\n", line_num) #define MAX_NR_TOKEN 16 @@ -107,13 +110,13 @@ static int add_to_fourcc(char *s, char *alias, unsigned int *fourcc, goto err_out_parse_error; return 1; err_out_duplicated: - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_DuplicateFourcc); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"duplicated FourCC"); return 0; err_out_too_many: - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_TooManyFourccs); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"too many FourCCs/formats..."); return 0; err_out_parse_error: - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_ParseError); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"parse error"); return 0; } @@ -126,20 +129,20 @@ static int add_to_format(char *s, char *alias,unsigned int *fourcc, unsigned int for (i = 0; i < CODECS_MAX_FOURCC && fourcc[i] != 0xffffffff; i++) /* NOTHING */; if (i == CODECS_MAX_FOURCC) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_TooManyFourccs); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"too many FourCCs/formats..."); return 0; } fourcc[i]=strtoul(s,&endptr,0); if (*endptr != '\0') { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_ParseErrorFIDNotNumber); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"parse error (format ID not a number?)"); return 0; } if(alias){ fourccmap[i]=strtoul(alias,&endptr,0); if (*endptr != '\0') { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_ParseErrorFIDAliasNotNumber); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"parse error (format ID alias not a number?)"); return 0; } } else @@ -147,7 +150,7 @@ static int add_to_format(char *s, char *alias,unsigned int *fourcc, unsigned int for (j = 0; j < i; j++) if (fourcc[j] == fourcc[i]) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_DuplicateFID); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"duplicated format ID"); return 0; } @@ -219,7 +222,7 @@ static int add_to_format(char *s, char *alias,unsigned int *fourcc, unsigned int {"VDPAU_H264",IMGFMT_VDPAU_H264}, {"VDPAU_WMV3",IMGFMT_VDPAU_WMV3}, {"VDPAU_VC1",IMGFMT_VDPAU_VC1}, - {"VDPAU_MPEG4",IMGFMT_VDPAU_MPEG4}, + {"VDPAU_MPEG4",IMGFMT_VDPAU_MPEG4}, {NULL, 0} }; @@ -284,10 +287,10 @@ static int add_to_inout(char *sfmt, char *sflags, unsigned int *outfmt, return 1; err_out_too_many: - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_TooManyOut); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"too many out..."); return 0; err_out_parse_error: - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_ParseError); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"parse error"); return 0; } @@ -368,7 +371,7 @@ static int validate_codec(codecs_t *c, int type) /* NOTHING */; if (i < strlen(tmp_name)) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_InvalidCodecName, c->name); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) name is not valid!\n", c->name); return 0; } @@ -377,13 +380,13 @@ static int validate_codec(codecs_t *c, int type) #if 0 if (c->fourcc[0] == 0xffffffff) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecLacksFourcc, c->name); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) does not have FourCC/format!\n", c->name); return 0; } #endif if (!c->drv) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecLacksDriver, c->name); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) does not have a driver!\n", c->name); return 0; } @@ -392,7 +395,7 @@ static int validate_codec(codecs_t *c, int type) #warning Where are they defined ???????????? if (!c->dll && (c->driver == 4 || (c->driver == 2 && type == TYPE_VIDEO))) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecNeedsDLL, c->name); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) needs a 'dll'!\n", c->name); return 0; } #warning Can guid.f1 be 0? How does one know that it was not given? @@ -400,7 +403,7 @@ static int validate_codec(codecs_t *c, int type) if (type == TYPE_VIDEO) if (c->outfmt[0] == 0xffffffff) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecNeedsOutfmt, c->name); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"\ncodec(%s) needs an 'outfmt'!\n", c->name); return 0; } #endif @@ -418,7 +421,7 @@ static int add_comment(char *s, char **d) (*d)[pos++] = '\n'; } if (!(*d = realloc(*d, pos + strlen(s) + 1))) { - mp_msg(MSGT_CODECCFG,MSGL_FATAL,MSGTR_CantAllocateComment); + mp_tmsg(MSGT_CODECCFG,MSGL_FATAL,"Can't allocate memory for comment. "); return 0; } strcpy(*d + pos, s); @@ -467,7 +470,7 @@ static int get_token(int min, int max) char c; if (max >= MAX_NR_TOKEN) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_GetTokenMaxNotLessThanMAX_NR_TOKEN); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"get_token(): max >= MAX_MR_TOKEN!"); goto out_eof; } @@ -551,15 +554,15 @@ int parse_codec_cfg(const char *cfgfile) #endif } - mp_msg(MSGT_CODECCFG,MSGL_V,MSGTR_ReadingFile, cfgfile); + mp_tmsg(MSGT_CODECCFG,MSGL_V,"Reading %s: ", cfgfile); if ((fp = fopen(cfgfile, "r")) == NULL) { - mp_msg(MSGT_CODECCFG,MSGL_V,MSGTR_CantOpenFileError, cfgfile, strerror(errno)); + 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_msg(MSGT_CODECCFG,MSGL_FATAL,MSGTR_CantGetMemoryForLine, strerror(errno)); + mp_tmsg(MSGT_CODECCFG,MSGL_FATAL,"Can't get memory for 'line': %s\n", strerror(errno)); return 0; } read_nextline = 1; @@ -617,7 +620,7 @@ int parse_codec_cfg(const char *cfgfile) } if (!(*codecsp = realloc(*codecsp, sizeof(codecs_t) * (*nr_codecsp + 2)))) { - mp_msg(MSGT_CODECCFG,MSGL_FATAL,MSGTR_CantReallocCodecsp, strerror(errno)); + mp_tmsg(MSGT_CODECCFG,MSGL_FATAL,"Can't realloc '*codecsp': %s\n", strerror(errno)); goto err_out; } codec=*codecsp + *nr_codecsp; @@ -632,19 +635,19 @@ int parse_codec_cfg(const char *cfgfile) for (i = 0; i < *nr_codecsp - 1; i++) { if(( (*codecsp)[i].name!=NULL) && (!strcmp(token[0], (*codecsp)[i].name)) ) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecNameNotUnique, token[0]); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Codec name '%s' isn't unique.", token[0]); goto err_out_print_linenum; } } if (!(codec->name = strdup(token[0]))) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CantStrdupName, strerror(errno)); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Can't strdup -> 'name': %s\n", strerror(errno)); goto err_out; } } else if (!strcmp(token[0], "info")) { if (codec->info || get_token(1, 1) < 0) goto err_out_parse_error; if (!(codec->info = strdup(token[0]))) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CantStrdupInfo, strerror(errno)); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Can't strdup -> 'info': %s\n", strerror(errno)); goto err_out; } } else if (!strcmp(token[0], "comment")) { @@ -668,14 +671,14 @@ int parse_codec_cfg(const char *cfgfile) if (get_token(1, 1) < 0) goto err_out_parse_error; if (!(codec->drv = strdup(token[0]))) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CantStrdupDriver, strerror(errno)); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Can't strdup -> 'driver': %s\n", strerror(errno)); goto err_out; } } else if (!strcmp(token[0], "dll")) { if (get_token(1, 1) < 0) goto err_out_parse_error; if (!(codec->dll = strdup(token[0]))) { - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CantStrdupDLL, strerror(errno)); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Can't strdup -> 'dll': %s", strerror(errno)); goto err_out; } } else if (!strcmp(token[0], "guid")) { @@ -744,7 +747,7 @@ int parse_codec_cfg(const char *cfgfile) } if (!validate_codec(codec, codec_type)) goto err_out_not_valid; - mp_msg(MSGT_CODECCFG,MSGL_INFO,MSGTR_AudioVideoCodecTotals, nr_acodecs, nr_vcodecs); + mp_tmsg(MSGT_CODECCFG,MSGL_INFO,"%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: @@ -754,7 +757,7 @@ out: return 1; err_out_parse_error: - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_ParseError); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"parse error"); err_out_print_linenum: PRINT_LINENUM; err_out: @@ -766,10 +769,10 @@ err_out: fclose(fp); return 0; err_out_not_valid: - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_CodecDefinitionIncorrect); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"Codec is not defined correctly."); goto err_out_print_linenum; err_out_release_num: - mp_msg(MSGT_CODECCFG,MSGL_ERR,MSGTR_OutdatedCodecsConf); + mp_tmsg(MSGT_CODECCFG,MSGL_ERR,"This codecs.conf is too old and incompatible with this MPlayer release!"); goto err_out_print_linenum; } @@ -1053,8 +1056,8 @@ int main(int argc, char* argv[]) nr[1] = nr_acodecs; printf("/* GENERATED FROM %s, DO NOT EDIT! */\n\n",argv[1]); - printf("#include <stddef.h>\n",argv[1]); - printf("#include \"codec-cfg.h\"\n\n",argv[1]); + printf("#include <stddef.h>\n"); + printf("#include \"codec-cfg.h\"\n\n"); for (i=0; i<2; i++) { printf("const codecs_t %s[] = {\n", nm[i]); |