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
302#include "resample_template.c"302#include "resample_template.c"
303#undef TEMPLATE_RESAMPLE_S16_MMX2303#undef TEMPLATE_RESAMPLE_S16_MMX2
304 304
305#if HAVE_SSSE3_INLINE305#if HAVE_SSE2_INLINE
306#define TEMPLATE_RESAMPLE_S16_SSSE3306#define TEMPLATE_RESAMPLE_S16_SSE2
307#include "resample_template.c"307#include "resample_template.c"
308#undef TEMPLATE_RESAMPLE_S16_SSSE3308#undef TEMPLATE_RESAMPLE_S16_SSE2
309#endif309#endif
310 310
311#endif // HAVE_MMXEXT_INLINE311#endif // HAVE_MMXEXT_INLINE
@@ -317,8 +317,8 @@ static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, A · 5 unmodified lines
317 317
318 for(i=0; i<dst->ch_count; i++){318 for(i=0; i<dst->ch_count; i++){
319#if HAVE_MMXEXT_INLINE319#if HAVE_MMXEXT_INLINE
320#if HAVE_SSSE3_INLINE320#if HAVE_SSE2_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);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);
322 else322 else
323#endif323#endif
324 if(c->format == AV_SAMPLE_FMT_S16P && (mm_flags&AV_CPU_FLAG_MMX2 )){324 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
57 57
58#elif defined(TEMPLATE_RESAMPLE_S16) \58#elif defined(TEMPLATE_RESAMPLE_S16) \
59 || defined(TEMPLATE_RESAMPLE_S16_MMX2) \59 || defined(TEMPLATE_RESAMPLE_S16_MMX2) \
60 || defined(TEMPLATE_RESAMPLE_S16_SSSE3)60 || defined(TEMPLATE_RESAMPLE_S16_SSE2)
61 61
62# define FILTER_SHIFT 1562# define FILTER_SHIFT 15
63# define DELEM int16_t63# define DELEM int16_t
@@ -74,9 +74,9 @@ · 10 unmodified lines
74# elif defined(TEMPLATE_RESAMPLE_S16_MMX2)74# elif defined(TEMPLATE_RESAMPLE_S16_MMX2)
75# define COMMON_CORE COMMON_CORE_INT16_MMX275# define COMMON_CORE COMMON_CORE_INT16_MMX2
76# define RENAME(N) N ## _int16_mmx276# define RENAME(N) N ## _int16_mmx2
77# elif defined(TEMPLATE_RESAMPLE_S16_SSSE3)77# elif defined(TEMPLATE_RESAMPLE_S16_SSE2)
78# define COMMON_CORE COMMON_CORE_INT16_SSSE378# define COMMON_CORE COMMON_CORE_INT16_SSE2
79# define RENAME(N) N ## _int16_ssse379# define RENAME(N) N ## _int16_sse2
80# endif80# endif
81 81
82#endif82#endif
libswresample/x86/resample_mmx.h+6−4
@@ -23,7 +23,7 @@ · 22 unmodified lines
23#include "libswresample/swresample_internal.h"23#include "libswresample/swresample_internal.h"
24 24
25int 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);25int 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);
26int 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);26int 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);
27 27
28DECLARE_ALIGNED(16, const uint64_t, ff_resample_int16_rounder)[2] = { 0x0000000000004000ULL, 0x0000000000000000ULL};28DECLARE_ALIGNED(16, const uint64_t, ff_resample_int16_rounder)[2] = { 0x0000000000004000ULL, 0x0000000000000000ULL};
29 29
@@ -48,7 +48,7 @@ __asm__ volatile(\ · 18 unmodified lines
48 "r" (dst+dst_index)\48 "r" (dst+dst_index)\
49);49);
50 50
51#define COMMON_CORE_INT16_SSSE3 \51#define COMMON_CORE_INT16_SSE2 \
52 x86_reg len= -2*c->filter_length;\52 x86_reg len= -2*c->filter_length;\
53__asm__ volatile(\53__asm__ volatile(\
54 "movdqa "MANGLE(ff_resample_int16_rounder)", %%xmm0 \n\t"\54 "movdqa "MANGLE(ff_resample_int16_rounder)", %%xmm0 \n\t"\
@@ -58,8 +58,10 @@ __asm__ volatile(\ · 3 unmodified lines
58 "paddd %%xmm1, %%xmm0 \n\t"\58 "paddd %%xmm1, %%xmm0 \n\t"\
59 "add $16, %0 \n\t"\59 "add $16, %0 \n\t"\
60 " js 1b \n\t"\60 " js 1b \n\t"\
61 "phaddd %%xmm0, %%xmm0 \n\t"\61 "pshufd $0x0E, %%xmm0, %%xmm1 \n\t"\
62 "phaddd %%xmm0, %%xmm0 \n\t"\62 "paddd %%xmm1, %%xmm0 \n\t"\
63 "pshufd $0x01, %%xmm0, %%xmm1 \n\t"\
64 "paddd %%xmm1, %%xmm0 \n\t"\
63 "psrad $15, %%xmm0 \n\t"\65 "psrad $15, %%xmm0 \n\t"\
64 "packssdw %%xmm0, %%xmm0 \n\t"\66 "packssdw %%xmm0, %%xmm0 \n\t"\
65 "movd %%xmm0, (%3) \n\t"\67 "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