[FFmpeg-devel] [PATCH 5/7] avutil/stereo3d: add a new allocator function that returns a size
James Almer
jamrial at gmail.com
Sat Jun 22 05:59:51 EEST 2024
av_stereo3d_alloc() is not useful in scenarios where you need to know the
runtime size of AVStereo3D.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavutil/stereo3d.c | 8 ++++++++
libavutil/stereo3d.h | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/libavutil/stereo3d.c b/libavutil/stereo3d.c
index e8e5030db9..c182b18e52 100644
--- a/libavutil/stereo3d.c
+++ b/libavutil/stereo3d.c
@@ -32,6 +32,11 @@ static void get_defaults(AVStereo3D *stereo)
}
AVStereo3D *av_stereo3d_alloc(void)
+{
+ return av_stereo3d_alloc_size(NULL);
+}
+
+AVStereo3D *av_stereo3d_alloc_size(size_t *size)
{
AVStereo3D *stereo = av_mallocz(sizeof(AVStereo3D));
if (!stereo)
@@ -39,6 +44,9 @@ AVStereo3D *av_stereo3d_alloc(void)
get_defaults(stereo);
+ if (size)
+ *size = sizeof(*stereo);
+
return stereo;
}
diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h
index e3af519e03..31167c14fa 100644
--- a/libavutil/stereo3d.h
+++ b/libavutil/stereo3d.h
@@ -251,6 +251,14 @@ typedef struct AVStereo3D {
*/
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().
+ *
+ * @return An AVStereo3D filled with default values or NULL on failure.
+ */
+AVStereo3D *av_stereo3d_alloc_size(size_t *size);
+
/**
* Allocate a complete AVFrameSideData and add it to the frame.
*
--
2.45.2
More information about the ffmpeg-devel
mailing list