[FFmpeg-devel] [PATCH] add DECLARE_ASM_CONST

Reimar Döffinger Reimar.Doeffinger
Sun Jan 27 21:09:57 CET 2008


Hello,
not sure if this is really ideal, but here it is, the libavcodec part
only.
I put it in libavutil because it is needed (and a lot more) in
libswscale as well.
The h264.c case is a bit ugly, that array is not declared as aligned,
after the change it will be __attribute__((align(1))), I'd hope that
makes no difference, but I'm not sure.

Greetings,
Reimar D?ffinger
-------------- next part --------------
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 66d9200..841d854 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -5303,7 +5303,7 @@ static inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx ) {
     return ctx + 4 * cat;
 }
 
-static const attribute_used uint8_t last_coeff_flag_offset_8x8[63] = {
+DECLARE_ASM_CONST(1, const uint8_t, last_coeff_flag_offset_8x8[63]) = {
     0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
     3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
diff --git a/libavcodec/i386/motion_est_mmx.c b/libavcodec/i386/motion_est_mmx.c
index 3c22393..888d891 100644
--- a/libavcodec/i386/motion_est_mmx.c
+++ b/libavcodec/i386/motion_est_mmx.c
@@ -24,13 +24,13 @@
 #include "dsputil.h"
 #include "x86_cpu.h"
 
-static const __attribute__ ((aligned(8))) uint64_t round_tab[3]={
+DECLARE_ASM_CONST(8, uint64_t, round_tab[3])={
 0x0000000000000000ULL,
 0x0001000100010001ULL,
 0x0002000200020002ULL,
 };
 
-static attribute_used __attribute__ ((aligned(8))) uint64_t bone= 0x0101010101010101LL;
+DECLARE_ASM_CONST(8, uint64_t, bone)= 0x0101010101010101LL;
 
 static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
 {
diff --git a/libavcodec/i386/simple_idct_mmx.c b/libavcodec/i386/simple_idct_mmx.c
index 12f352c..c230598 100644
--- a/libavcodec/i386/simple_idct_mmx.c
+++ b/libavcodec/i386/simple_idct_mmx.c
@@ -48,10 +48,10 @@
 #define ROW_SHIFT 11
 #define COL_SHIFT 20 // 6
 
-static const uint64_t attribute_used __attribute__((aligned(8))) wm1010= 0xFFFF0000FFFF0000ULL;
-static const uint64_t attribute_used __attribute__((aligned(8))) d40000= 0x0000000000040000ULL;
+DECLARE_ASM_CONST(8, uint64_t, wm1010)= 0xFFFF0000FFFF0000ULL;
+DECLARE_ASM_CONST(8, uint64_t, d40000)= 0x0000000000040000ULL;
 
-static const int16_t __attribute__((aligned(8))) coeffs[]= {
+DECLARE_ALIGNED(static const int16_t, coeffs[])= {
         1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0,
 //        1<<(COL_SHIFT-1), 0, 1<<(COL_SHIFT-1), 0,
 //        0, 1<<(COL_SHIFT-1-16), 0, 1<<(COL_SHIFT-1-16),
diff --git a/libavutil/mem.h b/libavutil/mem.h
index 8695353..b9ff44d 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -28,8 +28,10 @@
 
 #ifdef __GNUC__
   #define DECLARE_ALIGNED(n,t,v)       t v __attribute__ ((aligned (n)))
+  #define DECLARE_ASM_CONST(n,t,v)     static const t v attribute_used __attribute__ ((aligned (n)))
 #else
   #define DECLARE_ALIGNED(n,t,v)      __declspec(align(n)) t v
+  #define DECLARE_ASM_CONST(n,t,v)    __declspec(align(n)) static const t v
 #endif
 
 /**



More information about the ffmpeg-devel mailing list