[FFmpeg-devel,v1] avfilter/showinfo: support Content Light Level information

Submitted by lance.lmwang@gmail.com on Aug. 9, 2019, 2:28 a.m.

Details

Message ID 20190809022802.9740-1-lance.lmwang@gmail.com
State Accepted
Commit 6866c54ee4747fd11d9a8b6c3a3a8275685159b2
Headers show

Commit Message

lance.lmwang@gmail.com Aug. 9, 2019, 2:28 a.m.
From: Limin Wang <lance.lmwang@gmail.com>

show real information instead of the unknown side data type message for HDR10 stream

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

Comments

mypopy@gmail.com Aug. 9, 2019, 2:50 a.m.
On Fri, Aug 9, 2019 at 10:36 AM <lance.lmwang@gmail.com> wrote:
>
> From: Limin Wang <lance.lmwang@gmail.com>
>
> show real information instead of the unknown side data type message for HDR10 stream
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavfilter/vf_showinfo.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> index 9fa322e404..3c13f11524 100644
> --- a/libavfilter/vf_showinfo.c
> +++ b/libavfilter/vf_showinfo.c
> @@ -160,6 +160,15 @@ static void dump_mastering_display(AVFilterContext *ctx, AVFrameSideData *sd)
>             av_q2d(mastering_display->min_luminance), av_q2d(mastering_display->max_luminance));
>  }
>
> +static void dump_content_light_metadata(AVFilterContext *ctx, AVFrameSideData *sd)
> +{
> +    AVContentLightMetadata* metadata = (AVContentLightMetadata*)sd->data;
> +
Add invaild data check? other part is Ok for me
> +    av_log(ctx, AV_LOG_INFO, "Content Light Level information: "
> +           "MaxCLL=%d, MaxFALL=%d",
> +           metadata->MaxCLL, metadata->MaxFALL);
> +}
> +
>  static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
>  {
>      const char *color_range_str     = av_color_range_name(frame->color_range);
> @@ -301,6 +310,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
>          case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
>              dump_mastering_display(ctx, sd);
>              break;
> +        case AV_FRAME_DATA_CONTENT_LIGHT_LEVEL:
> +            dump_content_light_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
>
lance.lmwang@gmail.com Aug. 9, 2019, 3:05 a.m.
On Fri, Aug 09, 2019 at 10:50:10AM +0800, mypopy@gmail.com wrote:
> On Fri, Aug 9, 2019 at 10:36 AM <lance.lmwang@gmail.com> wrote:
> >
> > From: Limin Wang <lance.lmwang@gmail.com>
> >
> > show real information instead of the unknown side data type message for HDR10 stream
> >
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavfilter/vf_showinfo.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> > index 9fa322e404..3c13f11524 100644
> > --- a/libavfilter/vf_showinfo.c
> > +++ b/libavfilter/vf_showinfo.c
> > @@ -160,6 +160,15 @@ static void dump_mastering_display(AVFilterContext *ctx, AVFrameSideData *sd)
> >             av_q2d(mastering_display->min_luminance), av_q2d(mastering_display->max_luminance));
> >  }
> >
> > +static void dump_content_light_metadata(AVFilterContext *ctx, AVFrameSideData *sd)
> > +{
> > +    AVContentLightMetadata* metadata = (AVContentLightMetadata*)sd->data;
> > +
> Add invaild data check? other part is Ok for me

IMO, the medata memory is allocate by av_content_light_metadata_create_side_data() api, it's valid already,
there is no need to check the size.

> > +    av_log(ctx, AV_LOG_INFO, "Content Light Level information: "
> > +           "MaxCLL=%d, MaxFALL=%d",
> > +           metadata->MaxCLL, metadata->MaxFALL);
> > +}
> > +
> >  static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
> >  {
> >      const char *color_range_str     = av_color_range_name(frame->color_range);
> > @@ -301,6 +310,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
> >          case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
> >              dump_mastering_display(ctx, sd);
> >              break;
> > +        case AV_FRAME_DATA_CONTENT_LIGHT_LEVEL:
> > +            dump_content_light_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
> >
Nicolas George Aug. 9, 2019, 9:12 a.m.
Limin Wang (12019-08-09):
> IMO, the medata memory is allocate by av_content_light_metadata_create_side_data() api, it's valid already,
> there is no need to check the size.

Unless somebody made a programming mistake somewhere else.

Regards,
lance.lmwang@gmail.com Aug. 10, 2019, 2:35 p.m.
On Fri, Aug 09, 2019 at 11:12:35AM +0200, Nicolas George wrote:
> Limin Wang (12019-08-09):
> > IMO, the medata memory is allocate by av_content_light_metadata_create_side_data() api, it's valid already,
> > there is no need to check the size.
> 
> Unless somebody made a programming mistake somewhere else.

OK, I'll update the patch for checking size valid in case somebody's  mistake.


> 
> 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".

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 9fa322e404..3c13f11524 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -160,6 +160,15 @@  static void dump_mastering_display(AVFilterContext *ctx, AVFrameSideData *sd)
            av_q2d(mastering_display->min_luminance), av_q2d(mastering_display->max_luminance));
 }
 
+static void dump_content_light_metadata(AVFilterContext *ctx, AVFrameSideData *sd)
+{
+    AVContentLightMetadata* metadata = (AVContentLightMetadata*)sd->data;
+
+    av_log(ctx, AV_LOG_INFO, "Content Light Level information: "
+           "MaxCLL=%d, MaxFALL=%d",
+           metadata->MaxCLL, metadata->MaxFALL);
+}
+
 static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
 {
     const char *color_range_str     = av_color_range_name(frame->color_range);
@@ -301,6 +310,9 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
             dump_mastering_display(ctx, sd);
             break;
+        case AV_FRAME_DATA_CONTENT_LIGHT_LEVEL:
+            dump_content_light_metadata(ctx, sd);
+            break;
         default:
             av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
                    sd->type, sd->size);