Message ID | AS8P250MB074434FCF48B2095E6D088D48F0D2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM |
---|---|
State | Accepted |
Commit | 1d17d84b7d564228629d78c1c510de467662c5bc |
Headers | show |
Series | [FFmpeg-devel,1/5] avcodec/progressframe: Explain how unnamed union can simplify accesses | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
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;
This relies on the common initial seqence guarantee (and on C11 support for unnamed members). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- Alternatively, we could rely on type punning via unions and even use union { AVFrame *const f; ProgressFrame pf; }; libavcodec/progressframe.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)