[FFmpeg-devel] [PATCH 08/17] AVCodecContext: switch to child_class_iterate()

Anton Khirnov anton at khirnov.net
Thu May 28 23:15:50 EEST 2020


---
 libavcodec/options.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libavcodec/options.c b/libavcodec/options.c
index 7706a03297..ff16e2cbfd 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -53,6 +53,7 @@ static void *codec_child_next(void *obj, void *prev)
     return NULL;
 }
 
+#if FF_API_CHILD_CLASS_NEXT
 static const AVClass *codec_child_class_next(const AVClass *prev)
 {
     void *iter = NULL;
@@ -69,6 +70,17 @@ static const AVClass *codec_child_class_next(const AVClass *prev)
             return c->priv_class;
     return NULL;
 }
+#endif
+
+static const AVClass *codec_child_class_iterate(void **iter)
+{
+    const AVCodec *c;
+    /* find next codec with priv options */
+    while (c = av_codec_iterate(iter))
+        if (c->priv_class)
+            return c->priv_class;
+    return NULL;
+}
 
 static AVClassCategory get_category(void *ptr)
 {
@@ -84,7 +96,10 @@ static const AVClass av_codec_context_class = {
     .version                 = LIBAVUTIL_VERSION_INT,
     .log_level_offset_offset = offsetof(AVCodecContext, log_level_offset),
     .child_next              = codec_child_next,
+#if FF_API_CHILD_CLASS_NEXT
     .child_class_next        = codec_child_class_next,
+#endif
+    .child_class_iterate     = codec_child_class_iterate,
     .category                = AV_CLASS_CATEGORY_ENCODER,
     .get_category            = get_category,
 };
-- 
2.26.2



More information about the ffmpeg-devel mailing list