[FFmpeg-devel] [RFC PATCH] avutil/avutil: make AV_TIME_BASE_Q available in C++

Zhao Zhili quinkblack at foxmail.com
Fri Aug 18 21:11:31 EEST 2023


From: Zhao Zhili <zhilizhao at tencent.com>

It still different than AV_TIME_BASE_Q in C, like you cannot take
address of AV_TIME_BASE_Q in C++. It's better than nothing.
---
 libavutil/avutil.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 64b68bdbd3..5201cc6c5e 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -257,7 +257,12 @@ const char *av_get_media_type_string(enum AVMediaType media_type);
  * Internal time base represented as fractional value
  */
 
+#ifdef __cplusplus
+/* ISO C++ forbids compound-literals. */
+#define AV_TIME_BASE_Q          AVRational{1, AV_TIME_BASE}
+#else
 #define AV_TIME_BASE_Q          (AVRational){1, AV_TIME_BASE}
+#endif
 
 /**
  * @}
-- 
2.25.1



More information about the ffmpeg-devel mailing list