1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-12-04 14:00:22 +02:00

avcodec/codec_internal: Avoid deprecation warnings for channel_layouts

AVCodec.channel_layouts is deprecated and Clang (unlike GCC)
warns when setting this field in a codec definition.
Fortunately, Clang (unlike GCC) allows to use
FF_DISABLE_DEPRECATION_WARNINGS inside a definition (of an FFCodec),
so that one can create simple macros to set AVCodec.channel_layouts
that also suppress deprecation warnings for Clang.

(Notice that some of the codec definitions were already
inside FF_DISABLE/ENABLE_DEPRECATION_WARNINGS (that were not
guarded by FF_API_OLD_CHANNEL_LAYOUT); these have been removed.
Also notice that setting AVCodec.channel_layouts was not guarded
by FF_API_OLD_CHANNEL_LAYOUT either, so testing disabling it
it without removing all the codeblocks would not have worked.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2022-09-26 01:10:51 +02:00
parent 4393331250
commit fdff1b9cbf
30 changed files with 57 additions and 140 deletions

View File

@@ -276,6 +276,25 @@ typedef struct FFCodec {
.update_thread_context_for_user = NULL
#endif
#if FF_API_OLD_CHANNEL_LAYOUT
#define CODEC_OLD_CHANNEL_LAYOUTS(...) CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(((const uint64_t[]) { __VA_ARGS__, 0 }))
#if defined(__clang__)
#define CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(array) \
FF_DISABLE_DEPRECATION_WARNINGS \
.p.channel_layouts = (array), \
FF_ENABLE_DEPRECATION_WARNINGS
#else
#define CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(array) .p.channel_layouts = (array),
#endif
#else
/* This is only provided to allow to test disabling FF_API_OLD_CHANNEL_LAYOUT
* without removing all the FF_API_OLD_CHANNEL_LAYOUT codeblocks.
* It is of course still expected to be removed when FF_API_OLD_CHANNEL_LAYOUT
* will be finally removed (along with all usages of these macros). */
#define CODEC_OLD_CHANNEL_LAYOUTS(...)
#define CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(array)
#endif
#define FF_CODEC_DECODE_CB(func) \
.cb_type = FF_CODEC_CB_TYPE_DECODE, \
.cb.decode = (func)