History

swresample: change COMMON_CORE_INT16 asm from SSSE3 to SSE2

pshuf+paddd is slightly faster than phaddd. The real gain is in pre-ssse3 processors like AMD K8 and K10, which get a big boost in performance compared to the mmxext version

James Almer committed 12 years ago

Commit 7c8bf091 parent c56d25c3 files · +15 −13Browse files

Unified · Split

3 files
  1. libswresample/resample.c +5 −5
  2. libswresample/resample_template.c +4 −4
  3. libswresample/x86/resample_mmx.h +6 −4
libswresample/resample.c+5−5
@@ -302,10 +302,10 @@ static int set_compensation(ResampleContext *c, int sample_delta, int compensati · 301 unmodified lines
302302 #include "resample_template.c"
303303 #undef TEMPLATE_RESAMPLE_S16_MMX2
304304
305−#if HAVE_SSSE3_INLINE
306−#define TEMPLATE_RESAMPLE_S16_SSSE3
305+#if HAVE_SSE2_INLINE
306+#define TEMPLATE_RESAMPLE_S16_SSE2
307307 #include "resample_template.c"
308−#undef TEMPLATE_RESAMPLE_S16_SSSE3
308+#undef TEMPLATE_RESAMPLE_S16_SSE2
309309 #endif
310310
311311 #endif // HAVE_MMXEXT_INLINE
@@ -317,8 +317,8 @@ static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, A · 5 unmodified lines
317317
318318 for(i=0; i<dst->ch_count; i++){
319319 #if HAVE_MMXEXT_INLINE
320−#if HAVE_SSSE3_INLINE
321− if(c->format == AV_SAMPLE_FMT_S16P && (mm_flags&AV_CPU_FLAG_SSSE3)) ret= swri_resample_int16_ssse3(c, (int16_t*)dst->ch[i], (const int16_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count);
320+#if HAVE_SSE2_INLINE
321+ if(c->format == AV_SAMPLE_FMT_S16P && (mm_flags&AV_CPU_FLAG_SSE2)) ret= swri_resample_int16_sse2 (c, (int16_t*)dst->ch[i], (const int16_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count);
322322 else
323323 #endif
324324 if(c->format == AV_SAMPLE_FMT_S16P && (mm_flags&AV_CPU_FLAG_MMX2 )){
libswresample/resample_template.c+4−4
@@ -57,7 +57,7 @@ · 56 unmodified lines
5757
5858 #elif defined(TEMPLATE_RESAMPLE_S16) \
5959 || defined(TEMPLATE_RESAMPLE_S16_MMX2) \
60− || defined(TEMPLATE_RESAMPLE_S16_SSSE3)
60+ || defined(TEMPLATE_RESAMPLE_S16_SSE2)
6161
6262 # define FILTER_SHIFT 15
6363 # define DELEM int16_t
@@ -74,9 +74,9 @@ · 10 unmodified lines
7474 # elif defined(TEMPLATE_RESAMPLE_S16_MMX2)
7575 # define COMMON_CORE COMMON_CORE_INT16_MMX2
7676 # define RENAME(N) N ## _int16_mmx2
77−# elif defined(TEMPLATE_RESAMPLE_S16_SSSE3)
78−# define COMMON_CORE COMMON_CORE_INT16_SSSE3
79−# define RENAME(N) N ## _int16_ssse3
77+# elif defined(TEMPLATE_RESAMPLE_S16_SSE2)
78+# define COMMON_CORE COMMON_CORE_INT16_SSE2
79+# define RENAME(N) N ## _int16_sse2
8080 # endif
8181
8282 #endif
libswresample/x86/resample_mmx.h+6−4
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323 #include "libswresample/swresample_internal.h"
2424
2525 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);
26−int swri_resample_int16_ssse3(struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
26+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);
2727
2828 DECLARE_ALIGNED(16, const uint64_t, ff_resample_int16_rounder)[2] = { 0x0000000000004000ULL, 0x0000000000000000ULL};
2929
@@ -48,7 +48,7 @@ __asm__ volatile(\ · 18 unmodified lines
4848 "r" (dst+dst_index)\
4949 );
5050
51−#define COMMON_CORE_INT16_SSSE3 \
51+#define COMMON_CORE_INT16_SSE2 \
5252 x86_reg len= -2*c->filter_length;\
5353 __asm__ volatile(\
5454 "movdqa "MANGLE(ff_resample_int16_rounder)", %%xmm0 \n\t"\
@@ -58,8 +58,10 @@ __asm__ volatile(\ · 3 unmodified lines
5858 "paddd %%xmm1, %%xmm0 \n\t"\
5959 "add $16, %0 \n\t"\
6060 " js 1b \n\t"\
61− "phaddd %%xmm0, %%xmm0 \n\t"\
62− "phaddd %%xmm0, %%xmm0 \n\t"\
61+ "pshufd $0x0E, %%xmm0, %%xmm1 \n\t"\
62+ "paddd %%xmm1, %%xmm0 \n\t"\
63+ "pshufd $0x01, %%xmm0, %%xmm1 \n\t"\
64+ "paddd %%xmm1, %%xmm0 \n\t"\
6365 "psrad $15, %%xmm0 \n\t"\
6466 "packssdw %%xmm0, %%xmm0 \n\t"\
6567 "movd %%xmm0, (%3) \n\t"\

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t