[FFmpeg-devel] [PATCH 1/2] libavutil: create a AV_OPT_FLAG_READONLY flag
Jean-Baptiste Kempf
jb
Wed Feb 16 01:26:13 CET 2011
This will be useful for options like vbv_delay, that do not make
sense as a command-line option
---
libavutil/avutil.h | 2 +-
libavutil/opt.c | 10 ++++++++++
libavutil/opt.h | 2 ++
3 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 7d1d4cc..e887c4d 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -40,7 +40,7 @@
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
#define LIBAVUTIL_VERSION_MAJOR 50
-#define LIBAVUTIL_VERSION_MINOR 38
+#define LIBAVUTIL_VERSION_MINOR 39
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
diff --git a/libavutil/opt.c b/libavutil/opt.c
index ab6021c..11051d3 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -59,6 +59,11 @@ static int av_set_number2(void *obj, const char *name, double num, int den, int6
if (!o || o->offset<=0)
return AVERROR(ENOENT);
+ if (o->flags&AV_OPT_FLAG_READONLY) {
+ av_log(obj, AV_LOG_ERROR, "Parameter '%s' is read-only\n", name);
+ return AVERROR(EINVAL);
+ }
+
if (o->max*den < num*intnum || o->min*den > num*intnum) {
av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, name);
return AVERROR(ERANGE);
@@ -123,6 +128,11 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons
if (!val || o->offset<=0)
return AVERROR(EINVAL);
+ if (o->flags&AV_OPT_FLAG_READONLY) {
+ av_log(obj, AV_LOG_ERROR, "Parameter '%s' is read-only\n", name);
+ return AVERROR(EINVAL);
+ }
+
if (o->type == FF_OPT_TYPE_BINARY) {
uint8_t **dst = (uint8_t **)(((uint8_t*)obj) + o->offset);
int *lendst = (int *)(dst + 1);
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 67c2dd7..cc2e444 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -75,6 +75,7 @@ typedef struct AVOption {
#define AV_OPT_FLAG_AUDIO_PARAM 8
#define AV_OPT_FLAG_VIDEO_PARAM 16
#define AV_OPT_FLAG_SUBTITLE_PARAM 32
+#define AV_OPT_FLAG_READONLY 64
//FIXME think about enc-audio, ... style flags
/**
@@ -126,6 +127,7 @@ typedef struct AVOption2 {
#define AV_OPT_FLAG_AUDIO_PARAM 8
#define AV_OPT_FLAG_VIDEO_PARAM 16
#define AV_OPT_FLAG_SUBTITLE_PARAM 32
+#define AV_OPT_FLAG_READONLY 64
*/
//FIXME think about enc-audio, ... style flags
--
1.7.2.3
More information about the ffmpeg-devel
mailing list