1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-24 13:56:33 +02:00

x86: place some inline asm under #if HAVE_INLINE_ASM

Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
Ronald S. Bultje 2012-06-22 18:46:52 +01:00 committed by Mans Rullgard
parent 145a8096d5
commit 8123e0901f
11 changed files with 45 additions and 1 deletions

View File

@ -27,6 +27,8 @@
#include "libavutil/internal.h" #include "libavutil/internal.h"
#include "config.h" #include "config.h"
#if HAVE_INLINE_ASM
#ifdef BROKEN_RELOCATIONS #ifdef BROKEN_RELOCATIONS
#define TABLES_ARG , "r"(tables) #define TABLES_ARG , "r"(tables)
@ -225,4 +227,5 @@ static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val)
return val; return val;
} }
#endif /* HAVE_INLINE_ASM */
#endif /* AVCODEC_X86_CABAC_H */ #endif /* AVCODEC_X86_CABAC_H */

View File

@ -29,6 +29,8 @@
#include "libavcodec/cavsdsp.h" #include "libavcodec/cavsdsp.h"
#include "dsputil_mmx.h" #include "dsputil_mmx.h"
#if HAVE_INLINE_ASM
/* in/out: mma=mma+mmb, mmb=mmb-mma */ /* in/out: mma=mma+mmb, mmb=mmb-mma */
#define SUMSUB_BA( a, b ) \ #define SUMSUB_BA( a, b ) \
"paddw "#b", "#a" \n\t"\ "paddw "#b", "#a" \n\t"\
@ -477,10 +479,14 @@ static void ff_cavsdsp_init_3dnow(CAVSDSPContext* c, AVCodecContext *avctx) {
c->cavs_idct8_add = cavs_idct8_add_mmx; c->cavs_idct8_add = cavs_idct8_add_mmx;
} }
#endif /* HAVE_INLINE_ASM */
void ff_cavsdsp_init_mmx(CAVSDSPContext *c, AVCodecContext *avctx) void ff_cavsdsp_init_mmx(CAVSDSPContext *c, AVCodecContext *avctx)
{ {
int mm_flags = av_get_cpu_flags(); int mm_flags = av_get_cpu_flags();
#if HAVE_INLINE_ASM
if (mm_flags & AV_CPU_FLAG_MMX2) ff_cavsdsp_init_mmx2 (c, avctx); if (mm_flags & AV_CPU_FLAG_MMX2) ff_cavsdsp_init_mmx2 (c, avctx);
if (mm_flags & AV_CPU_FLAG_3DNOW) ff_cavsdsp_init_3dnow(c, avctx); if (mm_flags & AV_CPU_FLAG_3DNOW) ff_cavsdsp_init_3dnow(c, avctx);
#endif /* HAVE_INLINE_ASM */
} }

View File

@ -24,6 +24,8 @@
#include "libavutil/x86_cpu.h" #include "libavutil/x86_cpu.h"
#include "libavcodec/dnxhdenc.h" #include "libavcodec/dnxhdenc.h"
#if HAVE_INLINE_ASM
static void get_pixels_8x4_sym_sse2(DCTELEM *block, const uint8_t *pixels, int line_size) static void get_pixels_8x4_sym_sse2(DCTELEM *block, const uint8_t *pixels, int line_size)
{ {
__asm__ volatile( __asm__ volatile(
@ -50,10 +52,14 @@ static void get_pixels_8x4_sym_sse2(DCTELEM *block, const uint8_t *pixels, int l
); );
} }
#endif /* HAVE_INLINE_ASM */
void ff_dnxhd_init_mmx(DNXHDEncContext *ctx) void ff_dnxhd_init_mmx(DNXHDEncContext *ctx)
{ {
#if HAVE_INLINE_ASM
if (av_get_cpu_flags() & AV_CPU_FLAG_SSE2) { if (av_get_cpu_flags() & AV_CPU_FLAG_SSE2) {
if (ctx->cid_table->bit_depth == 8) if (ctx->cid_table->bit_depth == 8)
ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2; ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2;
} }
#endif /* HAVE_INLINE_ASM */
} }

View File

@ -34,6 +34,8 @@
#include "libavcodec/cabac.h" #include "libavcodec/cabac.h"
#include "cabac.h" #include "cabac.h"
#if HAVE_INLINE_ASM
//FIXME use some macros to avoid duplicating get_cabac (cannot be done yet //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
//as that would make optimization work hard) //as that would make optimization work hard)
#if HAVE_7REGS #if HAVE_7REGS
@ -187,4 +189,5 @@ static int decode_significance_8x8_x86(CABACContext *c,
} }
#endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ #endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */
#endif /* HAVE_INLINE_ASM */
#endif /* AVCODEC_X86_H264_I386_H */ #endif /* AVCODEC_X86_H264_I386_H */

