[FFmpeg-devel] [PATCH 1/2] lavu/internal: add FF_FIELD_AT().

Nicolas George george at nsup.org
Sat Jul 24 18:29:46 EEST 2021


Signed-off-by: Nicolas George <george at nsup.org>
---
 libavutil/internal.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavutil/internal.h b/libavutil/internal.h
index a33e8700c3..2011813932 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -103,6 +103,11 @@
 
 #define FF_PTR_ADD(ptr, off) ((off) ? (ptr) + (off) : (ptr))
 
+/**
+ * Access a field in a structure by its offset.
+ */
+#define FF_FIELD_AT(type, off, obj) (*(type *)((char *)&(obj) + (off)))
+
 #include "libm.h"
 
 /**
-- 
2.30.2



More information about the ffmpeg-devel mailing list