[FFmpeg-devel,V1] lavf/showinfo: support mastering display sidedata

Submitted by Jun Zhao on Aug. 4, 2019, 10:30 a.m.

Details

Message ID 1564914637-18037-1-git-send-email-mypopydev@gmail.com
State New
Headers show

Commit Message

Jun Zhao Aug. 4, 2019, 10:30 a.m.
From: Jun Zhao <barryjzhao@tencent.com>

support mastering display sidedata.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavfilter/vf_showinfo.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

Comments

Steven Liu Aug. 4, 2019, 11 a.m.
> 在 2019年8月4日,18:30,Jun Zhao <mypopydev@gmail.com> 写道:
> 
> From: Jun Zhao <barryjzhao@tencent.com>
> 
> support mastering display sidedata.
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
> libavfilter/vf_showinfo.c |   30 ++++++++++++++++++++++++++++++
> 1 files changed, 30 insertions(+), 0 deletions(-)
> 
> diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> index f6f8f49..8889c01 100644
> --- a/libavfilter/vf_showinfo.c
> +++ b/libavfilter/vf_showinfo.c
> @@ -34,6 +34,7 @@
> #include "libavutil/stereo3d.h"
> #include "libavutil/timestamp.h"
> #include "libavutil/timecode.h"
> +#include "libavutil/mastering_display_metadata.h"
> 
> #include "avfilter.h"
> #include "internal.h"
> @@ -133,6 +134,32 @@ static void dump_roi(AVFilterContext *ctx, AVFrameSideData *sd)
>    }
> }
> 
> +static void dump_mastering_display(AVFilterContext *ctx, AVFrameSideData *sd)
> +{
> +    AVMasteringDisplayMetadata *mastering_display;
> +
> +    av_log(ctx, AV_LOG_INFO, "mastering display: ");
> +    if (sd->size < sizeof(*mastering_display)) {
> +        av_log(ctx, AV_LOG_INFO, "invalid data”);
Why don’t use ERROR level if it is invalid data?
> +        return;
> +    }
> +
> +    mastering_display = (AVMasteringDisplayMetadata *)sd->data;
> +
> +    av_log(ctx, AV_LOG_INFO, "has_primaries:%d has_luminance:%d "
> +           "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) "
> +           "min_luminance=%f, max_luminance=%f",
> +           mastering_display->has_primaries, mastering_display->has_luminance,
> +           av_q2d(mastering_display->display_primaries[0][0]),
> +           av_q2d(mastering_display->display_primaries[0][1]),
> +           av_q2d(mastering_display->display_primaries[1][0]),
> +           av_q2d(mastering_display->display_primaries[1][1]),
> +           av_q2d(mastering_display->display_primaries[2][0]),
> +           av_q2d(mastering_display->display_primaries[2][1]),
> +           av_q2d(mastering_display->white_point[0]), av_q2d(mastering_display->white_point[1]),
> +           av_q2d(mastering_display->min_luminance), av_q2d(mastering_display->max_luminance));
> +}
> +
> static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
> {
>    const char *color_range_str     = av_color_range_name(frame->color_range);
> @@ -271,6 +298,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
>        case AV_FRAME_DATA_REGIONS_OF_INTEREST:
>            dump_roi(ctx, sd);
>            break;
> +        case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
> +            dump_mastering_display(ctx, sd);
> +            break;
>        default:
>            av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
>                   sd->type, sd->size);
> -- 
> 1.7.1
> 
> _______________________________________________
> 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".


Thanks
--------------------------------
刘歧|CDN|研发总监
吉林省高升科技有限公司北京分公司
地址:北京市海淀区西三环北路87号国际财经中心B座9层
手机:18611075131
邮箱: liuqi@gosun.com
电话:010-82602628



Thanks
Steven
mypopy@gmail.com Aug. 5, 2019, 6:28 a.m.
On Sun, Aug 4, 2019 at 7:00 PM Steven Liu <lq@chinaffmpeg.org> wrote:
>
>
>
> > 在 2019年8月4日,18:30,Jun Zhao <mypopydev@gmail.com> 写道:
> >
> > From: Jun Zhao <barryjzhao@tencent.com>
> >
> > support mastering display sidedata.
> >
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> > libavfilter/vf_showinfo.c |   30 ++++++++++++++++++++++++++++++
> > 1 files changed, 30 insertions(+), 0 deletions(-)
> >
> > diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
> > index f6f8f49..8889c01 100644
> > --- a/libavfilter/vf_showinfo.c
> > +++ b/libavfilter/vf_showinfo.c
> > @@ -34,6 +34,7 @@
> > #include "libavutil/stereo3d.h"
> > #include "libavutil/timestamp.h"
> > #include "libavutil/timecode.h"
> > +#include "libavutil/mastering_display_metadata.h"
> >
> > #include "avfilter.h"
> > #include "internal.h"
> > @@ -133,6 +134,32 @@ static void dump_roi(AVFilterContext *ctx, AVFrameSideData *sd)
> >    }
> > }
> >
> > +static void dump_mastering_display(AVFilterContext *ctx, AVFrameSideData *sd)
> > +{
> > +    AVMasteringDisplayMetadata *mastering_display;
> > +
> > +    av_log(ctx, AV_LOG_INFO, "mastering display: ");
> > +    if (sd->size < sizeof(*mastering_display)) {
> > +        av_log(ctx, AV_LOG_INFO, "invalid data”);
> Why don’t use ERROR level if it is invalid data?
Will change to ERROR and update the other part in this file like this
case, Thanks.
> > +        return;
> > +    }
> > +
> > +    mastering_display = (AVMasteringDisplayMetadata *)sd->data;
> > +
> > +    av_log(ctx, AV_LOG_INFO, "has_primaries:%d has_luminance:%d "
> > +           "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) "
> > +           "min_luminance=%f, max_luminance=%f",
> > +           mastering_display->has_primaries, mastering_display->has_luminance,
> > +           av_q2d(mastering_display->display_primaries[0][0]),
> > +           av_q2d(mastering_display->display_primaries[0][1]),
> > +           av_q2d(mastering_display->display_primaries[1][0]),
> > +           av_q2d(mastering_display->display_primaries[1][1]),
> > +           av_q2d(mastering_display->display_primaries[2][0]),
> > +           av_q2d(mastering_display->display_primaries[2][1]),
> > +           av_q2d(mastering_display->white_point[0]), av_q2d(mastering_display->white_point[1]),
> > +           av_q2d(mastering_display->min_luminance), av_q2d(mastering_display->max_luminance));
> > +}
> > +
> > static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
> > {
> >    const char *color_range_str     = av_color_range_name(frame->color_range);
> > @@ -271,6 +298,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
> >        case AV_FRAME_DATA_REGIONS_OF_INTEREST:
> >            dump_roi(ctx, sd);
> >            break;
> > +        case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
> > +            dump_mastering_display(ctx, sd);
> > +            break;
> >        default:
> >            av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
> >                   sd->type, sd->size);
> > --
> > 1.7.1

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index f6f8f49..8889c01 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -34,6 +34,7 @@ 
 #include "libavutil/stereo3d.h"
 #include "libavutil/timestamp.h"
 #include "libavutil/timecode.h"
+#include "libavutil/mastering_display_metadata.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -133,6 +134,32 @@  static void dump_roi(AVFilterContext *ctx, AVFrameSideData *sd)
     }
 }
 
