[FFmpeg-devel] [PATCH v5 3/4] avfilter/vf_showinfo: display user data unregistered message

Limin Wang lance.lmwang at gmail.com
Tue Jan 7 02:50:03 EET 2020


On Mon, Jan 06, 2020 at 10:38:22PM +0000, Mark Thompson wrote:
> On 02/01/2020 01:28, lance.lmwang at gmail.com wrote:
> > From: Limin Wang <lance.lmwang at gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> > ---
> >  libavfilter/vf_showinfo.c | 33 +++++++++++++++++++++++++++++++++
> >  1 file changed, 33 insertions(+)
> > 
> > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> > index 31f6b32..bb3b37e 100644
> > --- a/libavfilter/vf_showinfo.c
> > +++ b/libavfilter/vf_showinfo.c
> > @@ -169,6 +169,36 @@ static void dump_content_light_metadata(AVFilterContext *ctx, AVFrameSideData *s
> >             metadata->MaxCLL, metadata->MaxFALL);
> >  }
> >  
> > +static int string_is_ascii(const uint8_t *str)
> > +{
> > +    while (*str && *str < 128) str++;
> > +    return !*str;
> 
> Perhaps isprint() would be better?  You don't really want to allow any control characters like newline either.

Sure, it's OK to use isprint, I'll update to use it.

> 
> > +}
> > +
> > +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, "%x", user_data[i]);
> 
> "%02x"

OK
 
> Putting the hyphens in the standard places would make this more readable, too.

I'll try to add the hyphens in the standard places.

> 
> > +    av_log(ctx, AV_LOG_INFO, "\n");
> > +
> > +    user_data += uuid_size;
> > +    /* Only print the user data details if it's string */
> > +    if (string_is_ascii(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 +349,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);
> > 
> 
> - Mark
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang


More information about the ffmpeg-devel mailing list