Browse code

Add LOCAL_ALIGNED() macro for declaring aligned local arrays

Originally committed as revision 21864 to svn://svn.ffmpeg.org/ffmpeg/trunk

Måns Rullgård authored on 2010/02/18 05:36:12
Showing 2 changed files
... ...
@@ -1035,6 +1035,8 @@ HAVE_LIST="
1035 1035
     libdc1394_1
1036 1036
     libdc1394_2
1037 1037
     llrint
1038
+    local_aligned_16
1039
+    local_aligned_8
1038 1040
     log2
1039 1041
     log2f
1040 1042
     loongson
... ...
@@ -700,6 +700,22 @@ static inline void emms(void)
700 700
 #   define STRIDE_ALIGN 8
701 701
 #endif
702 702
 
703
+#define LOCAL_ALIGNED(a, t, v, s, ...)                          \
704
+    uint8_t la_##v[sizeof(t s __VA_ARGS__) + (a)];              \
705
+    t (*v) __VA_ARGS__ = (void *)FFALIGN((uintptr_t)la_##v, a)
706
+
707
+#if HAVE_LOCAL_ALIGNED_8
708
+#   define LOCAL_ALIGNED_8((t, v, s, ...) DECLARE_ALIGNED_8(t, v) s __VA_ARGS__
709
+#else
710
+#   define LOCAL_ALIGNED_8(t, v, s, ...) LOCAL_ALIGNED(8, t, v, s, __VA_ARGS__)
711
+#endif
712
+
713
+#if HAVE_LOCAL_ALIGNED_16
714
+#   define LOCAL_ALIGNED_16((t, v, s, ...) DECLARE_ALIGNED_16(t, v) s __VA_ARGS__
715
+#else
716
+#   define LOCAL_ALIGNED_16(t, v, s, ...) LOCAL_ALIGNED(16, t, v, s, __VA_ARGS__)
717
+#endif
718
+
703 719
 /* PSNR */
704 720
 void get_psnr(uint8_t *orig_image[3], uint8_t *coded_image[3],
705 721
               int orig_linesize[3], int coded_linesize,