diff mbox series

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

Message ID 20200528201559.22618-8-anton@khirnov.net
State Accepted
Commit 851e0dfe296af1cb96dc5315547ef459cd85c598
Headers show
Series [FFmpeg-devel,01/17] Remove unnecessary use of avcodec_close().
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Anton Khirnov May 28, 2020, 8:15 p.m. UTC
---
 libavcodec/options.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox series

Patch

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,
 };