[FFmpeg-cvslog] lavu/log: do not assume AVClass.item_name is always set

Anton Khirnov git at videolan.org
Thu Nov 9 12:30:07 EET 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Nov  4 08:04:11 2023 +0100| [acf63d5350adeae551d412db699f8ca03f7e76b9] | committer: Anton Khirnov

lavu/log: do not assume AVClass.item_name is always set

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

 libavutil/log.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavutil/log.c b/libavutil/log.c
index 2d358b7ab9..46662f3db0 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -291,6 +291,11 @@ static const char *get_level_str(int level)
     }
 }
 
+static const char *item_name(void *obj, const AVClass *cls)
+{
+    return (cls->item_name ? cls->item_name : av_default_item_name)(obj);
+}
+
 static void format_line(void *avcl, int level, const char *fmt, va_list vl,
                         AVBPrint part[4], int *print_prefix, int type[2])
 {
@@ -307,12 +312,12 @@ static void format_line(void *avcl, int level, const char *fmt, va_list vl,
                                    avc->parent_log_context_offset);
             if (parent && *parent) {
                 av_bprintf(part+0, "[%s @ %p] ",
-                         (*parent)->item_name(parent), parent);
+                           item_name(parent, *parent), parent);
                 if(type) type[0] = get_category(parent);
             }
         }
         av_bprintf(part+1, "[%s @ %p] ",
-                 avc->item_name(avcl), avcl);
+                   item_name(avcl, avc), avcl);
         if(type) type[1] = get_category(avcl);
     }
 



More information about the ffmpeg-cvslog mailing list