aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Lhomme <robux4@gmail.com>2017-04-03 09:29:45 +0200
committerJames Almer <jamrial@gmail.com>2017-04-06 11:26:25 -0300
commitb378f5bd640177801681479ddb9fe80ececd9cf8 (patch)
tree9ff921d7c9c124e76ab1a0d5305f148316936f22
parent2a512f86c12d2ed588733c454a12930efbad49f4 (diff)
downloadffmpeg-b378f5bd640177801681479ddb9fe80ececd9cf8.tar.gz
lavu: add support for Content Light Level side metadata
As found in HEVC. Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--doc/APIchanges5
-rw-r--r--libavutil/frame.c1
-rw-r--r--libavutil/frame.h6
-rw-r--r--libavutil/mastering_display_metadata.c23
-rw-r--r--libavutil/mastering_display_metadata.h39
-rw-r--r--libavutil/version.h2
6 files changed, 75 insertions, 1 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index adff133855..e2e6c9067f 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,11 @@ libavutil: 2015-08-28
API changes, most recent first:
+2016-04-06 - xxxxxxx - lavu 55.60.100 - mastering_display_metadata.h
+ Add AV_FRAME_DATA_CONTENT_LIGHT_LEVEL value, av_content_light_metadata_alloc()
+ and av_content_light_metadata_create_side_data() API, and AVContentLightMetadata
+ type to export content light level video properties.
+
2017-03-31 - xxxxxxx - lavu 55.57.100 - spherical.h
Add av_spherical_projection_name().
Add av_spherical_from_name().
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..4d8c1bed4f 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 CTA-861.3). This payload contains 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..6069347617 100644
--- a/libavutil/mastering_display_metadata.c
+++ b/libavutil/mastering_display_metadata.c
@@ -41,3 +41,26 @@ AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFra
return (AVMasteringDisplayMetadata *)side_data->data;
}
+
+AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size)
+{
+ AVContentLightMetadata *metadata = av_mallocz(sizeof(AVContentLightMetadata));
+
+ if (size)
+ *size = sizeof(*metadata);
+
+ return metadata;
+}
+
+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..847b0b62c6 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 (CTA-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).
+ */
+ unsigned MaxCLL;
+
+ /**
+ * Max average light level per frame (cd/m^2).
+ */
+ unsigned MaxFALL;
+} 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(size_t *size);
+
+/**
+ * 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 b0f9ba4f4e..95e1e929f3 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR 59
+#define LIBAVUTIL_VERSION_MINOR 60
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \