[FFmpeg-cvslog] avutil/mastering_display_metadata: add a new allocator function that returns a size

James Almer git at videolan.org
Thu Apr 11 18:02:33 EEST 2024


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Fri Mar 22 18:42:05 2024 -0300| [6d760c666d57ccbc95e85ef6fb9667fdd06854d1] | committer: James Almer

avutil/mastering_display_metadata: add a new allocator function that returns a size

av_mastering_display_metadata_alloc() is not useful in scenarios where you need to
know the runtime size of AVMasteringDisplayMetadata.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6d760c666d57ccbc95e85ef6fb9667fdd06854d1
---

 doc/APIchanges                         |  3 +++
 libavutil/mastering_display_metadata.c | 13 +++++++++++++
 libavutil/mastering_display_metadata.h |  9 +++++++++
 libavutil/version.h                    |  2 +-
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 59855a6434..d7c2056f0e 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-04-11 - xxxxxxxxxx - lavu 59.15.100 - frame.h
+  Add av_mastering_display_metadata_alloc_size().
+
 2024-04-11 - xxxxxxxxxx - lavu 59.14.100 - frame.h
   Add av_frame_side_data_add() and av_frame_side_data_remove().
   Add AV_FRAME_SIDE_DATA_FLAG_REPLACE.
diff --git a/libavutil/mastering_display_metadata.c b/libavutil/mastering_display_metadata.c
index 6069347617..ea41f13f9d 100644
--- a/libavutil/mastering_display_metadata.c
+++ b/libavutil/mastering_display_metadata.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stddef.h>
 #include <stdint.h>
 #include <string.h>
 
@@ -29,6 +30,18 @@ AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void)
     return av_mallocz(sizeof(AVMasteringDisplayMetadata));
 }
 
+AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc_size(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 c23b07c3cd..52fcef9e37 100644
--- a/libavutil/mastering_display_metadata.h
+++ b/libavutil/mastering_display_metadata.h
@@ -77,6 +77,15 @@ typedef struct AVMasteringDisplayMetadata {
  */
 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().
+ *
+ * @return An AVMasteringDisplayMetadata filled with default values or NULL
+ *         on failure.
+ */
+AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc_size(size_t *size);
+
 /**
  * Allocate a complete AVMasteringDisplayMetadata and add it to the frame.
  *
diff --git a/libavutil/version.h b/libavutil/version.h
index 78ee30dd08..1f2bddc022 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  14
+#define LIBAVUTIL_VERSION_MINOR  15
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list