diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-03-07 01:19:27 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-03-10 00:57:23 +0100 |
commit | 0971fcf0a0821388c5258f46f73bdfbdeadd1b52 (patch) | |
tree | 492901755220c4b71d211b1eeab5412d04d0d89f /libavcodec/codec_internal.h | |
parent | 0349ae3ec4c2d381b0ce163b4195ecbba422a484 (diff) | |
download | ffmpeg-0971fcf0a0821388c5258f46f73bdfbdeadd1b52.tar.gz |
avcodec/codec_internal, all: Use macros to set deprecated AVCodec fields
The aim of this is twofold: a) Clang warns when setting a deprecated
field in a definition and because several of the widely set
AVCodec fields are deprecated, one gets several hundred warnings
from Clang for an ordinary build. Yet fortunately Clang (unlike GCC)
allows to disable deprecation warnings inside a definition, so
that one can create simple macros to set these fields that also suppress
deprecation warnings for Clang. This has already been done in
fdff1b9cbfd8cf5a9810c29efa4baf13a4786742 for AVCodec.channel_layouts.
b) Using macros will allow to easily migrate these fields to internal ones.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/codec_internal.h')
-rw-r--r-- | libavcodec/codec_internal.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 473d72fdbb..b2df8e729a 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -327,6 +327,34 @@ int ff_default_get_supported_config(const struct AVCodecContext *avctx, .cb_type = FF_CODEC_CB_TYPE_RECEIVE_PACKET, \ .cb.receive_packet = (func) +#ifdef __clang__ +#define DISABLE_DEPRECATION_WARNINGS FF_DISABLE_DEPRECATION_WARNINGS +#define ENABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS +#else +#define DISABLE_DEPRECATION_WARNINGS +#define ENABLE_DEPRECATION_WARNINGS +#endif + +#define CODEC_CH_LAYOUTS(...) CODEC_CH_LAYOUTS_ARRAY(((const AVChannelLayout[]) { __VA_ARGS__, { 0 } })) +#define CODEC_CH_LAYOUTS_ARRAY(array) CODEC_ARRAY(ch_layouts, (array)) + +#define CODEC_SAMPLERATES(...) CODEC_SAMPLERATES_ARRAY(((const int[]) { __VA_ARGS__, 0 })) +#define CODEC_SAMPLERATES_ARRAY(array) CODEC_ARRAY(supported_samplerates, (array)) + +#define CODEC_SAMPLEFMTS(...) CODEC_SAMPLEFMTS_ARRAY(((const enum AVSampleFormat[]) { __VA_ARGS__, AV_SAMPLE_FMT_NONE })) +#define CODEC_SAMPLEFMTS_ARRAY(array) CODEC_ARRAY(sample_fmts, (array)) + +#define CODEC_FRAMERATES(...) CODEC_FRAMERATES_ARRAY(((const AVRational[]) { __VA_ARGS__, { 0, 0 } })) +#define CODEC_FRAMERATES_ARRAY(array) CODEC_ARRAY(supported_framerates, (array)) + +#define CODEC_PIXFMTS(...) CODEC_PIXFMTS_ARRAY(((const enum AVPixelFormat[]) { __VA_ARGS__, AV_PIX_FMT_NONE })) +#define CODEC_PIXFMTS_ARRAY(array) CODEC_ARRAY(pix_fmts, (array)) + +#define CODEC_ARRAY(field, array) \ + DISABLE_DEPRECATION_WARNINGS \ + .p.field = (array) \ + ENABLE_DEPRECATION_WARNINGS + static av_always_inline const FFCodec *ffcodec(const AVCodec *codec) { return (const FFCodec*)codec; |