From a62a42f3f1e597117e6cf99d966fc1ceed105f22 Mon Sep 17 00:00:00 2001 From: arpi Date: Sun, 26 May 2002 22:39:38 +0000 Subject: [PATCH] codecs.conf versioning - patch by Joey Parrish git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6201 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/tech/codecs.conf.txt | 12 ++++++++++++ codec-cfg.c | 28 +++++++++++++++++++++++++--- codec-cfg.h | 2 ++ etc/codecs.conf | 2 ++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/DOCS/tech/codecs.conf.txt b/DOCS/tech/codecs.conf.txt index 1f9c6df700..f52bd991af 100644 --- a/DOCS/tech/codecs.conf.txt +++ b/DOCS/tech/codecs.conf.txt @@ -33,6 +33,18 @@ care. However, they are organized in a particular order for the benefit of human readers. For example, all of the open source decoders that MPlayer implements natively are grouped in one section. +Release Number +-------------- +Your codecs.conf now requires a release number to avoid codec release +incompatibilities. The format is simple: (YYYYMMDD) + +release 20020520 + +Whenever changes are made to the codecs that *require* an updated +codecs.conf, then MPlayer will no longer accept outdated versions. +It is not recommended to change this line unless you know exactly +what you are doing. + Video Codecs ------------ Let's jump right in with an example. Here is an example video codec block: diff --git a/codec-cfg.c b/codec-cfg.c index 981c5421bc..fafedddc41 100644 --- a/codec-cfg.c +++ b/codec-cfg.c @@ -368,10 +368,10 @@ static FILE *fp; static int line_num = 0; static char *line; static char *token[MAX_NR_TOKEN]; +static int read_nextline = 1; static int get_token(int min, int max) { - static int read_nextline = 1; static int line_pos; int i; char c; @@ -466,15 +466,33 @@ int parse_codec_cfg(char *cfgfile) mp_msg(MSGT_CODECCFG,MSGL_FATAL,"can't get memory for 'line': %s\n", strerror(errno)); return 0; } + read_nextline = 1; /* - * check if the cfgfile starts with 'audiocodec' or - * with 'videocodec' + * this only catches release lines at the start of + * codecs.conf, before audiocodecs and videocodecs. */ while ((tmp = get_token(1, 1)) == RET_EOL) /* NOTHING */; if (tmp == RET_EOF) goto out; + if (!strcmp(token[0], "release")) { + if (get_token(1, 2) < 0) + goto err_out_parse_error; + tmp = atoi(token[0]); + if (tmp < CODEC_CFG_MIN) + goto err_out_release_num; + while ((tmp = get_token(1, 1)) == RET_EOL) + /* NOTHING */; + if (tmp == RET_EOF) + goto out; + } else + goto err_out_release_num; + + /* + * check if the next block starts with 'audiocodec' or + * with 'videocodec' + */ if (!strcmp(token[0], "audiocodec") || !strcmp(token[0], "videocodec")) goto loop_enter; goto err_out_parse_error; @@ -652,11 +670,15 @@ err_out: free(line); line=NULL; + line_num = 0; fclose(fp); return 0; err_out_not_valid: mp_msg(MSGT_CODECCFG,MSGL_ERR,"codec is not defined correctly"); goto err_out_print_linenum; +err_out_release_num: + mp_msg(MSGT_CODECCFG,MSGL_ERR,"this codecs.conf is too old, incompatible with this mplayer release!"); + goto err_out_print_linenum; } codecs_t *find_audio_codec(unsigned int fourcc, unsigned int *fourccmap, diff --git a/codec-cfg.h b/codec-cfg.h index eb4f3b7515..fb937b5799 100644 --- a/codec-cfg.h +++ b/codec-cfg.h @@ -1,6 +1,8 @@ #ifndef __CODEC_CFG_H #define __CODEC_CFG_H +#define CODEC_CFG_MIN 20020520 + #define CODECS_MAX_FOURCC 32 #define CODECS_MAX_OUTFMT 16 #define CODECS_MAX_INFMT 16 diff --git a/etc/codecs.conf b/etc/codecs.conf index 83073340b1..64b9c58a04 100644 --- a/etc/codecs.conf +++ b/etc/codecs.conf @@ -3,6 +3,8 @@ ; Before editing this file, please read DOCS/tech/codecs.conf.txt ! ;============================================================================= +release 20020520 + ;============================================================================= ; VIDEO CODECS ;=============================================================================