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
Unified · Split
| @@ -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_MMX2 | 303 | #undef TEMPLATE_RESAMPLE_S16_MMX2 |
| 304 | 304 | ||
| 305 | #if HAVE_SSSE3_INLINE | 305 | #if HAVE_SSE2_INLINE |
| 306 | #define TEMPLATE_RESAMPLE_S16_SSSE3 | 306 | #define TEMPLATE_RESAMPLE_S16_SSE2 |
| 307 | #include "resample_template.c" | 307 | #include "resample_template.c" |
| 308 | #undef TEMPLATE_RESAMPLE_S16_SSSE3 | 308 | #undef TEMPLATE_RESAMPLE_S16_SSE2 |
| 309 | #endif | 309 | #endif |
| 310 | 310 | ||
| 311 | #endif // HAVE_MMXEXT_INLINE | 311 | #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_INLINE | 319 | #if HAVE_MMXEXT_INLINE |
| 320 | #if HAVE_SSSE3_INLINE | 320 | #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 | else | 322 | else |
| 323 | #endif | 323 | #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 )){ |
| @@ -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 15 | 62 | # define FILTER_SHIFT 15 |
| 63 | # define DELEM int16_t | 63 | # 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_MMX2 | 75 | # define COMMON_CORE COMMON_CORE_INT16_MMX2 |
| 76 | # define RENAME(N) N ## _int16_mmx2 | 76 | # 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_SSSE3 | 78 | # define COMMON_CORE COMMON_CORE_INT16_SSE2 |
| 79 | # define RENAME(N) N ## _int16_ssse3 | 79 | # define RENAME(N) N ## _int16_sse2 |
| 80 | # endif | 80 | # endif |
| 81 | 81 | ||
| 82 | #endif | 82 | #endif |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | |||
| 23 | #include "libswresample/swresample_internal.h" | 23 | #include "libswresample/swresample_internal.h" |
| 24 | 24 | ||
| 25 | 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); | 25 | 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); |
| 27 | 27 | ||
| 28 | DECLARE_ALIGNED(16, const uint64_t, ff_resample_int16_rounder)[2] = { 0x0000000000004000ULL, 0x0000000000000000ULL}; | 28 | DECLARE_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"\ |