diff options
author | James Almer <jamrial@gmail.com> | 2014-04-25 04:52:31 -0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-04-25 16:46:07 +0200 |
commit | cdac3ab59f3c187ee12006972dba0757a1e7cc08 (patch) | |
tree | 7f0bc69d052fea30b6e0158f03b50a2ad638e485 /libswresample | |
parent | 92cc6d5163cd43a1a909dcc63787292f33e5d6ed (diff) | |
download | ffmpeg-cdac3ab59f3c187ee12006972dba0757a1e7cc08.tar.gz |
swresample: add swri_resample_double_sse2
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample')
-rw-r--r-- | libswresample/resample.c | 8 | ||||
-rw-r--r-- | libswresample/resample_template.c | 13 | ||||
-rw-r--r-- | libswresample/x86/resample_mmx.h | 49 |
3 files changed, 68 insertions, 2 deletions
diff --git a/libswresample/resample.c b/libswresample/resample.c index ac87671902..0ce74d076c 100644 --- a/libswresample/resample.c +++ b/libswresample/resample.c @@ -317,6 +317,10 @@ static int set_compensation(ResampleContext *c, int sample_delta, int compensati #define TEMPLATE_RESAMPLE_S16_SSE2 #include "resample_template.c" #undef TEMPLATE_RESAMPLE_S16_SSE2 + +#define TEMPLATE_RESAMPLE_DBL_SSE2 +#include "resample_template.c" +#undef TEMPLATE_RESAMPLE_DBL_SSE2 #endif #endif // HAVE_MMXEXT_INLINE @@ -344,6 +348,10 @@ static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, A ret= swri_resample_float_sse (c, (float*)dst->ch[i], (const float*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #endif else if(c->format == AV_SAMPLE_FMT_FLTP) ret= swri_resample_float(c, (float *)dst->ch[i], (const float *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); +#if HAVE_SSE2_INLINE + else if(c->format == AV_SAMPLE_FMT_DBLP && (mm_flags&AV_CPU_FLAG_SSE2)) + ret= swri_resample_double_sse2(c,(double *)dst->ch[i], (const double *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); +#endif else if(c->format == AV_SAMPLE_FMT_DBLP) ret= swri_resample_double(c,(double *)dst->ch[i], (const double *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); } if(need_emms) diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c index f42846ac5b..7624d9291b 100644 --- a/libswresample/resample_template.c +++ b/libswresample/resample_template.c @@ -25,8 +25,9 @@ * @author Michael Niedermayer <michaelni@gmx.at> */ -#if defined(TEMPLATE_RESAMPLE_DBL) -# define RENAME(N) N ## _double +#if defined(TEMPLATE_RESAMPLE_DBL) \ + || defined(TEMPLATE_RESAMPLE_DBL_SSE2) + # define FILTER_SHIFT 0 # define DELEM double # define FELEM double @@ -34,6 +35,14 @@ # define FELEML double # define OUT(d, v) d = v +# if defined(TEMPLATE_RESAMPLE_DBL) +# define RENAME(N) N ## _double +# elif defined(TEMPLATE_RESAMPLE_DBL_SSE2) +# define COMMON_CORE COMMON_CORE_DBL_SSE2 +# define LINEAR_CORE LINEAR_CORE_DBL_SSE2 +# define RENAME(N) N ## _double_sse2 +# endif + #elif defined(TEMPLATE_RESAMPLE_FLT) \ || defined(TEMPLATE_RESAMPLE_FLT_SSE) diff --git a/libswresample/x86/resample_mmx.h b/libswresample/x86/resample_mmx.h index a0df6e1e1e..1d47266097 100644 --- a/libswresample/x86/resample_mmx.h +++ b/libswresample/x86/resample_mmx.h @@ -25,6 +25,7 @@ int swri_resample_int16_mmx2 (struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx); int swri_resample_int16_sse2 (struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx); int swri_resample_float_sse (struct ResampleContext *c, float *dst, const float *src, int *consumed, int src_size, int dst_size, int update_ctx); +int swri_resample_double_sse2(struct ResampleContext *c, double *dst, const double *src, int *consumed, int src_size, int dst_size, int update_ctx); DECLARE_ALIGNED(16, const uint64_t, ff_resample_int16_rounder)[2] = { 0x0000000000004000ULL, 0x0000000000000000ULL}; @@ -191,3 +192,51 @@ __asm__ volatile(\ "r" (((uint8_t*)(filter+c->filter_alloc))-len)\ XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3")\ ); + +#define COMMON_CORE_DBL_SSE2 \ + x86_reg len= -8*c->filter_length;\ +__asm__ volatile(\ + "xorpd %%xmm0, %%xmm0 \n\t"\ + "1: \n\t"\ + "movupd (%1, %0), %%xmm1 \n\t"\ + "mulpd (%2, %0), %%xmm1 \n\t"\ + "addpd %%xmm1, %%xmm0 \n\t"\ + "add $16, %0 \n\t"\ + " js 1b \n\t"\ + "movhlps %%xmm0, %%xmm1 \n\t"\ + "addpd %%xmm1, %%xmm0 \n\t"\ + "movsd %%xmm0, (%3) \n\t"\ + : "+r" (len)\ + : "r" (((uint8_t*)(src+sample_index))-len),\ + "r" (((uint8_t*)filter)-len),\ + "r" (dst+dst_index)\ +); + +#define LINEAR_CORE_DBL_SSE2 \ + x86_reg len= -8*c->filter_length;\ +__asm__ volatile(\ + "xorpd %%xmm0, %%xmm0 \n\t"\ + "xorpd %%xmm2, %%xmm2 \n\t"\ + "1: \n\t"\ + "movupd (%3, %0), %%xmm1 \n\t"\ + "movapd %%xmm1, %%xmm3 \n\t"\ + "mulpd (%4, %0), %%xmm1 \n\t"\ + "mulpd (%5, %0), %%xmm3 \n\t"\ + "addpd %%xmm1, %%xmm0 \n\t"\ + "addpd %%xmm3, %%xmm2 \n\t"\ + "add $16, %0 \n\t"\ + " js 1b \n\t"\ + "movhlps %%xmm0, %%xmm1 \n\t"\ + "movhlps %%xmm2, %%xmm3 \n\t"\ + "addpd %%xmm1, %%xmm0 \n\t"\ + "addpd %%xmm3, %%xmm2 \n\t"\ + "movsd %%xmm0, %1 \n\t"\ + "movsd %%xmm2, %2 \n\t"\ + : "+r" (len),\ + "=m" (val),\ + "=m" (v2)\ + : "r" (((uint8_t*)(src+sample_index))-len),\ + "r" (((uint8_t*)filter)-len),\ + "r" (((uint8_t*)(filter+c->filter_alloc))-len)\ + XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3")\ +); |