[FFmpeg-cvslog] avcodec/progressframe: Explain how unnamed union can simplify accesses
Andreas Rheinhardt
git at videolan.org
Sun Apr 21 18:17:53 EEST 2024
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Apr 19 14:59:29 2024 +0200| [1d17d84b7d564228629d78c1c510de467662c5bc] | committer: Andreas Rheinhardt
avcodec/progressframe: Explain how unnamed union can simplify accesses
This relies on the common initial seqence guarantee
(and on C11 support for unnamed members).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1d17d84b7d564228629d78c1c510de467662c5bc
---
libavcodec/progressframe.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/libavcodec/progressframe.h b/libavcodec/progressframe.h
index dc841f30d2..428a461659 100644
--- a/libavcodec/progressframe.h
+++ b/libavcodec/progressframe.h
@@ -58,6 +58,18 @@
struct AVCodecContext;
+/**
+ * The ProgressFrame structure.
+ * Hint: It is guaranteed that the AVFrame pointer is at the start
+ * of ProgressFrame. This allows to use an unnamed
+ * union {
+ * struct {
+ * AVFrame *f;
+ * };
+ * ProgressFrame pf;
+ * };
+ * to simplify accessing the embedded AVFrame.
+ */
typedef struct ProgressFrame {
struct AVFrame *f;
struct ProgressInternal *progress;
More information about the ffmpeg-cvslog
mailing list