+static void dump_mastering_display(AVFilterContext *ctx, AVFrameSideData *sd)
+{
+    AVMasteringDisplayMetadata *mastering_display;
+
+    av_log(ctx, AV_LOG_INFO, "mastering display: ");
+    if (sd->size < sizeof(*mastering_display)) {
+        av_log(ctx, AV_LOG_INFO, "invalid data");
+        return;
+    }
+
+    mastering_display = (AVMasteringDisplayMetadata *)sd->data;
+
+    av_log(ctx, AV_LOG_INFO, "has_primaries:%d has_luminance:%d "
+           "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) "
+           "min_luminance=%f, max_luminance=%f",
+           mastering_display->has_primaries, mastering_display->has_luminance,
+           av_q2d(mastering_display->display_primaries[0][0]),
+           av_q2d(mastering_display->display_primaries[0][1]),
+           av_q2d(mastering_display->display_primaries[1][0]),
+           av_q2d(mastering_display->display_primaries[1][1]),
+           av_q2d(mastering_display->display_primaries[2][0]),
+           av_q2d(mastering_display->display_primaries[2][1]),
+           av_q2d(mastering_display->white_point[0]), av_q2d(mastering_display->white_point[1]),
+           av_q2d(mastering_display->min_luminance), av_q2d(mastering_display->max_luminance));
+}
+
 static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
 {
     const char *color_range_str     = av_color_range_name(frame->color_range);
@@ -271,6 +298,9 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         case AV_FRAME_DATA_REGIONS_OF_INTEREST:
             dump_roi(ctx, sd);
             break;
+        case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
+            dump_mastering_display(ctx, sd);
+            break;
         default:
             av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
                    sd->type, sd->size);