[FFmpeg-cvslog] lavu/opt: deprecate av_opt_ptr()

Anton Khirnov git at videolan.org
Wed Oct 16 17:50:26 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Oct 13 13:18:55 2024 +0200| [31b5b3badc2bc3d9d59d5b534c84033c9eb3d577] | committer: Anton Khirnov

lavu/opt: deprecate av_opt_ptr()

It has no more internal callers, and we do not want to support direct
pointer access via AVOptions, as that constrains AVOption API
extensions.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=31b5b3badc2bc3d9d59d5b534c84033c9eb3d577
---

 libavutil/opt.c     | 2 ++
 libavutil/opt.h     | 5 +++++
 libavutil/version.h | 1 +
 3 files changed, 8 insertions(+)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 7dc4fdb062..ee451ae023 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -2046,6 +2046,7 @@ const AVClass *av_opt_child_class_iterate(const AVClass *parent, void **iter)
     return NULL;
 }
 
+#if FF_API_OPT_PTR
 void *av_opt_ptr(const AVClass *class, void *obj, const char *name)
 {
     const AVOption *opt= av_opt_find2(&class, name, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ, NULL);
@@ -2055,6 +2056,7 @@ void *av_opt_ptr(const AVClass *class, void *obj, const char *name)
         return NULL;
     return (uint8_t*)obj + opt->offset;
 }
+#endif
 
 static int opt_copy_elem(void *logctx, enum AVOptionType type,
                          void *dst, const void *src)
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 17374211a4..d313679263 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -1071,6 +1071,7 @@ int av_opt_eval_q     (void *obj, const AVOption *o, const char *val, AVRational
  * @}
  */
 
+#if FF_API_OPT_PTR
 /**
  * Gets a pointer to the requested field in a struct.
  * This function allows accessing a struct even when its fields are moved or
@@ -1078,8 +1079,12 @@ int av_opt_eval_q     (void *obj, const AVOption *o, const char *val, AVRational
  *
  * @returns a pointer to the field, it can be cast to the correct type and read
  *          or written to.
+ *
+ * @deprecated direct access to AVOption-exported fields is not supported
  */
+attribute_deprecated
 void *av_opt_ptr(const AVClass *avclass, void *obj, const char *name);
+#endif
 
 /**
  * Check if given option is set to its default value.
diff --git a/libavutil/version.h b/libavutil/version.h
index 4ff5ce8e12..9ebed5d75c 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -116,6 +116,7 @@
 #define FF_API_RISCV_FD_ZBA             (LIBAVUTIL_VERSION_MAJOR < 60)
 #define FF_API_VULKAN_FIXED_QUEUES      (LIBAVUTIL_VERSION_MAJOR < 60)
 #define FF_API_OPT_INT_LIST             (LIBAVUTIL_VERSION_MAJOR < 60)
+#define FF_API_OPT_PTR                  (LIBAVUTIL_VERSION_MAJOR < 60)
 
 /**
  * @}



More information about the ffmpeg-cvslog mailing list