[FFmpeg-devel] [PATCH 1/6] avutil/mastering_display_metadata: add av_mastering_display_metadata_alloc2()

James Almer jamrial at gmail.com
Sun Dec 11 05:33:03 EET 2016


Also deprecate av_mastering_display_metadata_alloc().

This new alloc function optionally returns the size of the AVMasteringDisplayMetadata
struct.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavutil/mastering_display_metadata.c | 12 ++++++++++++
 libavutil/mastering_display_metadata.h | 17 +++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/libavutil/mastering_display_metadata.c b/libavutil/mastering_display_metadata.c
index e1683e5..872f14b 100644
--- a/libavutil/mastering_display_metadata.c
+++ b/libavutil/mastering_display_metadata.c
@@ -29,6 +29,18 @@ AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void)
     return av_mallocz(sizeof(AVMasteringDisplayMetadata));
 }
 
+AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc2(size_t *size)
+{
+    AVMasteringDisplayMetadata *mastering = av_mallocz(sizeof(AVMasteringDisplayMetadata));
+    if (!mastering)
+        return NULL;
+
+    if (size)
+        *size = sizeof(*mastering);
+
+    return mastering;
+}
+
 AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFrame *frame)
 {
     AVFrameSideData *side_data = av_frame_new_side_data(frame,
diff --git a/libavutil/mastering_display_metadata.h b/libavutil/mastering_display_metadata.h
index 936533f..32357b3 100644
--- a/libavutil/mastering_display_metadata.h
+++ b/libavutil/mastering_display_metadata.h
@@ -21,6 +21,10 @@
 #ifndef AVUTIL_MASTERING_DISPLAY_METADATA_H
 #define AVUTIL_MASTERING_DISPLAY_METADATA_H
 
+#include <stddef.h>
+#include <stdint.h>
+
+#include "attributes.h"
 #include "frame.h"
 #include "rational.h"
 
@@ -74,10 +78,23 @@ typedef struct AVMasteringDisplayMetadata {
  *
  * @return An AVMasteringDisplayMetadata filled with default values or NULL
  *         on failure.
+ *
+ * @deprecated Use av_mastering_display_metadata_alloc2().
  */
+attribute_deprecated
 AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
 
 /**
+ * Allocate an AVMasteringDisplayMetadata structure and set its fields to
+ * default values. The resulting struct can be freed using av_freep().
+ *
+ * @param size pointer for AVMasteringDisplayMetadata structure size to store (optional)
+ * @return An AVMasteringDisplayMetadata filled with default values or NULL
+ *         on failure.
+ */
+AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc2(size_t *size);
+
+/**
  * Allocate a complete AVMasteringDisplayMetadata and add it to the frame.
  *
  * @param frame The frame which side data is added to.
-- 
2.10.2



More information about the ffmpeg-devel mailing list