Commit ef5e74bb authored by Michael Niedermayer's avatar Michael Niedermayer

c std doesnt like negative shifts -> use asm

Originally committed as revision 730 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent df595131
...@@ -165,11 +165,25 @@ inline void dprintf(const char* fmt,...) {} ...@@ -165,11 +165,25 @@ inline void dprintf(const char* fmt,...) {}
#define MAX(a,b) ((a) > (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) > (b) ? (b) : (a)) #define MIN(a,b) ((a) > (b) ? (b) : (a))
#if defined ARCH_X86 && (__GNUC__ != 3 || __GNUC_MINOR__ > 1) #ifdef ARCH_X86
// inverse for shift optimization (gcc should do that ...) // avoid +32 for shift optimization (gcc should do that ...)
#define INV32(a) (-a) static inline int32_t NEG_SSR32( int32_t a, int8_t s){
asm ("sarl %1, %0\n\t"
: "+r" (a)
: "ic" ((uint8_t)(-s))
);
return a;
}
static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
asm ("shrl %1, %0\n\t"
: "+r" (a)
: "ic" ((uint8_t)(-s))
);
return a;
}
#else #else
#define INV32(a) (32-a) #define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
#define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
#endif #endif
/* bit output */ /* bit output */
...@@ -530,10 +544,10 @@ for examples see get_bits, show_bits, skip_bits, get_vlc ...@@ -530,10 +544,10 @@ for examples see get_bits, show_bits, skip_bits, get_vlc
# define LAST_SKIP_CACHE(name, gb, num) ; # define LAST_SKIP_CACHE(name, gb, num) ;
# define SHOW_UBITS(name, gb, num)\ # define SHOW_UBITS(name, gb, num)\
(((uint32_t)name##_cache)>>INV32(num)) NEG_USR32(name##_cache, num)
# define SHOW_SBITS(name, gb, num)\ # define SHOW_SBITS(name, gb, num)\
(((int32_t)name##_cache)>>INV32(num)) NEG_SSR32(name##_cache, num)
# define GET_CACHE(name, gb)\ # define GET_CACHE(name, gb)\
((uint32_t)name##_cache) ((uint32_t)name##_cache)
...@@ -579,10 +593,10 @@ static inline int get_bits_count(GetBitContext *s){ ...@@ -579,10 +593,10 @@ static inline int get_bits_count(GetBitContext *s){
# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) # define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
# define SHOW_UBITS(name, gb, num)\ # define SHOW_UBITS(name, gb, num)\
(((uint32_t)name##_cache)>>INV32(num)) NEG_USR32(name##_cache, num)
# define SHOW_SBITS(name, gb, num)\ # define SHOW_SBITS(name, gb, num)\
(((int32_t)name##_cache)>>INV32(num)) NEG_SSR32(name##_cache, num)
# define GET_CACHE(name, gb)\ # define GET_CACHE(name, gb)\
((uint32_t)name##_cache) ((uint32_t)name##_cache)
...@@ -610,7 +624,7 @@ static inline int get_bits_count(GetBitContext *s){ ...@@ -610,7 +624,7 @@ static inline int get_bits_count(GetBitContext *s){
# define UPDATE_CACHE(name, gb)\ # define UPDATE_CACHE(name, gb)\
if(name##_bit_count > 0){\ if(name##_bit_count > 0){\
const uint32_t next= be2me_32( *name##_buffer_ptr );\ const uint32_t next= be2me_32( *name##_buffer_ptr );\
name##_cache0 |= next>>INV32(name##_bit_count);\ name##_cache0 |= NEG_USR32(next,name##_bit_count);\
name##_cache1 |= next<<name##_bit_count;\ name##_cache1 |= next<<name##_bit_count;\
name##_buffer_ptr++;\ name##_buffer_ptr++;\
name##_bit_count-= 32;\ name##_bit_count-= 32;\
...@@ -627,7 +641,7 @@ static inline int get_bits_count(GetBitContext *s){ ...@@ -627,7 +641,7 @@ static inline int get_bits_count(GetBitContext *s){
#else #else
# define SKIP_CACHE(name, gb, num)\ # define SKIP_CACHE(name, gb, num)\
name##_cache0 <<= (num);\ name##_cache0 <<= (num);\
name##_cache0 |= name##_cache1 >>INV32(num);\ name##_cache0 |= NEG_USR32(name##_cache1,num);\
name##_cache1 <<= (num); name##_cache1 <<= (num);
#endif #endif
...@@ -644,10 +658,10 @@ static inline int get_bits_count(GetBitContext *s){ ...@@ -644,10 +658,10 @@ static inline int get_bits_count(GetBitContext *s){
# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) # define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
# define SHOW_UBITS(name, gb, num)\ # define SHOW_UBITS(name, gb, num)\
(((uint32_t)name##_cache0)>>INV32(num)) NEG_USR32(name##_cache0, num)
# define SHOW_SBITS(name, gb, num)\ # define SHOW_SBITS(name, gb, num)\
(((int32_t)name##_cache0)>>INV32(num)) NEG_SSR32(name##_cache0, num)
# define GET_CACHE(name, gb)\ # define GET_CACHE(name, gb)\
(name##_cache0) (name##_cache0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment