[FFmpeg-cvslog] lavr: x86: optimized 2-channel fltp to s16 conversion
Justin Ruggles
git at videolan.org
Fri Aug 24 14:44:29 CEST 2012
ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Wed May 2 15:50:46 2012 -0400| [a58a013980b976e767994f8964b7cd7e2097dc53] | committer: Justin Ruggles
lavr: x86: optimized 2-channel fltp to s16 conversion
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a58a013980b976e767994f8964b7cd7e2097dc53
---
libavresample/x86/audio_convert.asm | 43 ++++++++++++++++++++++++++++++++
libavresample/x86/audio_convert_init.c | 9 +++++++
2 files changed, 52 insertions(+)
diff --git a/libavresample/x86/audio_convert.asm b/libavresample/x86/audio_convert.asm
index 622a84c..15aaa6a 100644
--- a/libavresample/x86/audio_convert.asm
+++ b/libavresample/x86/audio_convert.asm
@@ -32,6 +32,7 @@ pf_s16_inv_scale: times 4 dd 0x38000000
pf_s16_scale: times 4 dd 0x47000000
pb_shuf_unpack_even: db -1, -1, 0, 1, -1, -1, 2, 3, -1, -1, 8, 9, -1, -1, 10, 11
pb_shuf_unpack_odd: db -1, -1, 4, 5, -1, -1, 6, 7, -1, -1, 12, 13, -1, -1, 14, 15
+pb_interleave_words: SHUFFLE_MASK_W 0, 4, 1, 5, 2, 6, 3, 7
SECTION_TEXT
@@ -538,6 +539,48 @@ INIT_XMM avx
CONV_S16P_TO_FLT_6CH
%endif
+;------------------------------------------------------------------------------
+; void ff_conv_fltp_to_s16_2ch(int16_t *dst, float *const *src, int len,
+; int channels);
+;------------------------------------------------------------------------------
+
+%macro CONV_FLTP_TO_S16_2CH 0
+cglobal conv_fltp_to_s16_2ch, 3,4,3, dst, src0, len, src1
+ lea lenq, [4*lend]
+ mov src1q, [src0q+gprsize]
+ mov src0q, [src0q ]
+ add dstq, lenq
+ add src0q, lenq
+ add src1q, lenq
+ neg lenq
+ mova m2, [pf_s16_scale]
+%if cpuflag(ssse3)
+ mova m3, [pb_interleave_words]
+%endif
+.loop:
+ mulps m0, m2, [src0q+lenq] ; m0 = 0, 2, 4, 6
+ mulps m1, m2, [src1q+lenq] ; m1 = 1, 3, 5, 7
+ cvtps2dq m0, m0
+ cvtps2dq m1, m1
+%if cpuflag(ssse3)
+ packssdw m0, m1 ; m0 = 0, 2, 4, 6, 1, 3, 5, 7
+ pshufb m0, m3 ; m0 = 0, 1, 2, 3, 4, 5, 6, 7
+%else
+ packssdw m0, m0 ; m0 = 0, 2, 4, 6, x, x, x, x
+ packssdw m1, m1 ; m1 = 1, 3, 5, 7, x, x, x, x
+ punpcklwd m0, m1 ; m0 = 0, 1, 2, 3, 4, 5, 6, 7
+%endif
+ mova [dstq+lenq], m0
+ add lenq, mmsize
+ jl .loop
+ REP_RET
+%endmacro
+
+INIT_XMM sse2
+CONV_FLTP_TO_S16_2CH
+INIT_XMM ssse3
+CONV_FLTP_TO_S16_2CH
+
;-----------------------------------------------------------------------------
; void ff_conv_fltp_to_flt_6ch(float *dst, float *const *src, int len,
; int channels);
diff --git a/libavresample/x86/audio_convert_init.c b/libavresample/x86/audio_convert_init.c
index 6bcf093..3098658 100644
--- a/libavresample/x86/audio_convert_init.c
+++ b/libavresample/x86/audio_convert_init.c
@@ -66,6 +66,11 @@ extern void ff_conv_s16p_to_flt_6ch_ssse3(float *dst, int16_t *const *src,
extern void ff_conv_s16p_to_flt_6ch_avx (float *dst, int16_t *const *src,
int len, int channels);
+extern void ff_conv_fltp_to_s16_2ch_sse2 (int16_t *dst, float *const *src,
+ int len, int channels);
+extern void ff_conv_fltp_to_s16_2ch_ssse3(int16_t *dst, float *const *src,
+ int len, int channels);
+
extern void ff_conv_fltp_to_flt_6ch_mmx (float *dst, float *const *src, int len,
int channels);
extern void ff_conv_fltp_to_flt_6ch_sse4(float *dst, float *const *src, int len,
@@ -110,10 +115,14 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
2, 16, 8, "SSE2", ff_conv_s16p_to_flt_2ch_sse2);
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
6, 16, 4, "SSE2", ff_conv_s16p_to_flt_6ch_sse2);
+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
+ 2, 16, 4, "SSE2", ff_conv_fltp_to_s16_2ch_sse2);
}
if (mm_flags & AV_CPU_FLAG_SSSE3 && HAVE_SSE) {
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
6, 16, 4, "SSSE3", ff_conv_s16p_to_flt_6ch_ssse3);
+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
+ 2, 16, 4, "SSSE3", ff_conv_fltp_to_s16_2ch_ssse3);
}
if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) {
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
More information about the ffmpeg-cvslog
mailing list