* [FFmpeg-devel] [PATCH] avutil/opt: fix av_opt_is_set_to_default() for array options with no default value (PR #21314)
@ 2025-12-29 19:06 James Almer via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: James Almer via ffmpeg-devel @ 2025-12-29 19:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: James Almer
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 <jamrial@gmail.com>
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 <jamrial@gmail.com>
---
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 <jamrial@gmail.com>
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 <jamrial@gmail.com>
---
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 -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-29 19:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-29 19:06 [FFmpeg-devel] [PATCH] avutil/opt: fix av_opt_is_set_to_default() for array options with no default value (PR #21314) James Almer via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git