* [FFmpeg-devel] [PATCH] avutil/avutil: make AV_TIME_BASE_Q available in C++
@ 2023-08-28 16:52 Zhao Zhili
0 siblings, 0 replies; only message in thread
From: Zhao Zhili @ 2023-08-28 16:52 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
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@tencent.com>
---
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 ad1efe708d..233c53b04a 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-08-28 - xxxxxxxxxx - lavu 58.18.100 - avutil.h
+ Make AV_TIME_BASE_Q compatible with C++.
+
2023-08-18 - xxxxxxxxxx - lavu 58.17.100 - channel_layout.h
All AV_CHANNEL_LAYOUT_* macros are now compatible with C++ 17 and older.
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 64b68bdbd3..48e54e25b9 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 bc43baca9f..6d27f91cce 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 58
-#define LIBAVUTIL_VERSION_MINOR 17
+#define LIBAVUTIL_VERSION_MINOR 18
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-28 8:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28 16:52 [FFmpeg-devel] [PATCH] avutil/avutil: make AV_TIME_BASE_Q available in C++ Zhao Zhili
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git