View File

@ -23,6 +23,8 @@
#include "libavutil/cpu.h" #include "libavutil/cpu.h"
#include "libavcodec/lpc.h" #include "libavcodec/lpc.h"
#if HAVE_INLINE_ASM
static void lpc_apply_welch_window_sse2(const int32_t *data, int len, static void lpc_apply_welch_window_sse2(const int32_t *data, int len,
double *w_data) double *w_data)
{ {
@ -136,12 +138,16 @@ static void lpc_compute_autocorr_sse2(const double *data, int len, int lag,
} }
} }
#endif /* HAVE_INLINE_ASM */
av_cold void ff_lpc_init_x86(LPCContext *c) av_cold void ff_lpc_init_x86(LPCContext *c)
{ {
int mm_flags = av_get_cpu_flags(); int mm_flags = av_get_cpu_flags();
#if HAVE_INLINE_ASM
if (mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) { if (mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) {
c->lpc_apply_welch_window = lpc_apply_welch_window_sse2; c->lpc_apply_welch_window = lpc_apply_welch_window_sse2;
c->lpc_compute_autocorr = lpc_compute_autocorr_sse2; c->lpc_compute_autocorr = lpc_compute_autocorr_sse2;
} }
#endif /* HAVE_INLINE_ASM */
} }

View File

@ -25,6 +25,8 @@
#include "config.h" #include "config.h"
#include "libavutil/common.h" #include "libavutil/common.h"
#if HAVE_INLINE_ASM
#if ARCH_X86_32 #if ARCH_X86_32
#define MULL MULL #define MULL MULL
@ -118,4 +120,5 @@ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
return a; return a;
} }
#endif /* HAVE_INLINE_ASM */
#endif /* AVCODEC_X86_MATHOPS_H */ #endif /* AVCODEC_X86_MATHOPS_H */

View File

@ -26,6 +26,8 @@
#include "libavcodec/dwt.h" #include "libavcodec/dwt.h"
#include "dsputil_mmx.h" #include "dsputil_mmx.h"
#if HAVE_INLINE_ASM
static void ff_snow_horizontal_compose97i_sse2(IDWTELEM *b, IDWTELEM *temp, int width){ static void ff_snow_horizontal_compose97i_sse2(IDWTELEM *b, IDWTELEM *temp, int width){
const int w2= (width+1)>>1; const int w2= (width+1)>>1;
const int w_l= (width>>1); const int w_l= (width>>1);
@ -871,8 +873,11 @@ static void ff_snow_inner_add_yblock_mmx(const uint8_t *obmc, const int obmc_str
ff_snow_inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8); ff_snow_inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
} }
#endif /* HAVE_INLINE_ASM */
void ff_dwt_init_x86(DWTContext *c) void ff_dwt_init_x86(DWTContext *c)
{ {
#if HAVE_INLINE_ASM
int mm_flags = av_get_cpu_flags(); int mm_flags = av_get_cpu_flags();
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
@ -893,4 +898,5 @@ void ff_dwt_init_x86(DWTContext *c)
c->inner_add_yblock = ff_snow_inner_add_yblock_mmx; c->inner_add_yblock = ff_snow_inner_add_yblock_mmx;
} }
} }
#endif /* HAVE_INLINE_ASM */
} }

View File

