diff mbox series

[FFmpeg-devel,05/15] avformat/pcm(dec|enc): Don't include disabled (de)muxers

Message ID 20210224115341.794293-5-andreas.rheinhardt@gmail.com
State Accepted
Commit 301ae25e999d9771a4ece0e3d6f0983797dcc65a
Headers show
Series [FFmpeg-devel,01/15] avformat/movenc: Remove always true check | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 24, 2021, 11:53 a.m. UTC
Also make the macro used for the demuxers spec-compliant. The earlier
macro was not, because the ... argument of a variadic macro must not be
left out. GCC and Clang warn about this when using -pedantic.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/pcmdec.c | 102 ++++++++++++++++---------------------------
 libavformat/pcmenc.c |  95 +++++++++++++---------------------------
 2 files changed, 68 insertions(+), 129 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 9895af03a4..e65b535665 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -104,7 +104,8 @@  static const AVOption pcm_options[] = {
     { NULL },
 };
 
-#define PCMDEF(name_, long_name_, ext, codec, ...)          \
+#define PCMDEF_0(name_, long_name_, ext, codec, ...)
+#define PCMDEF_1(name_, long_name_, ext, codec, ...)        \
 static const AVClass name_ ## _demuxer_class = {            \
     .class_name = #name_ " demuxer",                        \
     .item_name  = av_default_item_name,                     \
@@ -124,70 +125,40 @@  AVInputFormat ff_pcm_ ## name_ ## _demuxer = {              \
     .priv_class     = &name_ ## _demuxer_class,             \
     __VA_ARGS__                                             \
 };
