mirror of https://git.ffmpeg.org/ffmpeg.git
Move MASK_ABS macro to libavcodec/mathops.h
This macro is only used in two places, both in libavcodec, so this is a more sensible place for it. Two small tweaks to the macro are made: - removing the trailing semicolon - dropping unnecessary 'volatile' from the x86 asm Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
parent
070a402b60
commit
d7a4f8f8b9
|
@ -138,6 +138,13 @@ if ((y) < (x)) {\
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MASK_ABS
|
||||||
|
#define MASK_ABS(mask, level) do { \
|
||||||
|
mask = level >> 31; \
|
||||||
|
level = (level ^ mask) - mask; \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NEG_SSR32
|
#ifndef NEG_SSR32
|
||||||
# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
|
# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -885,7 +885,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
|
||||||
run = i - last_non_zero - 1;
|
run = i - last_non_zero - 1;
|
||||||
|
|
||||||
alevel= level;
|
alevel= level;
|
||||||
MASK_ABS(sign, alevel)
|
MASK_ABS(sign, alevel);
|
||||||
sign&=1;
|
sign&=1;
|
||||||
|
|
||||||
if (alevel <= mpeg1_max_level[0][run]){
|
if (alevel <= mpeg1_max_level[0][run]){
|
||||||
|
|
|
@ -101,6 +101,12 @@ __asm__ volatile(\
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MASK_ABS(mask, level) \
|
||||||
|
__asm__ ("cltd \n\t" \
|
||||||
|
"xorl %1, %0 \n\t" \
|
||||||
|
"subl %1, %0 \n\t" \
|
||||||
|
: "+a"(level), "=&d"(mask))
|
||||||
|
|
||||||
// avoid +32 for shift optimization (gcc should do that ...)
|
// avoid +32 for shift optimization (gcc should do that ...)
|
||||||
#define NEG_SSR32 NEG_SSR32
|
#define NEG_SSR32 NEG_SSR32
|
||||||
static inline int32_t NEG_SSR32( int32_t a, int8_t s){
|
static inline int32_t NEG_SSR32( int32_t a, int8_t s){
|
||||||
|
|
|
@ -96,22 +96,6 @@ struct AVDictionary {
|
||||||
|
|
||||||
#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
|
#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
|
||||||
|
|
||||||
/* math */
|
|
||||||
|
|
||||||
#if ARCH_X86 && HAVE_INLINE_ASM
|
|
||||||
#define MASK_ABS(mask, level)\
|
|
||||||
__asm__ volatile(\
|
|
||||||
"cltd \n\t"\
|
|
||||||
"xorl %1, %0 \n\t"\
|
|
||||||
"subl %1, %0 \n\t"\
|
|
||||||
: "+a" (level), "=&d" (mask)\
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
#define MASK_ABS(mask, level)\
|
|
||||||
mask = level >> 31;\
|
|
||||||
level = (level ^ mask) - mask;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* avoid usage of dangerous/inappropriate system functions */
|
/* avoid usage of dangerous/inappropriate system functions */
|
||||||
#undef malloc
|
#undef malloc
|
||||||
#define malloc please_use_av_malloc
|
#define malloc please_use_av_malloc
|
||||||
|
|
Loading…
Reference in New Issue