diff options
Diffstat (limited to 'codec-cfg.c')
-rw-r--r-- | codec-cfg.c | 215 |
1 files changed, 108 insertions, 107 deletions
diff --git a/codec-cfg.c b/codec-cfg.c index 0828e0ea53..168529fd8c 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 @@ -51,10 +53,6 @@ #endif #endif -#include "help_mp.h" - -// for mmioFOURCC: -#include "libmpdemux/aviheader.h" #include "libmpcodecs/img_format.h" #include "codec-cfg.h" @@ -63,6 +61,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 +109,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 +128,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,82 +149,82 @@ 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; } return 1; } - static const struct { - const char *name; - const unsigned int num; - } fmt_table[] = { - // note: due to parser deficiencies/simplicity, if one format - // name matches the beginning of another, the longer one _must_ - // come first in this list. - {"YV12", IMGFMT_YV12}, - {"I420", IMGFMT_I420}, - {"IYUV", IMGFMT_IYUV}, - {"NV12", IMGFMT_NV12}, - {"NV21", IMGFMT_NV21}, - {"YVU9", IMGFMT_YVU9}, - {"IF09", IMGFMT_IF09}, - {"444P16LE", IMGFMT_444P16_LE}, - {"444P16BE", IMGFMT_444P16_BE}, - {"422P16LE", IMGFMT_422P16_LE}, - {"422P16BE", IMGFMT_422P16_BE}, - {"420P16LE", IMGFMT_420P16_LE}, - {"420P16BE", IMGFMT_420P16_BE}, - {"444P16", IMGFMT_444P16}, - {"422P16", IMGFMT_422P16}, - {"420P16", IMGFMT_420P16}, - {"420A", IMGFMT_420A}, - {"444P", IMGFMT_444P}, - {"422P", IMGFMT_422P}, - {"411P", IMGFMT_411P}, - {"440P", IMGFMT_440P}, - {"Y800", IMGFMT_Y800}, - {"Y8", IMGFMT_Y8}, - - {"YUY2", IMGFMT_YUY2}, - {"UYVY", IMGFMT_UYVY}, - {"YVYU", IMGFMT_YVYU}, - - {"RGB48LE", IMGFMT_RGB48LE}, - {"RGB48BE", IMGFMT_RGB48BE}, - {"RGB4", IMGFMT_RGB4}, - {"RGB8", IMGFMT_RGB8}, - {"RGB15", IMGFMT_RGB15}, - {"RGB16", IMGFMT_RGB16}, - {"RGB24", IMGFMT_RGB24}, - {"RGB32", IMGFMT_RGB32}, - {"BGR4", IMGFMT_BGR4}, - {"BGR8", IMGFMT_BGR8}, - {"BGR15", IMGFMT_BGR15}, - {"BGR16", IMGFMT_BGR16}, - {"BGR24", IMGFMT_BGR24}, - {"BGR32", IMGFMT_BGR32}, - {"RGB1", IMGFMT_RGB1}, - {"BGR1", IMGFMT_BGR1}, - - {"MPES", IMGFMT_MPEGPES}, - {"ZRMJPEGNI", IMGFMT_ZRMJPEGNI}, - {"ZRMJPEGIT", IMGFMT_ZRMJPEGIT}, - {"ZRMJPEGIB", IMGFMT_ZRMJPEGIB}, - - {"IDCT_MPEG2",IMGFMT_XVMC_IDCT_MPEG2}, - {"MOCO_MPEG2",IMGFMT_XVMC_MOCO_MPEG2}, - - {"VDPAU_MPEG1",IMGFMT_VDPAU_MPEG1}, - {"VDPAU_MPEG2",IMGFMT_VDPAU_MPEG2}, - {"VDPAU_H264",IMGFMT_VDPAU_H264}, - {"VDPAU_WMV3",IMGFMT_VDPAU_WMV3}, - {"VDPAU_VC1",IMGFMT_VDPAU_VC1}, - {"VDPAU_MPEG4",IMGFMT_VDPAU_MPEG4}, - - {NULL, 0} - }; +static const struct { + const char *name; + const unsigned int num; +} fmt_table[] = { + // note: due to parser deficiencies/simplicity, if one format + // name matches the beginning of another, the longer one _must_ + // come first in this list. + {"YV12", IMGFMT_YV12}, + {"I420", IMGFMT_I420}, + {"IYUV", IMGFMT_IYUV}, + {"NV12", IMGFMT_NV12}, + {"NV21", IMGFMT_NV21}, + {"YVU9", IMGFMT_YVU9}, + {"IF09", IMGFMT_IF09}, + {"444P16LE", IMGFMT_444P16_LE}, + {"444P16BE", IMGFMT_444P16_BE}, + {"422P16LE", IMGFMT_422P16_LE}, + {"422P16BE", IMGFMT_422P16_BE}, + {"420P16LE", IMGFMT_420P16_LE}, + {"420P16BE", IMGFMT_420P16_BE}, + {"444P16", IMGFMT_444P16}, + {"422P16", IMGFMT_422P16}, + {"420P16", IMGFMT_420P16}, + {"420A", IMGFMT_420A}, + {"444P", IMGFMT_444P}, + {"422P", IMGFMT_422P}, + {"411P", IMGFMT_411P}, + {"440P", IMGFMT_440P}, + {"Y800", IMGFMT_Y800}, + {"Y8", IMGFMT_Y8}, + + {"YUY2", IMGFMT_YUY2}, + {"UYVY", IMGFMT_UYVY}, + {"YVYU", IMGFMT_YVYU}, + + {"RGB48LE", IMGFMT_RGB48LE}, + {"RGB48BE", IMGFMT_RGB48BE}, + {"RGB4", IMGFMT_RGB4}, + {"RGB8", IMGFMT_RGB8}, + {"RGB15", IMGFMT_RGB15}, + {"RGB16", IMGFMT_RGB16}, + {"RGB24", IMGFMT_RGB24}, + {"RGB32", IMGFMT_RGB32}, + {"BGR4", IMGFMT_BGR4}, + {"BGR8", IMGFMT_BGR8}, + {"BGR15", IMGFMT_BGR15}, + {"BGR16", IMGFMT_BGR16}, + {"BGR24", IMGFMT_BGR24}, + {"BGR32", IMGFMT_BGR32}, + {"RGB1", IMGFMT_RGB1}, + {"BGR1", IMGFMT_BGR1}, + + {"MPES", IMGFMT_MPEGPES}, + {"ZRMJPEGNI", IMGFMT_ZRMJPEGNI}, + {"ZRMJPEGIT", IMGFMT_ZRMJPEGIT}, + {"ZRMJPEGIB", IMGFMT_ZRMJPEGIB}, + + {"IDCT_MPEG2",IMGFMT_XVMC_IDCT_MPEG2}, + {"MOCO_MPEG2",IMGFMT_XVMC_MOCO_MPEG2}, + + {"VDPAU_MPEG1",IMGFMT_VDPAU_MPEG1}, + {"VDPAU_MPEG2",IMGFMT_VDPAU_MPEG2}, + {"VDPAU_H264",IMGFMT_VDPAU_H264}, + {"VDPAU_WMV3",IMGFMT_VDPAU_WMV3}, + {"VDPAU_VC1",IMGFMT_VDPAU_VC1}, + {"VDPAU_MPEG4",IMGFMT_VDPAU_MPEG4}, + + {NULL, 0} +}; static int add_to_inout(char *sfmt, char *sflags, unsigned int *outfmt, @@ -284,10 +286,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 +370,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 +379,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; } @@ -391,8 +393,8 @@ static int validate_codec(codecs_t *c, int type) #warning codec->driver == 4;... <- this should not be put in here... #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); + (c->driver == 2 && type == TYPE_VIDEO))) { + 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 +402,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 +420,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 +469,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 +553,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 +619,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 +634,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 +670,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")) { @@ -716,8 +718,7 @@ int parse_codec_cfg(const char *cfgfile) goto err_out_parse_error; if (!strcmp(token[0], "seekable")) codec->flags |= CODECS_FLAG_SEEKABLE; - else - if (!strcmp(token[0], "align16")) + else if (!strcmp(token[0], "align16")) codec->flags |= CODECS_FLAG_ALIGN16; else goto err_out_parse_error; @@ -744,7 +745,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 +755,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 +767,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; } @@ -1049,8 +1050,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]); |