[FFmpeg-cvslog] avutil/avutil: make AV_TIME_BASE_Q available in C++

Zhao Zhili git at videolan.org
Mon Sep 18 20:01:59 EEST 2023


ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Tue Sep 19 00:52:21 2023 +0800| [ba9cd06c763648ecd1f447d7a672a0da85749d30] | committer: Zhao Zhili

avutil/avutil: make AV_TIME_BASE_Q available in C++

ISO C++ forbids compound-literals. It's not available with MSVC.
This is a known issue from 10 years ago, and that's why there is a
av_get_time_base_q().

Since we have no plan to remove AV_TIME_BASE_Q, just make it
available in C++.

There are multiple choices:
1. Use C++11 syntax: AVRational{1, AV_TIME_BASE}

Users may still use C++98 to write new code. So no.

2. Use av_get_time_base_q().

It's for this purpose. But it's not compile time constants as
AV_TIME_BASE_Q in C.

So I choose av_make_q() as Anton's suggestion.

https://libav-devel.libav.narkive.com/ZQCWfTun/patch-0-2-fix-avutil-h-usage-from-c
Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ba9cd06c763648ecd1f447d7a672a0da85749d30
---

 doc/APIchanges      | 3 +++
 libavutil/avutil.h  | 5 +++++
 libavutil/version.h | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index d818a0514e..f333ff5b24 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-09-19 - xxxxxxxxxx - lavu 58.25.100 - avutil.h
+  Make AV_TIME_BASE_Q compatible with C++.
+
 2023-09-xx - xxxxxxxxxx - lavf 60 - avformat.h
   Deprecate AVFMT_FLAG_SHORTEST without replacement.
 
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 30bec192f1..a362c8baa8 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          av_make_q(1, AV_TIME_BASE)
+#else
 #define AV_TIME_BASE_Q          (AVRational){1, AV_TIME_BASE}
+#endif
 
 /**
  * @}
diff --git a/libavutil/version.h b/libavutil/version.h
index 132e5ffc84..00f229d233 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  58
-#define LIBAVUTIL_VERSION_MINOR  24
+#define LIBAVUTIL_VERSION_MINOR  25
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list