diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-03-22 22:34:21 +0300 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-04-13 00:23:49 +0300 |
commit | 14dd0a9057019e97ff9438f6cc1502f6922acb85 (patch) | |
tree | 68e4f03323b8b503a8ce6dcc5ce7fa3a5d4ee9db /libavcodec/cbs_vp9.c | |
parent | b7d9507bb8c4d1b8bf99158d6859a5b2ecd73298 (diff) |
avcodec/cbs: Avoid leaving the ... out in calls to variadic macros
According to C99, there has to be at least one argument for every ...
in a variadic function-like macro. In practice most (all?) compilers also
allow to leave it completely out, but it is nevertheless required: In a
variadic macro "there shall be more arguments in the invocation than there
are parameters in the macro definition (excluding the ...)." (C99,
6.10.3.4).
CBS (not the framework itself, but the macros used in the
cbs_*_syntax_template.c files) relies on the compiler allowing to leave
a variadic macro argument out. This leads to warnings when compiling in
-pedantic mode, e.g. "warning: must specify at least one argument for
'...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]"
from Clang.
Most of these warnings can be easily avoided: The syntax_templates
mostly contain helper macros that expand to more complex variadic macros
and these helper macros often omit an argument for the .... Modifying
them to always expand to complex macros with an empty argument for the
... at the end fixes most of these warnings: The number of warnings went
down from 400 to 0 for cbs_av1, from 1114 to 32 for cbs_h2645, from 38 to
0 for cbs_jpeg, from 166 to 0 for cbs_mpeg2 and from 110 to 8 for cbs_vp9.
These eight remaining warnings for cbs_vp9 have been fixed by switching
to another macro in cbs_vp9_syntax_template: The fixed values for the
sync bytes as well as the trailing bits for byte-alignment are now read
via the fixed() macro (this also adds a check to ensure that trailing
bits are indeed zero as they have to be).
Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/cbs_vp9.c')
-rw-r--r-- | libavcodec/cbs_vp9.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c index ec82f11c76..eef603bfb2 100644 --- a/libavcodec/cbs_vp9.c +++ b/libavcodec/cbs_vp9.c @@ -253,15 +253,14 @@ static int cbs_vp9_write_le(CodedBitstreamContext *ctx, PutBitContext *pbc, #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL) #define f(width, name) \ - xf(width, name, current->name, 0) + xf(width, name, current->name, 0, ) #define s(width, name) \ - xs(width, name, current->name, 0) + xs(width, name, current->name, 0, ) #define fs(width, name, subs, ...) \ xf(width, name, current->name, subs, __VA_ARGS__) #define ss(width, name, subs, ...) \ xs(width, name, current->name, subs, __VA_ARGS__) - #define READ #define READWRITE read #define RWContext GetBitContext @@ -295,9 +294,9 @@ static int cbs_vp9_write_le(CodedBitstreamContext *ctx, PutBitContext *pbc, #define delta_q(name) do { \ uint8_t delta_coded; \ int8_t delta_q; \ - xf(1, name.delta_coded, delta_coded, 0); \ + xf(1, name.delta_coded, delta_coded, 0, ); \ if (delta_coded) \ - xs(4, name.delta_q, delta_q, 0); \ + xs(4, name.delta_q, delta_q, 0, ); \ else \ delta_q = 0; \ current->name = delta_q; \ @@ -366,9 +365,9 @@ static int cbs_vp9_write_le(CodedBitstreamContext *ctx, PutBitContext *pbc, } while (0) #define delta_q(name) do { \ - xf(1, name.delta_coded, !!current->name, 0); \ + xf(1, name.delta_coded, !!current->name, 0, ); \ if (current->name) \ - xs(4, name.delta_q, current->name, 0); \ + xs(4, name.delta_q, current->name, 0, ); \ } while (0) #define prob(name, subs, ...) do { \ |