diff mbox series

[FFmpeg-devel] Revert "avcodec/vlc: Add macro for ff_init_vlc_sparse()"

Message ID 20200918062435.902895-1-andreas.rheinhardt@gmail.com
State Accepted
Commit 6401a5d4b836a08090bc82e5d3101cc1873ae2a7
Headers show
Series [FFmpeg-devel] Revert "avcodec/vlc: Add macro for ff_init_vlc_sparse()"
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 18, 2020, 6:24 a.m. UTC
This reverts commit 61669b7c40b8dc3a0841768fb39c7567513b7cfc.

This commit broke building with MSVC due to its spec-incompliant handling
of ',' in __VA_ARGS__: These are not treated as argument separators for
further macros, so that in our case the init_vlc2() macro is treated as
having only one argument whenever the init_vlc() macro is used. See [1]
for further details.

[1]: https://reviews.llvm.org/D69626

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/smacker.c | 12 ++++++------
 libavcodec/vlc.h     |  7 +------
 2 files changed, 7 insertions(+), 12 deletions(-)

Comments

Hendrik Leppkes Sept. 18, 2020, 9:15 a.m. UTC | #1
On Fri, Sep 18, 2020 at 8:25 AM Andreas Rheinhardt
<andreas.rheinhardt@gmail.com> wrote:
>
> This reverts commit 61669b7c40b8dc3a0841768fb39c7567513b7cfc.
>
> This commit broke building with MSVC due to its spec-incompliant handling
> of ',' in __VA_ARGS__: These are not treated as argument separators for
> further macros, so that in our case the init_vlc2() macro is treated as
> having only one argument whenever the init_vlc() macro is used. See [1]
> for further details.
>
> [1]: https://reviews.llvm.org/D69626
>

The new preprocessor mentioned in the llvm report is now officially
available in VS2019 (ie. no longer experimental), but its opt-in to
not break old code, and of course we want to support older versions as
well for the time being, so reverting this is probably the only
realistic option.

LGTM.

- Hendrik
Andreas Rheinhardt Sept. 18, 2020, 11:03 a.m. UTC | #2
Hendrik Leppkes:
> On Fri, Sep 18, 2020 at 8:25 AM Andreas Rheinhardt
> <andreas.rheinhardt@gmail.com> wrote:
>>
>> This reverts commit 61669b7c40b8dc3a0841768fb39c7567513b7cfc.
>>
>> This commit broke building with MSVC due to its spec-incompliant handling
>> of ',' in __VA_ARGS__: These are not treated as argument separators for
>> further macros, so that in our case the init_vlc2() macro is treated as
>> having only one argument whenever the init_vlc() macro is used. See [1]
>> for further details.
>>
>> [1]: https://reviews.llvm.org/D69626
>>
> 
> The new preprocessor mentioned in the llvm report is now officially
> available in VS2019 (ie. no longer experimental), but its opt-in to
> not break old code, and of course we want to support older versions as
> well for the time being, so reverting this is probably the only
> realistic option.
> 
> LGTM.
> 
> - Hendrik

Thanks, applied.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index ffd24c11e7..813eb862c0 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -222,9 +222,9 @@  static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
         skip_bits1(gb);
         if (h.current > 1) {
             err = ff_init_vlc_sparse(&vlc[i], SMKTREE_BITS, h.current,
-                                     INIT_VLC_DEFAULT_SIZES(h.lengths),
-                                     INIT_VLC_DEFAULT_SIZES(h.bits),
-                                     INIT_VLC_DEFAULT_SIZES(h.values),
+                                     h.lengths, sizeof(*h.lengths), sizeof(*h.lengths),
+                                     h.bits,    sizeof(*h.bits),    sizeof(*h.bits),
+                                     h.values,  sizeof(*h.values),  sizeof(*h.values),
                                      INIT_VLC_LE);
             if (err < 0) {
                 av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
@@ -653,9 +653,9 @@  static int smka_decode_frame(AVCodecContext *avctx, void *data,
         skip_bits1(&gb);
         if (h.current > 1) {
             ret = ff_init_vlc_sparse(&vlc[i], SMKTREE_BITS, h.current,
-                                     INIT_VLC_DEFAULT_SIZES(h.lengths),
-                                     INIT_VLC_DEFAULT_SIZES(h.bits),
-                                     INIT_VLC_DEFAULT_SIZES(h.values),
+                                     h.lengths, sizeof(*h.lengths), sizeof(*h.lengths),
+                                     h.bits,    sizeof(*h.bits),    sizeof(*h.bits),
+                                     h.values,  sizeof(*h.values),  sizeof(*h.values),
                                      INIT_VLC_LE);
             if (ret < 0) {
                 av_log(avctx, AV_LOG_ERROR, "Cannot build VLC table\n");
diff --git a/libavcodec/vlc.h b/libavcodec/vlc.h
index 7cb323b62c..42ccddf3fc 100644
--- a/libavcodec/vlc.h
+++ b/libavcodec/vlc.h
@@ -35,12 +35,7 @@  typedef struct RL_VLC_ELEM {
     uint8_t run;
 } RL_VLC_ELEM;
 
-#define INIT_VLC_DEFAULT_SIZES(ptr) \
-    (ptr), sizeof((ptr)[0]), sizeof((ptr)[0])
-
-#define init_vlc(...) init_vlc2(__VA_ARGS__)
-
-#define init_vlc2(vlc, nb_bits, nb_codes,               \
+#define init_vlc(vlc, nb_bits, nb_codes,                \
                  bits, bits_wrap, bits_size,            \
                  codes, codes_wrap, codes_size,         \
                  flags)                                 \