From: "Ronald S. Bultje" <[email protected]>

MSVC has incomplete variadic macro argument handling, meaning it does
support it to some extend, but it will basically handle all variadic
arguments as a single argument, including the comma that separates them,
thus making it useless for anything else than as a function argument.
Our implementation of LOCAL_ALIGNED() breaks because of this, thus here
we implement an alternative form of LOCAL_ALIGNED() that does not use
variadic macro arguments.
---
 configure                    |    1 +
 libavcodec/aacps.c           |   10 +++++-----
 libavcodec/aacsbr.c          |    2 +-
 libavcodec/ac3enc.c          |    2 +-
 libavcodec/ac3enc_template.c |    4 ++--
 libavcodec/dsputil.h         |   26 ++++++++++++++++++--------
 libavcodec/dvdec.c           |    2 +-
 libavcodec/h264_loopfilter.c |    2 +-
 libavcodec/ra288.c           |    6 +++---
 9 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/configure b/configure
index 61b773f..c596691 100755
--- a/configure
+++ b/configure
@@ -1105,6 +1105,7 @@ HAVE_LIST="
     llrint
     llrintf
     local_aligned_16
+    local_aligned_32
     local_aligned_8
     localtime_r
     log2
diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c
index fa7e9ac..d0b3d9e 100644
--- a/libavcodec/aacps.c
+++ b/libavcodec/aacps.c
@@ -309,7 +309,7 @@ static void hybrid6_cx(PSDSPContext *dsp, float (*in)[2], 
float (*out)[32][2], c
 {
     int i;
     int N = 8;
-    LOCAL_ALIGNED_16(float, temp, [8], [2]);
+    LOCAL_ALIGNED_16_2D(float, temp, [8], [2]);
 
     for (i = 0; i < len; i++, in++) {
         dsp->hybrid_analysis(temp, in, filter, 1, N);
@@ -608,8 +608,8 @@ static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC])
 
 static void decorrelation(PSContext *ps, float (*out)[32][2], const float 
(*s)[32][2], int is34)
 {
-    LOCAL_ALIGNED_16(float, power, [34], [PS_QMF_TIME_SLOTS]);
-    LOCAL_ALIGNED_16(float, transient_gain, [34], [PS_QMF_TIME_SLOTS]);
+    LOCAL_ALIGNED_16_2D(float, power, [34], [PS_QMF_TIME_SLOTS]);
+    LOCAL_ALIGNED_16_2D(float, transient_gain, [34], [PS_QMF_TIME_SLOTS]);
     float *peak_decay_nrg = ps->peak_decay_nrg;
     float *power_smooth = ps->power_smooth;
     float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth;
@@ -886,8 +886,8 @@ static void stereo_processing(PSContext *ps, float 
(*l)[32][2], float (*r)[32][2
 
 int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], 
float R[2][38][64], int top)
 {
-    LOCAL_ALIGNED_16(float, Lbuf, [91], [32][2]);
-    LOCAL_ALIGNED_16(float, Rbuf, [91], [32][2]);
+    LOCAL_ALIGNED_16_2D(float, Lbuf, [91], [32][2]);
+    LOCAL_ALIGNED_16_2D(float, Rbuf, [91], [32][2]);
     const int len = 32;
     int is34 = ps->is34bands;
 
diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
index 5eca115..40aea3d 100644
--- a/libavcodec/aacsbr.c
+++ b/libavcodec/aacsbr.c
@@ -1232,7 +1232,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
 {
     int k;
     for (k = 0; k < k0; k++) {
-        LOCAL_ALIGNED_16(float, phi, [3], [2][2]);
+        LOCAL_ALIGNED_16_2D(float, phi, [3], [2][2]);
         float dk;
 
         dsp->autocorrelate(X_low[k], phi);
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 50d7f70..c459f90 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1037,7 +1037,7 @@ static void 
count_mantissa_bits_update_ch(AC3EncodeContext *s, int ch,
 static int count_mantissa_bits(AC3EncodeContext *s)
 {
     int ch, max_end_freq;
-    LOCAL_ALIGNED_16(uint16_t, mant_cnt, [AC3_MAX_BLOCKS], [16]);
+    LOCAL_ALIGNED_16_2D(uint16_t, mant_cnt, [AC3_MAX_BLOCKS], [16]);
 
     count_mantissa_bits_init(mant_cnt);
 
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index 6e0a2b6..62737b1 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -130,9 +130,9 @@ static void apply_mdct(AC3EncodeContext *s)
  */
 static void apply_channel_coupling(AC3EncodeContext *s)
 {
-    LOCAL_ALIGNED_16(CoefType, cpl_coords,      [AC3_MAX_BLOCKS], 
[AC3_MAX_CHANNELS][16]);
+    LOCAL_ALIGNED_16_2D(CoefType, cpl_coords,      [AC3_MAX_BLOCKS], 
[AC3_MAX_CHANNELS][16]);
 #if CONFIG_AC3ENC_FLOAT
-    LOCAL_ALIGNED_16(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], 
[AC3_MAX_CHANNELS][16]);
+    LOCAL_ALIGNED_16_2D(int32_t, fixed_cpl_coords, [AC3_MAX_BLOCKS], 
[AC3_MAX_CHANNELS][16]);
 #else
     int32_t (*fixed_cpl_coords)[AC3_MAX_CHANNELS][16] = cpl_coords;
 #endif
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index 77980e0..b0f827d 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -640,24 +640,34 @@ void ff_mlp_init_x86(DSPContext* c, AVCodecContext 
*avctx);
 #   define STRIDE_ALIGN 8
 #endif
 
-#define LOCAL_ALIGNED_A(a, t, v, s, o, ...)             \
+#define LOCAL_ALIGNED_A(a, t, v, s, o)                  \
     uint8_t la_##v[sizeof(t s o) + (a)];                \
     t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)
 
-#define LOCAL_ALIGNED_D(a, t, v, s, o, ...) DECLARE_ALIGNED(a, t, v) s o
-
-#define LOCAL_ALIGNED(a, t, v, ...) LOCAL_ALIGNED_A(a, t, v, __VA_ARGS__,,)
+#define LOCAL_ALIGNED_D(a, t, v, s, o) DECLARE_ALIGNED(a, t, v) s o
 
 #if HAVE_LOCAL_ALIGNED_8
-#   define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,)
+#   define LOCAL_ALIGNED_8(t, v, s)       LOCAL_ALIGNED_D(8, t, v, s,)
+#   define LOCAL_ALIGNED_8_2D(t, v, s, o) LOCAL_ALIGNED_D(8, t, v, s, o)
 #else
-#   define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED(8, t, v, __VA_ARGS__)
+#   define LOCAL_ALIGNED_8(t, v, s)       LOCAL_ALIGNED_A(8, t, v, s,)
+#   define LOCAL_ALIGNED_8_2D(t, v, s, o) LOCAL_ALIGNED_A(8, t, v, s, o)
 #endif
 
 #if HAVE_LOCAL_ALIGNED_16
-#   define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,)
+#   define LOCAL_ALIGNED_16(t, v, s)       LOCAL_ALIGNED_D(16, t, v, s,)
+#   define LOCAL_ALIGNED_16_2D(t, v, s, o) LOCAL_ALIGNED_D(16, t, v, s, o)
+#else
+#   define LOCAL_ALIGNED_16(t, v, s)       LOCAL_ALIGNED_A(16, t, v, s,)
+#   define LOCAL_ALIGNED_16_2D(t, v, s, o) LOCAL_ALIGNED_A(16, t, v, s, o)
+#endif
+
+#if HAVE_LOCAL_ALIGNED_32
+#   define LOCAL_ALIGNED_32(t, v, s)       LOCAL_ALIGNED_D(32, t, v, s,)
+#   define LOCAL_ALIGNED_32_2D(t, v, s, o) LOCAL_ALIGNED_D(32, t, v, s, o)
 #else
-#   define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED(16, t, v, __VA_ARGS__)
+#   define LOCAL_ALIGNED_32(t, v, s)       LOCAL_ALIGNED_A(32, t, v, s,)
+#   define LOCAL_ALIGNED_32_2D(t, v, s, o) LOCAL_ALIGNED_A(32, t, v, s, o)
 #endif
 
 #define WRAPPER8_16(name8, name16)\
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 8a21267..b70935e 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -141,7 +141,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, 
void *arg)
     PutBitContext pb, vs_pb;
     GetBitContext gb;
     BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;
-    LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]);
+    LOCAL_ALIGNED_16_2D(DCTELEM, sblock, [5*DV_MAX_BPM], [64]);
     LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [  80 + 
FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */
     LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5*80 + 
FF_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */
     const int log2_blocksize = 3;
diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c
index be750ca..ebba406 100644
--- a/libavcodec/h264_loopfilter.c
+++ b/libavcodec/h264_loopfilter.c
@@ -359,7 +359,7 @@ static av_always_inline void 
h264_filter_mb_fast_internal(H264Context *h,
         }
         return;
     } else {
-        LOCAL_ALIGNED_8(int16_t, bS, [2], [4][4]);
+        LOCAL_ALIGNED_8_2D(int16_t, bS, [2], [4][4]);
         int edges;
         if( IS_8x8DCT(mb_type) && (h->cbp&7) == 7 && !chroma444 ) {
             edges = 4;
diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
index aa7ad33..972ac4a 100644
--- a/libavcodec/ra288.c
+++ b/libavcodec/ra288.c
@@ -134,9 +134,9 @@ static void do_hybrid_window(RA288Context *ractx,
     int i;
     float buffer1[MAX_BACKWARD_FILTER_ORDER + 1];
     float buffer2[MAX_BACKWARD_FILTER_ORDER + 1];
-    LOCAL_ALIGNED(32, float, work, [FFALIGN(MAX_BACKWARD_FILTER_ORDER +
-                                            MAX_BACKWARD_FILTER_LEN   +
-                                            MAX_BACKWARD_FILTER_NONREC, 16)]);
+    LOCAL_ALIGNED_32(float, work, [FFALIGN(MAX_BACKWARD_FILTER_ORDER +
+                                           MAX_BACKWARD_FILTER_LEN   +
+                                           MAX_BACKWARD_FILTER_NONREC, 16)]);
 
     ractx->fdsp.vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 
16));
 
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to