mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-11-06 05:17:42 +00:00
avutil/opt: add a serialization flag to exclude options with specific flags
Useful for example for scenarios like wanting to serialize only options that are not marked as deprecated. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
1 parent
3593b81b09
commit
7304d10462
6 files changed
+64
-13
No files matched your search
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2026-06-23.
|
||||
|
||||
API changes, most recent first:
|
||||
|
||||
2026-10-07 - xxxxxxxxxx - lavu 61.12.100 - opt.h
|
||||
Add AV_OPT_SERIALIZE_OPT_FLAGS_EXCLUDE.
|
||||
|
||||
2026-10-03 - xxxxxxxxxx - lavu 61.11.100 - pixfmt.h
|
||||
Add AV_PIX_FMT_XYZP12LE, AV_PIX_FMT_XYZP12BE, and AV_PIX_FMT_XYZP12.
|
||||
|
||||
|
||||
+12
-4
@@ -2816,10 +2816,18 @@ static int opt_serialize(void *obj, int opt_flags, int flags, int *cnt,
|
||||
while (o = av_opt_next(obj, o)) {
|
||||
if (o->type == AV_OPT_TYPE_CONST)
|
||||
continue;
|
||||
if ((flags & AV_OPT_SERIALIZE_OPT_FLAGS_EXACT) && o->flags != opt_flags)
|
||||
continue;
|
||||
else if (((o->flags & opt_flags) != opt_flags))
|
||||
continue;
|
||||
if ((flags & AV_OPT_SERIALIZE_OPT_FLAGS_EXCLUDE)) {
|
||||
if ((flags & AV_OPT_SERIALIZE_OPT_FLAGS_EXACT)) {
|
||||
if (o->flags == opt_flags)
|
||||
continue;
|
||||
} else if ((o->flags & opt_flags) == opt_flags)
|
||||
continue;
|
||||
} else {
|
||||
if ((flags & AV_OPT_SERIALIZE_OPT_FLAGS_EXACT) && o->flags != opt_flags)
|
||||
continue;
|
||||
else if (((o->flags & opt_flags) != opt_flags))
|
||||
continue;
|
||||
}
|
||||
if (flags & AV_OPT_SERIALIZE_SKIP_DEFAULTS && av_opt_is_set_to_default(obj, o) > 0)
|
||||
continue;
|
||||
if ((ret = av_opt_get(obj, o->name, 0, &buf)) < 0) {
|
||||
|
||||
+10
-1
@@ -1090,8 +1090,17 @@ int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_fla
|
||||
int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
|
||||
|
||||
#define AV_OPT_SERIALIZE_SKIP_DEFAULTS 0x00000001 ///< Serialize options that are not set to default values only.
|
||||
#define AV_OPT_SERIALIZE_OPT_FLAGS_EXACT 0x00000002 ///< Serialize options that exactly match opt_flags only.
|
||||
/**
|
||||
* Match only options with the exact @ref AVOption.flags flags
|
||||
* in @ref opt_flags, for exclusion or inclusion in serialization.
|
||||
*/
|
||||
#define AV_OPT_SERIALIZE_OPT_FLAGS_EXACT 0x00000002
|
||||
#define AV_OPT_SERIALIZE_SEARCH_CHILDREN 0x00000004 ///< Serialize options in possible children of the given object.
|
||||
/**
|
||||
* Serialize options with @ref AVOption.flags flags not
|
||||
* in @ref opt_flags.
|
||||
*/
|
||||
#define AV_OPT_SERIALIZE_OPT_FLAGS_EXCLUDE 0x00000008
|
||||
|
||||
/**
|
||||
* Serialize object's options.
|
||||
|
||||
+31
-7
@@ -385,22 +385,30 @@ int main(void)
|
||||
if (ret < 0)
|
||||
printf("Error ret '%d'\n", ret);
|
||||
if (av_opt_serialize(&test_ctx, 0, 0, &buf, '=', ',') >= 0) {
|
||||
ChildContext child_ctx = { 0 };
|
||||
ChildContext child_ctx = { .child_num64 = 1, .child_unum = 1 };
|
||||
printf("%s\n", buf);
|
||||
av_free(buf);
|
||||
child_ctx.class = &child_class;
|
||||
test_ctx.child = &child_ctx;
|
||||
if (av_opt_serialize(&test_ctx, 0,
|
||||
printf("Exclude flag EXPORT:\n");
|
||||
if (av_opt_serialize(&test_ctx, AV_OPT_FLAG_EXPORT,
|
||||
AV_OPT_SERIALIZE_SKIP_DEFAULTS|AV_OPT_SERIALIZE_SEARCH_CHILDREN|
|
||||
AV_OPT_SERIALIZE_OPT_FLAGS_EXCLUDE,
|
||||
&buf, '=', ',') >= 0) {
|
||||
printf("%s\n", buf);
|
||||
av_free(buf);
|
||||
}
|
||||
printf("Include flag EXPORT:\n");
|
||||
if (av_opt_serialize(&test_ctx, AV_OPT_FLAG_EXPORT,
|
||||
AV_OPT_SERIALIZE_SKIP_DEFAULTS|AV_OPT_SERIALIZE_SEARCH_CHILDREN,
|
||||
&buf, '=', ',') >= 0) {
|
||||
printf("%s\n", buf);
|
||||
av_free(buf);
|
||||
}
|
||||
child_ctx.child_num64 = 1;
|
||||
child_ctx.child_unum = 1;
|
||||
printf("Include flag EXPORT:\n");
|
||||
if (av_opt_serialize(&test_ctx, AV_OPT_FLAG_EXPORT,
|
||||
AV_OPT_SERIALIZE_SKIP_DEFAULTS|AV_OPT_SERIALIZE_SEARCH_CHILDREN,
|
||||
printf("Exclude flag 1:\n");
|
||||
if (av_opt_serialize(&test_ctx, 1,
|
||||
AV_OPT_SERIALIZE_SKIP_DEFAULTS|AV_OPT_SERIALIZE_SEARCH_CHILDREN|
|
||||
AV_OPT_SERIALIZE_OPT_FLAGS_EXCLUDE,
|
||||
&buf, '=', ',') >= 0) {
|
||||
printf("%s\n", buf);
|
||||
av_free(buf);
|
||||
@@ -412,6 +420,14 @@ int main(void)
|
||||
printf("%s\n", buf);
|
||||
av_free(buf);
|
||||
}
|
||||
printf("Exclude exact match flag 1:\n");
|
||||
if (av_opt_serialize(&test_ctx, 1,
|
||||
AV_OPT_SERIALIZE_SKIP_DEFAULTS|AV_OPT_SERIALIZE_SEARCH_CHILDREN|
|
||||
AV_OPT_SERIALIZE_OPT_FLAGS_EXACT|AV_OPT_SERIALIZE_OPT_FLAGS_EXCLUDE,
|
||||
&buf, '=', ',') >= 0) {
|
||||
printf("%s\n", buf);
|
||||
av_free(buf);
|
||||
}
|
||||
printf("Include exact match flag 1:\n");
|
||||
if (av_opt_serialize(&test_ctx, 1,
|
||||
AV_OPT_SERIALIZE_SKIP_DEFAULTS|AV_OPT_SERIALIZE_SEARCH_CHILDREN|
|
||||
@@ -420,6 +436,14 @@ int main(void)
|
||||
printf("%s\n", buf);
|
||||
av_free(buf);
|
||||
}
|
||||
printf("Exclude exact match flag EXPORT|READONLY:\n");
|
||||
if (av_opt_serialize(&test_ctx, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY,
|
||||
AV_OPT_SERIALIZE_SKIP_DEFAULTS|AV_OPT_SERIALIZE_SEARCH_CHILDREN|
|
||||
AV_OPT_SERIALIZE_OPT_FLAGS_EXACT|AV_OPT_SERIALIZE_OPT_FLAGS_EXCLUDE,
|
||||
&buf, '=', ',') >= 0) {
|
||||
printf("%s\n", buf);
|
||||
av_free(buf);
|
||||
}
|
||||
printf("Include exact match flag EXPORT|READONLY:\n");
|
||||
if (av_opt_serialize(&test_ctx, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY,
|
||||
AV_OPT_SERIALIZE_SKIP_DEFAULTS|AV_OPT_SERIALIZE_SEARCH_CHILDREN|
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@
|
||||
*/
|
||||
|
||||
#define LIBAVUTIL_VERSION_MAJOR 61
|
||||
#define LIBAVUTIL_VERSION_MINOR 11
|
||||
#define LIBAVUTIL_VERSION_MINOR 12
|
||||
#define LIBAVUTIL_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||
|
||||
@@ -191,13 +191,20 @@ Setting entry with key 'array_int' to value ''
|
||||
Setting entry with key 'array_str' to value 'str0|str\|1|str\\2'
|
||||
Setting entry with key 'array_dict' to value 'k00=v\\\\00:k01=v\,01,k10=v\\=1\\:0'
|
||||
num=0,unum=2147483648,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x00000001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0.001,color=0xffc0cbff,cl=hexagonal,bin=62696E00,bin1=,bin2=,num64=4294967296,flt=0.333333,dbl=0.333333,bool1=auto,bool2=true,bool3=false,dict1=,dict2=happy\=\\:-),array_int=,array_str=str0|str\\|1|str\\\\2,array_dict=k00\=v\\\\\\\\00:k01\=v\\\,01\,k10\=v\\\\\=1\\\\:0
|
||||
Exclude flag EXPORT:
|
||||
child_num=0,flt=0.333333,dbl=0.333333
|
||||
Include flag EXPORT:
|
||||
child_num64=1,child_unum=1
|
||||
Exclude flag 1:
|
||||
child_unum=1
|
||||
Include flag 1:
|
||||
child_num64=1,child_num=0,flt=0.333333,dbl=0.333333
|
||||
Exclude exact match flag 1:
|
||||
child_num64=1,child_unum=1
|
||||
Include exact match flag 1:
|
||||
child_num=0,flt=0.333333,dbl=0.333333
|
||||
Exclude exact match flag EXPORT|READONLY:
|
||||
child_num64=1,child_num=0,flt=0.333333,dbl=0.333333
|
||||
Include exact match flag EXPORT|READONLY:
|
||||
child_unum=1
|
||||
|
||||
|
||||
Reference in new issue
Block a user