diff mbox series

[FFmpeg-devel,v2] lavu/opt: Discuss AV_OPT_FLAG_RUNTIME_PARAM more explicitly

Message ID 20240606160206.501956-1-ffmpeg-devel@pileofstuff.org
State New
Headers show
Series [FFmpeg-devel,v2] lavu/opt: Discuss AV_OPT_FLAG_RUNTIME_PARAM more explicitly | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andrew Sayers June 6, 2024, 4:02 p.m. UTC
After a struct is initialized, only options with the
AV_OPT_FLAG_RUNTIME_PARAM flag can be modified.

Make that clearer, for the sake of readers who would otherwise
assume all options can be modified at any time.
---
 libavutil/opt.h | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

Comments

Stefano Sabatini June 16, 2024, 4:04 p.m. UTC | #1
On date Thursday 2024-06-06 17:02:06 +0100, Andrew Sayers wrote:
> After a struct is initialized, only options with the
> AV_OPT_FLAG_RUNTIME_PARAM flag can be modified.
> 
> Make that clearer, for the sake of readers who would otherwise
> assume all options can be modified at any time.
> ---
>  libavutil/opt.h | 26 +++++++++++++++++++++++++-
>  1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/opt.h b/libavutil/opt.h
> index 07e27a9208..d23c10bcf5 100644
> --- a/libavutil/opt.h
> +++ b/libavutil/opt.h
> @@ -53,6 +53,9 @@
>   * question is allowed to access the field. This allows us to extend the
>   * semantics of those fields without breaking API compatibility.
>   *
> + * Note: only options with the AV_OPT_FLAG_RUNTIME_PARAM flag can be
> + * modified after the struct is initialized.
> + *
>   * @section avoptions_scope Scope of AVOptions
>   *
>   * AVOptions is designed to support any set of multimedia configuration options
> @@ -300,7 +303,7 @@ enum AVOptionType{
>  #define AV_OPT_FLAG_BSF_PARAM       (1 << 8)
>  

>  /**
> - * A generic parameter which can be set by the user at runtime.
> + * A generic parameter which can be set by the user after initialization.
>   */
>  #define AV_OPT_FLAG_RUNTIME_PARAM   (1 << 15)

I'm fine with changing the description, but then I wonder if we should
also rename the flag accordingly (by adding a new alias and
deprecating the old one):
AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM
??

>  /**
> @@ -483,6 +486,9 @@ typedef struct AVOptionRanges {
>  /**
>   * Set the values of all AVOption fields to their default values.
>   *

> + * Note: after a struct is initialized, only options with the
> + * AV_OPT_FLAG_RUNTIME_PARAM flag can be modified.
> + *

drop this note and the following ones, this is assumed by the flags so
there is no need to repeat this all over
Paul B Mahol June 16, 2024, 5:22 p.m. UTC | #2
Pointless. Commit log spam.
diff mbox series

Patch

diff --git a/libavutil/opt.h b/libavutil/opt.h
index 07e27a9208..d23c10bcf5 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -53,6 +53,9 @@ 
  * question is allowed to access the field. This allows us to extend the
  * semantics of those fields without breaking API compatibility.
  *
+ * Note: only options with the AV_OPT_FLAG_RUNTIME_PARAM flag can be
+ * modified after the struct is initialized.
+ *
  * @section avoptions_scope Scope of AVOptions
  *
  * AVOptions is designed to support any set of multimedia configuration options
@@ -300,7 +303,7 @@  enum AVOptionType{
 #define AV_OPT_FLAG_BSF_PARAM       (1 << 8)
 
 /**
- * A generic parameter which can be set by the user at runtime.
+ * A generic parameter which can be set by the user after initialization.
  */
 #define AV_OPT_FLAG_RUNTIME_PARAM   (1 << 15)
 /**
@@ -483,6 +486,9 @@  typedef struct AVOptionRanges {
 /**
  * Set the values of all AVOption fields to their default values.
  *
+ * Note: after a struct is initialized, only options with the
+ * AV_OPT_FLAG_RUNTIME_PARAM flag can be modified.
+ *
  * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass)
  */
 void av_opt_set_defaults(void *s);
@@ -492,6 +498,9 @@  void av_opt_set_defaults(void *s);
  * AVOption fields for which (opt->flags & mask) == flags will have their
  * default applied to s.
  *
+ * Note: after a struct is initialized, only options with the
+ * AV_OPT_FLAG_RUNTIME_PARAM flag can be modified.
+ *
  * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass)
  * @param mask combination of AV_OPT_FLAG_*
  * @param flags combination of AV_OPT_FLAG_*
@@ -661,6 +670,9 @@  enum {
  * key. ctx must be an AVClass context, storing is done using
  * AVOptions.
  *
+ * Note: after a struct is initialized, only options with the
+ * AV_OPT_FLAG_RUNTIME_PARAM flag can be modified.
+ *
  * @param opts options string to parse, may be NULL
  * @param key_val_sep a 0-terminated list of characters used to
  * separate key from value
@@ -679,6 +691,9 @@  int av_set_options_string(void *ctx, const char *opts,
  * Parse the key-value pairs list in opts. For each key=value pair found,
  * set the value of the corresponding option in ctx.
  *
+ * Note: after a struct is initialized, only options with the
+ * AV_OPT_FLAG_RUNTIME_PARAM flag can be modified.
+ *
  * @param ctx          the AVClass object to set options on
  * @param opts         the options string, key-value pairs separated by a
  *                     delimiter
@@ -709,6 +724,9 @@  int av_opt_set_from_string(void *ctx, const char *opts,
 /**
  * Set all the options from a given dictionary on an object.
  *
+ * Note: after a struct is initialized, only options with the
+ * AV_OPT_FLAG_RUNTIME_PARAM flag can be modified.
+ *
  * @param obj a struct whose first element is a pointer to AVClass
  * @param options options to process. This dictionary will be freed and replaced
  *                by a new one containing all options not found in obj.
@@ -726,6 +744,9 @@  int av_opt_set_dict(void *obj, struct AVDictionary **options);
 /**
  * Set all the options from a given dictionary on an object.
  *
+ * Note: after a struct is initialized, only options with the
+ * AV_OPT_FLAG_RUNTIME_PARAM flag can be modified.
+ *
  * @param obj a struct whose first element is a pointer to AVClass
  * @param options options to process. This dictionary will be freed and replaced
  *                by a new one containing all options not found in obj.
@@ -764,6 +785,9 @@  int av_opt_copy(void *dest, const void *src);
  * @{
  * Those functions set the field of obj with the given name to value.
  *
+ * Note: after a struct is initialized, only options with the
+ * AV_OPT_FLAG_RUNTIME_PARAM flag can be modified.
+ *
  * @param[in] obj A struct whose first element is a pointer to an AVClass.
  * @param[in] name the name of the field to set
  * @param[in] val The value to set. In case of av_opt_set() if the field is not