@ -30,6 +30,8 @@
#include "dsputil_mmx.h" #include "dsputil_mmx.h"
#include "libavcodec/vc1dsp.h" #include "libavcodec/vc1dsp.h"
#if HAVE_INLINE_ASM
#define OP_PUT(S,D) #define OP_PUT(S,D)
#define OP_AVG(S,D) "pavgb " #S ", " #D " \n\t" #define OP_AVG(S,D) "pavgb " #S ", " #D " \n\t"
@ -682,6 +684,8 @@ static void vc1_inv_trans_8x8_dc_mmx2(uint8_t *dest, int linesize, DCTELEM *bloc
); );
} }
#endif /* HAVE_INLINE_ASM */
#define LOOP_FILTER(EXT) \ #define LOOP_FILTER(EXT) \
void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \ void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \ void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
@ -730,6 +734,7 @@ void ff_vc1dsp_init_mmx(VC1DSPContext *dsp)
{ {
int mm_flags = av_get_cpu_flags(); int mm_flags = av_get_cpu_flags();
#if HAVE_INLINE_ASM
if (mm_flags & AV_CPU_FLAG_MMX) { if (mm_flags & AV_CPU_FLAG_MMX) {
dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_mmx; dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_mmx;
dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_mmx; dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_mmx;
@ -778,6 +783,7 @@ void ff_vc1dsp_init_mmx(VC1DSPContext *dsp)
dsp->vc1_inv_trans_8x4_dc = vc1_inv_trans_8x4_dc_mmx2; dsp->vc1_inv_trans_8x4_dc = vc1_inv_trans_8x4_dc_mmx2;
dsp->vc1_inv_trans_4x4_dc = vc1_inv_trans_4x4_dc_mmx2; dsp->vc1_inv_trans_4x4_dc = vc1_inv_trans_4x4_dc_mmx2;
} }
#endif /* HAVE_INLINE_ASM */
#define ASSIGN_LF(EXT) \ #define ASSIGN_LF(EXT) \
dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \ dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \

View File

@ -110,7 +110,7 @@ struct AVDictionary {
/* math */ /* math */
#if ARCH_X86 #if ARCH_X86 && HAVE_INLINE_ASM
#define MASK_ABS(mask, level)\ #define MASK_ABS(mask, level)\
__asm__ volatile(\ __asm__ volatile(\
"cltd \n\t"\ "cltd \n\t"\

View File

@ -28,6 +28,8 @@
#include "config.h" #include "config.h"
#include "libavutil/attributes.h" #include "libavutil/attributes.h"
#if HAVE_INLINE_ASM
#if !AV_GCC_VERSION_AT_LEAST(4,1) #if !AV_GCC_VERSION_AT_LEAST(4,1)
#define av_bswap16 av_bswap16 #define av_bswap16 av_bswap16
static av_always_inline av_const unsigned av_bswap16(unsigned x) static av_always_inline av_const unsigned av_bswap16(unsigned x)
@ -55,4 +57,5 @@ static inline uint64_t av_const av_bswap64(uint64_t x)
#endif #endif
#endif /* !AV_GCC_VERSION_AT_LEAST(4,5) */ #endif /* !AV_GCC_VERSION_AT_LEAST(4,5) */
#endif /* HAVE_INLINE_ASM */
#endif /* AVUTIL_X86_BSWAP_H */ #endif /* AVUTIL_X86_BSWAP_H */

View File

@ -21,6 +21,7 @@
#ifndef AVUTIL_X86_INTMATH_H #ifndef AVUTIL_X86_INTMATH_H
#define AVUTIL_X86_INTMATH_H #define AVUTIL_X86_INTMATH_H
#if HAVE_INLINE_ASM
#define FASTDIV(a,b) \ #define FASTDIV(a,b) \
({\ ({\
int ret, dmy;\ int ret, dmy;\
@ -31,5 +32,6 @@
);\ );\
ret;\ ret;\
}) })
#endif
#endif /* AVUTIL_X86_INTMATH_H */ #endif /* AVUTIL_X86_INTMATH_H */