diff mbox series

[FFmpeg-devel,v9,3/4] avfilter/vf_showinfo: display H.26[45] user data unregistered sei message

Message ID 20200317105409.2795-3-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,v9,1/4] avutil: add AV_FRAME_DATA_SEI_UNREGISTERED side data type
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Limin Wang March 17, 2020, 10:54 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavfilter/vf_showinfo.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

Comments

Limin Wang April 8, 2020, 1:56 p.m. UTC | #1
ping this patch for merge, it'll dump the metadata and don't change API.


On Tue, Mar 17, 2020 at 06:54:08PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@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 79b79db..36b9bf1 100644
> --- a/libavfilter/vf_showinfo.c
> +++ b/libavfilter/vf_showinfo.c
> @@ -23,6 +23,7 @@
>   */
>  
>  #include <inttypes.h>
> +#include <ctype.h>
>  
>  #include "libavutil/bswap.h"
>  #include "libavutil/adler32.h"
> @@ -170,6 +171,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_sei_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);
> @@ -347,6 +381,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
>              av_log(ctx, AV_LOG_INFO, "GOP timecode - %s", tcbuf);
>              break;
>          }
> +        case AV_FRAME_DATA_SEI_UNREGISTERED:
> +            dump_sei_unregistered_metadata(ctx, sd);
> +            break;
>          default:
>              av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
>                     sd->type, sd->size);
> -- 
> 2.9.5
>
diff mbox series

Patch

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 79b79db..36b9bf1 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -23,6 +23,7 @@ 
  */
 
 #include <inttypes.h>
+#include <ctype.h>
 
 #include "libavutil/bswap.h"
 #include "libavutil/adler32.h"
@@ -170,6 +171,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_sei_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);
@@ -347,6 +381,9 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
             av_log(ctx, AV_LOG_INFO, "GOP timecode - %s", tcbuf);
             break;
         }
+        case AV_FRAME_DATA_SEI_UNREGISTERED:
+            dump_sei_unregistered_metadata(ctx, sd);
+            break;
         default:
             av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
                    sd->type, sd->size);