swresample: add swri_resample_double_sse2

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
James Almer 2014-04-25 04:52:31 -03:00 committed by Michael Niedermayer
parent 92cc6d5163
commit cdac3ab59f
4 changed files with 87 additions and 2 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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")\
);

View File

@ -311,6 +311,24 @@ fate-swr-resample_lin-fltp-48000-8000: SIZE_TOLERANCE = 576000 - 20484
fate-swr-resample_lin-fltp-48000-44100: CMP_TARGET = 0.63
fate-swr-resample_lin-fltp-48000-44100: SIZE_TOLERANCE = 576000 - 20480
fate-swr-resample_lin-dblp-8000-44100: CMP_TARGET = 14.61
fate-swr-resample_lin-dblp-8000-44100: SIZE_TOLERANCE = 96000 - 20480
fate-swr-resample_lin-dblp-8000-48000: CMP_TARGET = 14.50
fate-swr-resample_lin-dblp-8000-48000: SIZE_TOLERANCE = 96000 - 20480
fate-swr-resample_lin-dblp-44100-8000: CMP_TARGET = 75.45
fate-swr-resample_lin-dblp-44100-8000: SIZE_TOLERANCE = 529200 - 20486
fate-swr-resample_lin-dblp-44100-48000: CMP_TARGET = 9.67
fate-swr-resample_lin-dblp-44100-48000: SIZE_TOLERANCE = 529200 - 20482
fate-swr-resample_lin-dblp-48000-8000: CMP_TARGET = 62.41
fate-swr-resample_lin-dblp-48000-8000: SIZE_TOLERANCE = 576000 - 20484
fate-swr-resample_lin-dblp-48000-44100: CMP_TARGET = 0.63
fate-swr-resample_lin-dblp-48000-44100: SIZE_TOLERANCE = 576000 - 20480
endef
define ARESAMPLE_NN
@ -343,6 +361,7 @@ $(call CROSS_TEST,$(SAMPLERATES),ARESAMPLE,dblp,f64le,s16)
$(call CROSS_TEST,$(SAMPLERATES_LITE),ARESAMPLE_LIN,s16p,s16le,s16)
$(call CROSS_TEST,$(SAMPLERATES_LITE),ARESAMPLE_LIN,fltp,f32le,s16)
$(call CROSS_TEST,$(SAMPLERATES_LITE),ARESAMPLE_LIN,dblp,f64le,s16)
$(call CROSS_TEST,$(SAMPLERATES_NN),ARESAMPLE_NN,s16p,s16le,s16)
$(call CROSS_TEST,$(SAMPLERATES_NN),ARESAMPLE_NN,fltp,f32le,s16)