[FFmpeg-devel] [PATCH 1/2] lavu/opt: fix av_opt_get_key_value() API.
Nicolas George
nicolas.george at normalesup.org
Sat Nov 10 13:17:39 CET 2012
Add an argument to return the final delimiter.
This is an API break, but the function was introduced only
a week ago.
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
cmdutils.c | 3 ++-
doc/APIchanges | 3 ++-
libavutil/opt.c | 9 ++++++---
libavutil/opt.h | 3 ++-
libavutil/version.h | 2 +-
5 files changed, 13 insertions(+), 7 deletions(-)
Not completely sure:
The end delimiter is useful for parsing, for example to parse a string like
"[foo=bar:baz=qux]" and know whether we have reached the ']' or not.
But does anyone believe that the '=' delimiter is useful too?
diff --git a/cmdutils.c b/cmdutils.c
index 1c392d7..9b8fc93 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -575,7 +575,8 @@ static int init_report(const char *env)
tm = localtime(&now);
while (env && *env) {
- if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) {
+ ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val, NULL);
+ if (ret < 0) {
if (count)
av_log(NULL, AV_LOG_ERROR,
"Failed to parse FFREPORT environment variable: %s\n",
diff --git a/doc/APIchanges b/doc/APIchanges
index 8ab0d56..5593ae7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,8 +15,9 @@ libavutil: 2012-10-22
API changes, most recent first:
-2012-11-02 - xxxxxxx - lavu 52.4.100 - opt.h
+2012-11-11 - xxxxxxx - lavu 52.6.100 - opt.h
Add av_opt_get_key_value().
+ (initialy added in lavu 52.4.100 with a different API)
2012-11-03 - xxxxxxx - lavu 52.3.100 - opt.h
Add AV_OPT_TYPE_SAMPLE_FMT value to AVOptionType enum.
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 05ae864..28c8ba8 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -857,7 +857,7 @@ static int get_key(const char **ropts, const char *delim, char **rkey)
int av_opt_get_key_value(const char **ropts,
const char *key_val_sep, const char *pairs_sep,
unsigned flags,
- char **rkey, char **rval)
+ char **rkey, char **rval, char *rdelim)
{
int ret;
char *key = NULL, *val;
@@ -870,8 +870,11 @@ int av_opt_get_key_value(const char **ropts,
av_free(key);
return AVERROR(ENOMEM);
}
- if (*opts && strchr(pairs_sep, *opts))
+ if (*opts && strchr(pairs_sep, *opts)) {
+ if (rdelim)
+ rdelim = *opts;
opts++;
+ }
*ropts = opts;
*rkey = key;
*rval = val;
@@ -895,7 +898,7 @@ int av_opt_set_from_string(void *ctx, const char *opts,
while (*opts) {
ret = av_opt_get_key_value(&opts, key_val_sep, pairs_sep,
*shorthand ? AV_OPT_FLAG_IMPLICIT_KEY : 0,
- &parsed_key, &value);
+ &parsed_key, &value, NULL);
if (ret < 0) {
if (ret == AVERROR(EINVAL))
av_log(ctx, AV_LOG_ERROR, "No option name near '%s'\n", opts);
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 4a3b7f5..d95d56a 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -467,6 +467,7 @@ int av_opt_set_dict(void *obj, struct AVDictionary **options);
* @param flags flags; see the AV_OPT_FLAG_* values below
* @param rkey parsed key; must be freed using av_free()
* @param rval parsed value; must be freed using av_free()
+ * @param rdelim if not NULL, used to return the delimiter at the end
*
* @return 0 for success, or a negative value corresponding to an AVERROR
* code in case of error; in particular:
@@ -476,7 +477,7 @@ int av_opt_set_dict(void *obj, struct AVDictionary **options);
int av_opt_get_key_value(const char **ropts,
const char *key_val_sep, const char *pairs_sep,
unsigned flags,
- char **rkey, char **rval);
+ char **rkey, char **rval, char *rdelim);
enum {
diff --git a/libavutil/version.h b/libavutil/version.h
index 55e0d11..7f11471 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -75,7 +75,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 52
-#define LIBAVUTIL_VERSION_MINOR 5
+#define LIBAVUTIL_VERSION_MINOR 6
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
1.7.10.4
More information about the ffmpeg-devel
mailing list