[FFmpeg-devel] [PATCH 3/6] avutil/stereo3d: add av_stereo3d_alloc2()

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


Also deprecate av_stereo3d_alloc().

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

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

diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
index a538364..bdea287 100644
--- a/libavutil/stereo3d.c
+++ b/libavutil/stereo3d.c
@@ -30,6 +30,18 @@ AVStereo3D *av_stereo3d_alloc(void)
     return av_mallocz(sizeof(AVStereo3D));
 }
 
+AVStereo3D *av_stereo3d_alloc2(size_t *size)
+{
+    AVStereo3D *stereo3d = av_mallocz(sizeof(AVStereo3D));
+    if (!stereo3d)
+        return NULL;
+
+    if (size)
+        *size = sizeof(*stereo3d);
+
+    return stereo3d;
+}
+
 AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame)
 {
     AVFrameSideData *side_data = av_frame_new_side_data(frame,
diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h
index 19c5416..d82a4b8 100644
--- a/libavutil/stereo3d.h
+++ b/libavutil/stereo3d.h
@@ -21,8 +21,10 @@
 #ifndef AVUTIL_STEREO3D_H
 #define AVUTIL_STEREO3D_H
 
+#include <stddef.h>
 #include <stdint.h>
 
+#include "attributes.h"
 #include "frame.h"
 
 /**
@@ -137,10 +139,22 @@ typedef struct AVStereo3D {
  * The resulting struct can be freed using av_freep().
  *
  * @return An AVStereo3D filled with default values or NULL on failure.
+ *
+ * @deprecated Use av_stereo3d_alloc2().
  */
+attribute_deprecated
 AVStereo3D *av_stereo3d_alloc(void);
 
 /**
+ * Allocate an AVStereo3D structure and set its fields to default values.
+ * The resulting struct can be freed using av_freep().
+ *
+ * @param size pointer for AVStereo3D structure size to store (optional)
+ * @return An AVStereo3D filled with default values or NULL on failure.
+ */
+AVStereo3D *av_stereo3d_alloc2(size_t *size);
+
+/**
  * Allocate a complete AVFrameSideData 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