Message ID | tencent_9C6A0201BD68527CF2AC123AEDC3E1B5E40A@qq.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,RFC] avutil/avutil: make AV_TIME_BASE_Q available in C++ | 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 |
On Sat, Aug 19, 2023 at 02:11:31AM +0800, Zhao Zhili wrote: > From: Zhao Zhili <zhilizhao@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. > --- iam in favor of better C++ compatibility of public headers thx [...]
Quoting Zhao Zhili (2023-08-18 20: 11:31) > From: Zhao Zhili <zhilizhao@tencent.com> Date: Tue, 22 Aug 2023 14:29:44 +0200 Message-ID: <169270738483.26513.18411031229205897825@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 > > 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} How about av_make_q(1, AV_TIME_BASE_Q)? I don't know how the above syntax works.
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 /** * @}
From: Zhao Zhili <zhilizhao@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(+)