diff mbox series

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

Message ID 1591919668-12634-1-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit 567d571b2015819abbb5de953ebb30bca69645a8
Headers show
Series None | expand

Commit Message

Lance Wang June 11, 2020, 11:54 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

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

Comments

Moritz Barsnick June 26, 2020, 9:15 a.m. UTC | #1
On Fri, Jun 12, 2020 at 07:54:28 +0800, lance.lmwang@gmail.com wrote:
> +    if (sd->size < uuid_size) {
> +        av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size);

... \n

Moritz
Lance Wang June 26, 2020, 9:31 a.m. UTC | #2
On Fri, Jun 26, 2020 at 11:15:15AM +0200, Moritz Barsnick wrote:
> On Fri, Jun 12, 2020 at 07:54:28 +0800, lance.lmwang@gmail.com wrote:
> > +    if (sd->size < uuid_size) {
> > +        av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size);
> 
> ... \n

it didn't added \n, for \n will be added after the switch.

> 
> Moritz
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Moritz Barsnick June 26, 2020, 9:55 a.m. UTC | #3
On Fri, Jun 26, 2020 at 17:31:36 +0800, lance.lmwang@gmail.com wrote:
> On Fri, Jun 26, 2020 at 11:15:15AM +0200, Moritz Barsnick wrote:
> > On Fri, Jun 12, 2020 at 07:54:28 +0800, lance.lmwang@gmail.com wrote:
> > > +    if (sd->size < uuid_size) {
> > > +        av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size);
> >
> > ... \n
>
> it didn't added \n, for \n will be added after the switch.

Um. Well, sorry for underquoting (did you check your code or patch, not
just my quote?):

> +static void dump_sei_unregistered_metadata(AVFilterContext *ctx, AVFrameSideData *sd)
> +{
> +    const int uuid_size = 16;
> +    uint8_t *user_data = sd->data;
> +    int i;
> +
> +    if (sd->size < uuid_size) {
> +        av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size);
> +        return;
> +    }

You return immediately, nothing will be added.

Moritz
Lance Wang June 26, 2020, 10:28 a.m. UTC | #4
On Fri, Jun 26, 2020 at 11:55:33AM +0200, Moritz Barsnick wrote:
> On Fri, Jun 26, 2020 at 17:31:36 +0800, lance.lmwang@gmail.com wrote:
> > On Fri, Jun 26, 2020 at 11:15:15AM +0200, Moritz Barsnick wrote:
> > > On Fri, Jun 12, 2020 at 07:54:28 +0800, lance.lmwang@gmail.com wrote:
> > > > +    if (sd->size < uuid_size) {
> > > > +        av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size);
> > >
> > > ... \n
> >
> > it didn't added \n, for \n will be added after the switch.
> 
> Um. Well, sorry for underquoting (did you check your code or patch, not
> just my quote?):

Yes, I have double checked the code.

> 
> > +static void dump_sei_unregistered_metadata(AVFilterContext *ctx, AVFrameSideData *sd)
> > +{
> > +    const int uuid_size = 16;
> > +    uint8_t *user_data = sd->data;
> > +    int i;
> > +
> > +    if (sd->size < uuid_size) {
> > +        av_log(ctx, AV_LOG_ERROR, "invalid data(%d < UUID(%d-bytes))", sd->size, uuid_size);
> > +        return;
> > +    }
> 
> You return immediately, nothing will be added.

Yes, I have followed the same error process style like other metadtata error processing.

> 
> Moritz
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Nicolas George June 26, 2020, 10:34 a.m. UTC | #5
lance.lmwang@gmail.com (12020-06-26):
> Yes, I have double checked the code.

Not enouth. A \n at level INFO cannot end a line at level ERROR.

> Yes, I have followed the same error process style like other metadtata error processing.

Then the existing code is wrong too.

Regards,
Lance Wang June 26, 2020, 10:46 a.m. UTC | #6
On Fri, Jun 26, 2020 at 12:34:35PM +0200, Nicolas George wrote:
> lance.lmwang@gmail.com (12020-06-26):
> > Yes, I have double checked the code.
> 
> Not enouth. A \n at level INFO cannot end a line at level ERROR.
> 
> > Yes, I have followed the same error process style like other metadtata error processing.
> 
> Then the existing code is wrong too.

Yes, It make sense. Now there are ERROR, INFO, WARNING. Can we change all of the
to INFO? If can't, then we'll had to remove the end \n and add for every case.


> 
> Regards,
> 
> -- 
>   Nicolas George



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Nicolas George June 26, 2020, 10:50 a.m. UTC | #7
lance.lmwang@gmail.com (12020-06-26):
> Yes, It make sense. Now there are ERROR, INFO, WARNING. Can we change all of the
> to INFO? If can't, then we'll had to remove the end \n and add for every case.

Absolutely not. ERRORs need to be visible even if INFO is hidden.

Personally, I consider that the messages at different log levels are
just completely separate, and should not be interleaved within a single
line. I can accept tidbits of VERBOSE within a line of INFO, but that's
the maximum.

In this case, that means the ERROR message needs to be complete, and the
INFO needs to be consistent even if there is an error.

Regards,
Lance Wang June 26, 2020, 11:08 a.m. UTC | #8
On Fri, Jun 26, 2020 at 12:50:40PM +0200, Nicolas George wrote:
> lance.lmwang@gmail.com (12020-06-26):
> > Yes, It make sense. Now there are ERROR, INFO, WARNING. Can we change all of the
> > to INFO? If can't, then we'll had to remove the end \n and add for every case.
> 
> Absolutely not. ERRORs need to be visible even if INFO is hidden.
> 
> Personally, I consider that the messages at different log levels are
> just completely separate, and should not be interleaved within a single
> line. I can accept tidbits of VERBOSE within a line of INFO, but that's
> the maximum.
> 
> In this case, that means the ERROR message needs to be complete, and the
> INFO needs to be consistent even if there is an error.

OK, I'll submit a patch to add extra \n for ERROR and WARNING message. I 
think it's OK to print one extra INFO \n if it's info level.

> 
> Regards,
> 
> -- 
>   Nicolas George



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 5d4aee4..5315f8f 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -190,6 +190,33 @@  static void dump_video_enc_params(AVFilterContext *ctx, AVFrameSideData *sd)
         av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks);
 }
 
+static void dump_sei_unregistered_metadata(AVFilterContext *ctx, AVFrameSideData *sd)
+{
+    const int uuid_size = 16;
+    uint8_t *user_data = sd->data;
+    int i;
+
+    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 (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");
+
+    av_log(ctx, AV_LOG_INFO, "User Data=");
+    for (; i < sd->size; i++) {
+        av_log(ctx, AV_LOG_INFO, "%02x", user_data[i]);
+    }
+    av_log(ctx, AV_LOG_INFO, "\n");
+}
+
 static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
 {
     const char *color_range_str     = av_color_range_name(frame->color_range);
@@ -375,6 +402,9 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         case AV_FRAME_DATA_VIDEO_ENC_PARAMS:
             dump_video_enc_params(ctx, sd);
             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);