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

Submitted by James Almer on Dec. 11, 2016, 3:33 a.m.

Details

Message ID 20161211033308.8592-3-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer Dec. 11, 2016, 3:33 a.m.
Also deprecate av_stereo3d_alloc().

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

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

Comments

Michael Niedermayer Dec. 12, 2016, 2:53 a.m.
On Sun, Dec 11, 2016 at 12:33:05AM -0300, James Almer wrote:
> Also deprecate av_stereo3d_alloc().
> 
> This new alloc function optionally returns the size of the AVStereo3D struct.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavutil/stereo3d.c | 12 ++++++++++++
>  libavutil/stereo3d.h | 14 ++++++++++++++
>  2 files changed, 26 insertions(+)

needs APIChanges update & bump

should be ok otherwise

thx

[...]

Patch hide | download patch | download mbox

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.