[FFmpeg-devel] [PATCH 1/3] lavu: add support for Content Light Level side metadata
Hendrik Leppkes
h.leppkes at gmail.com
Thu Mar 30 17:46:45 EEST 2017
On Thu, Mar 30, 2017 at 4:31 PM, Steve Lhomme <robux4 at gmail.com> wrote:
> As found in HEVC.
>
> I put the code in mastering_display_metadata as they usually go together in
> Blu-Ray UHD sources.
> ---
> libavutil/frame.c | 1 +
> libavutil/frame.h | 6 ++++++
> libavutil/mastering_display_metadata.c | 18 ++++++++++++++++
> libavutil/mastering_display_metadata.h | 39 ++++++++++++++++++++++++++++++++++
> libavutil/version.h | 2 +-
> 5 files changed, 65 insertions(+), 1 deletion(-)
>
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index 8811dcdcfe..dd12c5549c 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -772,6 +772,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type)
> case AV_FRAME_DATA_SKIP_SAMPLES: return "Skip samples";
> case AV_FRAME_DATA_AUDIO_SERVICE_TYPE: return "Audio service type";
> case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata";
> + case AV_FRAME_DATA_CONTENT_LIGHT_LEVEL: return "Content light level metadata";
> case AV_FRAME_DATA_GOP_TIMECODE: return "GOP timecode";
> }
> return NULL;
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index 7cb78a1a44..45e21a11d4 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -127,6 +127,12 @@ enum AVFrameSideDataType {
> * libavutil/spherical.h.
> */
> AV_FRAME_DATA_SPHERICAL,
> +
> + /**
> + * Content light level (based on CEA 861.3). This payload containts data in
> + * the form of the AVContentLightMetadata struct.
> + */
> + AV_FRAME_DATA_CONTENT_LIGHT_LEVEL,
> };
>
> enum AVActiveFormatDescription {
> diff --git a/libavutil/mastering_display_metadata.c b/libavutil/mastering_display_metadata.c
> index e1683e55c7..c41c90db12 100644
> --- a/libavutil/mastering_display_metadata.c
> +++ b/libavutil/mastering_display_metadata.c
> @@ -41,3 +41,21 @@ AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFra
>
> return (AVMasteringDisplayMetadata *)side_data->data;
> }
> +
> +AVContentLightMetadata *av_content_light_metadata_alloc(void)
> +{
> + return av_mallocz(sizeof(AVContentLightMetadata));
> +}
> +
> +AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *frame)
> +{
> + AVFrameSideData *side_data = av_frame_new_side_data(frame,
> + AV_FRAME_DATA_CONTENT_LIGHT_LEVEL,
> + sizeof(AVContentLightMetadata));
> + if (!side_data)
> + return NULL;
> +
> + memset(side_data->data, 0, sizeof(AVContentLightMetadata));
> +
> + return (AVContentLightMetadata *)side_data->data;
> +}
> diff --git a/libavutil/mastering_display_metadata.h b/libavutil/mastering_display_metadata.h
> index 936533fec4..5ad7f5bd42 100644
> --- a/libavutil/mastering_display_metadata.h
> +++ b/libavutil/mastering_display_metadata.h
> @@ -86,4 +86,43 @@ AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
> */
> AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFrame *frame);
>
> +/**
> + * Content light level needed by to transmit HDR over HDMI (CEA 861.3).
> + *
> + * To be used as payload of a AVFrameSideData or AVPacketSideData with the
> + * appropriate type.
> + *
> + * @note The struct should be allocated with av_content_light_metadata_alloc()
> + * and its size is not a part of the public ABI.
> + */
> +typedef struct AVContentLightMetadata {
> + /**
> + * Max content light level (cd/m^2).
> + */
> + AVRational max_content_light_level;
> +
> + /**
> + * Max avereage light level per picture (cd/m^2).
It might be better to call this how the spec calls it: Maximum
frame-average light level (MaxFALL), instead of coming up with a
slight rewording, that could just cause confusion.
Maybe including the common acronyms MaxCLL and MaxFALL for both
elements might be sensible too.
> + */
> + AVRational max_pic_avg_light_level;
> +} AVContentLightMetadata;
> +
> +/**
> + * Allocate an AVContentLightMetadata structure and set its fields to
> + * default values. The resulting struct can be freed using av_freep().
> + *
> + * @return An AVContentLightMetadata filled with default values or NULL
> + * on failure.
> + */
> +AVContentLightMetadata *av_content_light_metadata_alloc(void);
> +
> +/**
> + * Allocate a complete AVContentLightMetadata and add it to the frame.
> + *
> + * @param frame The frame which side data is added to.
> + *
> + * @return The AVContentLightMetadata structure to be filled by caller.
> + */
> +AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *frame);
> +
> #endif /* AVUTIL_MASTERING_DISPLAY_METADATA_H */
> diff --git a/libavutil/version.h b/libavutil/version.h
> index a14c0e7eb2..fedc6fa177 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
> */
>
> #define LIBAVUTIL_VERSION_MAJOR 55
> -#define LIBAVUTIL_VERSION_MINOR 53
> +#define LIBAVUTIL_VERSION_MINOR 54
> #define LIBAVUTIL_VERSION_MICRO 100
>
> #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> --
> 2.11.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list