-
-PCMDEF(f64be, "PCM 64-bit floating-point big-endian",
-       NULL, AV_CODEC_ID_PCM_F64BE)
-
-PCMDEF(f64le, "PCM 64-bit floating-point little-endian",
-       NULL, AV_CODEC_ID_PCM_F64LE)
-
-PCMDEF(f32be, "PCM 32-bit floating-point big-endian",
-       NULL, AV_CODEC_ID_PCM_F32BE)
-
-PCMDEF(f32le, "PCM 32-bit floating-point little-endian",
-       NULL, AV_CODEC_ID_PCM_F32LE)
-
-PCMDEF(s32be, "PCM signed 32-bit big-endian",
-       NULL, AV_CODEC_ID_PCM_S32BE)
-
-PCMDEF(s32le, "PCM signed 32-bit little-endian",
-       NULL, AV_CODEC_ID_PCM_S32LE)
-
-PCMDEF(s24be, "PCM signed 24-bit big-endian",
-       NULL, AV_CODEC_ID_PCM_S24BE)
-
-PCMDEF(s24le, "PCM signed 24-bit little-endian",
-       NULL, AV_CODEC_ID_PCM_S24LE)
-
-PCMDEF(s16be, "PCM signed 16-bit big-endian",
-       AV_NE("sw", NULL), AV_CODEC_ID_PCM_S16BE, .mime_type = "audio/L16")
-
-PCMDEF(s16le, "PCM signed 16-bit little-endian",
-       AV_NE(NULL, "sw"), AV_CODEC_ID_PCM_S16LE)
-
-PCMDEF(s8, "PCM signed 8-bit",
-       "sb", AV_CODEC_ID_PCM_S8)
-
-PCMDEF(u32be, "PCM unsigned 32-bit big-endian",
-       NULL, AV_CODEC_ID_PCM_U32BE)
-
-PCMDEF(u32le, "PCM unsigned 32-bit little-endian",
-       NULL, AV_CODEC_ID_PCM_U32LE)
-
-PCMDEF(u24be, "PCM unsigned 24-bit big-endian",
-       NULL, AV_CODEC_ID_PCM_U24BE)
-
-PCMDEF(u24le, "PCM unsigned 24-bit little-endian",
-       NULL, AV_CODEC_ID_PCM_U24LE)
-
-PCMDEF(u16be, "PCM unsigned 16-bit big-endian",
-       AV_NE("uw", NULL), AV_CODEC_ID_PCM_U16BE)
-
-PCMDEF(u16le, "PCM unsigned 16-bit little-endian",
-       AV_NE(NULL, "uw"), AV_CODEC_ID_PCM_U16LE)
-
-PCMDEF(u8, "PCM unsigned 8-bit",
-       "ub", AV_CODEC_ID_PCM_U8)
-
-PCMDEF(alaw, "PCM A-law",
-       "al", AV_CODEC_ID_PCM_ALAW)
-
-PCMDEF(mulaw, "PCM mu-law",
-       "ul", AV_CODEC_ID_PCM_MULAW)
-
-PCMDEF(vidc, "PCM Archimedes VIDC",
-       NULL, AV_CODEC_ID_PCM_VIDC)
-
+#define PCMDEF_2(name, long_name, ext, codec, enabled, ...) \
+    PCMDEF_ ## enabled(name, long_name, ext, codec, __VA_ARGS__)
+#define PCMDEF_3(name, long_name, ext, codec, config, ...)  \
+    PCMDEF_2(name, long_name, ext, codec, config,   __VA_ARGS__)
+#define PCMDEF_EXT(name, long_name, ext, uppercase, ...)    \
+    PCMDEF_3(name, long_name, ext, AV_CODEC_ID_PCM_ ## uppercase, \
+             CONFIG_PCM_ ## uppercase ## _DEMUXER,  __VA_ARGS__)
+#define PCMDEF(name, long_name, ext, uppercase)             \
+    PCMDEF_EXT(name, long_name, ext, uppercase, )
+
+PCMDEF(f64be, "PCM 64-bit floating-point big-endian",           NULL, F64BE)
+PCMDEF(f64le, "PCM 64-bit floating-point little-endian",        NULL, F64LE)
+PCMDEF(f32be, "PCM 32-bit floating-point big-endian",           NULL, F32BE)
+PCMDEF(f32le, "PCM 32-bit floating-point little-endian",        NULL, F32LE)
+PCMDEF(s32be, "PCM signed 32-bit big-endian",                   NULL, S32BE)
+PCMDEF(s32le, "PCM signed 32-bit little-endian",                NULL, S32LE)
+PCMDEF(s24be, "PCM signed 24-bit big-endian",                   NULL, S24BE)
+PCMDEF(s24le, "PCM signed 24-bit little-endian",                NULL, S24LE)
+PCMDEF_EXT(s16be, "PCM signed 16-bit big-endian",
+           AV_NE("sw", NULL), S16BE, .mime_type = "audio/L16")
+PCMDEF(s16le, "PCM signed 16-bit little-endian",   AV_NE(NULL, "sw"), S16LE)
+PCMDEF(s8,    "PCM signed 8-bit",                               "sb",    S8)
+PCMDEF(u32be, "PCM unsigned 32-bit big-endian",                 NULL, U32BE)
+PCMDEF(u32le, "PCM unsigned 32-bit little-endian",              NULL, U32LE)
+PCMDEF(u24be, "PCM unsigned 24-bit big-endian",                 NULL, U24BE)
+PCMDEF(u24le, "PCM unsigned 24-bit little-endian",              NULL, U24LE)
+PCMDEF(u16be, "PCM unsigned 16-bit big-endian",    AV_NE("uw", NULL), U16BE)
+PCMDEF(u16le, "PCM unsigned 16-bit little-endian", AV_NE(NULL, "uw"), U16LE)
+PCMDEF(u8,    "PCM unsigned 8-bit",                             "ub",    U8)
+PCMDEF(alaw,  "PCM A-law",                                      "al",  ALAW)
+PCMDEF(mulaw, "PCM mu-law",                                     "ul", MULAW)
+PCMDEF(vidc,  "PCM Archimedes VIDC",                            NULL,  VIDC)
+
+#if CONFIG_SLN_DEMUXER
 static const AVOption sln_options[] = {
     { "sample_rate", "", offsetof(PCMAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 8000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { "channels",    "", offsetof(PCMAudioDemuxerContext, channels),    AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
@@ -213,3 +184,4 @@  AVInputFormat ff_sln_demuxer = {
     .raw_codec_id   = AV_CODEC_ID_PCM_S16LE,
     .priv_class     = &sln_demuxer_class,
 };
+#endif
diff --git a/libavformat/pcmenc.c b/libavformat/pcmenc.c
index 1760b3bef7..050b9c4aa0 100644
--- a/libavformat/pcmenc.c
+++ b/libavformat/pcmenc.c
@@ -22,7 +22,8 @@ 
 #include "avformat.h"
 #include "rawenc.h"
 
-#define PCMDEF(name_, long_name_, ext, codec)               \
+#define PCMDEF_0(name_, long_name_, ext, codec)
+#define PCMDEF_1(name_, long_name_, ext, codec)             \
 AVOutputFormat ff_pcm_ ## name_ ## _muxer = {               \
     .name         = #name_,                                 \
     .long_name    = NULL_IF_CONFIG_SMALL(long_name_),       \
@@ -32,66 +33,32 @@  AVOutputFormat ff_pcm_ ## name_ ## _muxer = {               \
     .write_packet = ff_raw_write_packet,                    \
     .flags        = AVFMT_NOTIMESTAMPS,                     \
 };
-
-PCMDEF(f64be, "PCM 64-bit floating-point big-endian",
-       NULL, AV_CODEC_ID_PCM_F64BE)
-
-PCMDEF(f64le, "PCM 64-bit floating-point little-endian",
-       NULL, AV_CODEC_ID_PCM_F64LE)
-
-PCMDEF(f32be, "PCM 32-bit floating-point big-endian",
-       NULL, AV_CODEC_ID_PCM_F32BE)
-
-PCMDEF(f32le, "PCM 32-bit floating-point little-endian",
-       NULL, AV_CODEC_ID_PCM_F32LE)
-
-PCMDEF(s32be, "PCM signed 32-bit big-endian",
-       NULL, AV_CODEC_ID_PCM_S32BE)
-
-PCMDEF(s32le, "PCM signed 32-bit little-endian",
-       NULL, AV_CODEC_ID_PCM_S32LE)
-
-PCMDEF(s24be, "PCM signed 24-bit big-endian",
-       NULL, AV_CODEC_ID_PCM_S24BE)
-
-PCMDEF(s24le, "PCM signed 24-bit little-endian",
-       NULL, AV_CODEC_ID_PCM_S24LE)
-
-PCMDEF(s16be, "PCM signed 16-bit big-endian",
-       AV_NE("sw", NULL), AV_CODEC_ID_PCM_S16BE)
-
-PCMDEF(s16le, "PCM signed 16-bit little-endian",
-       AV_NE(NULL, "sw"), AV_CODEC_ID_PCM_S16LE)
-
-PCMDEF(s8, "PCM signed 8-bit",
-       "sb", AV_CODEC_ID_PCM_S8)
-
-PCMDEF(u32be, "PCM unsigned 32-bit big-endian",
-       NULL, AV_CODEC_ID_PCM_U32BE)
-
-PCMDEF(u32le, "PCM unsigned 32-bit little-endian",
-       NULL, AV_CODEC_ID_PCM_U32LE)
-
-PCMDEF(u24be, "PCM unsigned 24-bit big-endian",
-       NULL, AV_CODEC_ID_PCM_U24BE)
-
-PCMDEF(u24le, "PCM unsigned 24-bit little-endian",
-       NULL, AV_CODEC_ID_PCM_U24LE)
-
-PCMDEF(u16be, "PCM unsigned 16-bit big-endian",
-       AV_NE("uw", NULL), AV_CODEC_ID_PCM_U16BE)
-
-PCMDEF(u16le, "PCM unsigned 16-bit little-endian",
-       AV_NE(NULL, "uw"), AV_CODEC_ID_PCM_U16LE)
-
-PCMDEF(u8, "PCM unsigned 8-bit",
-       "ub", AV_CODEC_ID_PCM_U8)
-
-PCMDEF(alaw, "PCM A-law",
-       "al", AV_CODEC_ID_PCM_ALAW)
-
-PCMDEF(mulaw, "PCM mu-law",
-       "ul", AV_CODEC_ID_PCM_MULAW)
-
-PCMDEF(vidc, "PCM Archimedes VIDC",
-       NULL, AV_CODEC_ID_PCM_VIDC)
+#define PCMDEF_2(name, long_name, ext, codec, enabled)      \
+    PCMDEF_ ## enabled(name, long_name, ext, codec)
+#define PCMDEF_3(name, long_name, ext, codec, config)       \
+    PCMDEF_2(name, long_name, ext, codec, config)
+#define PCMDEF(name, long_name, ext, uppercase)             \
+    PCMDEF_3(name, long_name, ext, AV_CODEC_ID_PCM_ ## uppercase, \
+             CONFIG_PCM_ ## uppercase ## _MUXER)
+
+PCMDEF(f64be, "PCM 64-bit floating-point big-endian",           NULL, F64BE)
+PCMDEF(f64le, "PCM 64-bit floating-point little-endian",        NULL, F64LE)
+PCMDEF(f32be, "PCM 32-bit floating-point big-endian",           NULL, F32BE)
+PCMDEF(f32le, "PCM 32-bit floating-point little-endian",        NULL, F32LE)
+PCMDEF(s32be, "PCM signed 32-bit big-endian",                   NULL, S32BE)
+PCMDEF(s32le, "PCM signed 32-bit little-endian",                NULL, S32LE)
+PCMDEF(s24be, "PCM signed 24-bit big-endian",                   NULL, S24BE)
+PCMDEF(s24le, "PCM signed 24-bit little-endian",                NULL, S24LE)
+PCMDEF(s16be, "PCM signed 16-bit big-endian",      AV_NE("sw", NULL), S16BE)
+PCMDEF(s16le, "PCM signed 16-bit little-endian",   AV_NE(NULL, "sw"), S16LE)
+PCMDEF(s8,    "PCM signed 8-bit",                               "sb",    S8)
+PCMDEF(u32be, "PCM unsigned 32-bit big-endian",                 NULL, U32BE)
+PCMDEF(u32le, "PCM unsigned 32-bit little-endian",              NULL, U32LE)
+PCMDEF(u24be, "PCM unsigned 24-bit big-endian",                 NULL, U24BE)
+PCMDEF(u24le, "PCM unsigned 24-bit little-endian",              NULL, U24LE)
+PCMDEF(u16be, "PCM unsigned 16-bit big-endian",    AV_NE("uw", NULL), U16BE)
+PCMDEF(u16le, "PCM unsigned 16-bit little-endian", AV_NE(NULL, "uw"), U16LE)
+PCMDEF(u8,    "PCM unsigned 8-bit",                             "ub",    U8)
+PCMDEF(alaw,  "PCM A-law",                                      "al",  ALAW)
+PCMDEF(mulaw, "PCM mu-law",                                     "ul", MULAW)
+PCMDEF(vidc,  "PCM Archimedes VIDC",                            NULL,  VIDC)