[FFmpeg-devel] [PATCH v7 3/8] avfilter/vf_showinfo: display user data unregistered message
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Tue Jan 7 07:03:50 EET 2020
From: Limin Wang <lance.lmwang at gmail.com>
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
libavfilter/vf_showinfo.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 31f6b32aa4..14e73019d2 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -23,6 +23,7 @@
*/
#include <inttypes.h>
+#include <ctype.h>
#include "libavutil/adler32.h"
#include "libavutil/display.h"
@@ -169,6 +170,39 @@ static void dump_content_light_metadata(AVFilterContext *ctx, AVFrameSideData *s
metadata->MaxCLL, metadata->MaxFALL);
}
+static int string_is_print(const uint8_t *str)
+{
+ while (isprint(*str)) str++;
+ return !*str;
+}
+
+static void dump_user_data_unregistered_metadata(AVFilterContext *ctx, AVFrameSideData *sd)
+{
+ const int uuid_size = 16;
+ uint8_t *user_data = sd->data;
+
+ if (sd->size < uuid_size) {
+ av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size);
+ return;
+ }
+
+ av_log(ctx, AV_LOG_INFO, "User Data Unregistered:\n");
+ av_log(ctx, AV_LOG_INFO, "UUID=");
+ for (int i = 0; i < uuid_size; i++) {
+ av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
+ if (i == 3 || i == 5 || i == 7 || i == 9)
+ av_log(ctx, AV_LOG_INFO, "-");
+ }
+ av_log(ctx, AV_LOG_INFO, "\n");
+
+ user_data += uuid_size;
+ /* Only print the user data details if it's string */
+ if (string_is_print(user_data)) {
+ av_log(ctx, AV_LOG_INFO, "User Data=");
+ av_log(ctx, AV_LOG_INFO, "%s", user_data);
+ }
+}
+
static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
{
const char *color_range_str = av_color_range_name(frame->color_range);
@@ -319,6 +353,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
av_log(ctx, AV_LOG_INFO, "GOP timecode - %s", tcbuf);
break;
}
+ case AV_FRAME_DATA_USER_DATA_UNREGISTERED:
+ dump_user_data_unregistered_metadata(ctx, sd);
+ break;
default:
av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
sd->type, sd->size);
--
2.21.0
More information about the ffmpeg-devel
mailing list