PR #21314 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21314 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21314.patch
If `AVOptionArrayDef.def` is `NULL`, `av_opt_is_set_to_default` should return true when the field in the object is `NULL`. >From fcdd5c49ed82c74f681fb6a2312c4a28206f6e55 Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Mon, 29 Dec 2025 15:48:51 -0300 Subject: [PATCH 1/2] avutil/opt: fix av_opt_is_set_to_default() for array options with no default value If AVOptionArrayDef.def is NULL, av_opt_is_set_to_default() should return true when the field in the object is NULL. Signed-off-by: James Almer <[email protected]> --- libavutil/opt.c | 2 ++ tests/ref/fate/opt | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index fc5834e168..911e064914 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -2602,6 +2602,8 @@ int av_opt_is_set_to_default(void *obj, const AVOption *o) ret = 0; else if (val) ret = !strcmp(val, def); + else + ret = 1; av_freep(&val); diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt index 1f82f7e4bd..04e787f01d 100644 --- a/tests/ref/fate/opt +++ b/tests/ref/fate/opt @@ -86,7 +86,7 @@ name: bool2 default:0 error: name: bool3 default:1 error: name: dict1 default:1 error: name: dict2 default:0 error: -name: array_int default:0 error: +name: array_int default:1 error: name: array_str default:0 error: name:array_dict default:0 error: name: num default:1 error: @@ -117,7 +117,7 @@ name: bool2 default:1 error: name: bool3 default:1 error: name: dict1 default:1 error: name: dict2 default:1 error: -name: array_int default:0 error: +name: array_int default:1 error: name: array_str default:1 error: name:array_dict default:1 error: @@ -191,7 +191,7 @@ 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 -child_num=0,flt=0.333333,dbl=0.333333,array_int= +child_num=0,flt=0.333333,dbl=0.333333 Testing av_set_options_string() Setting options string '' -- 2.49.1 >From 83d3bd3e56edfa7b2ac8404ef9702a888e07999f Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Mon, 29 Dec 2025 16:04:25 -0300 Subject: [PATCH 2/2] avutil/iamf: remove default value from demixing_matrix_def It's not required sice the previous commit, and fixes memleaks introduced by a6e5fa3fbb5562f14a666964b77cb7560e1a92cd. Signed-off-by: James Almer <[email protected]> --- libavutil/iamf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/iamf.c b/libavutil/iamf.c index c18069220e..ea0c87428f 100644 --- a/libavutil/iamf.c +++ b/libavutil/iamf.c @@ -239,7 +239,7 @@ AVIAMFParamDefinition *av_iamf_param_definition_alloc(enum AVIAMFParamDefinition // // Audio Element // -static const AVOptionArrayDef demixing_matrix_def = { .def = "0|0", .size_max = (255 + 255) * 255, .sep = '|' }; +static const AVOptionArrayDef demixing_matrix_def = { .size_max = (255 + 255) * 255, .sep = '|' }; #undef OFFSET #define OFFSET(x) offsetof(AVIAMFLayer, x) -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
