summaryrefslogtreecommitdiff
path: root/libavresample
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-04-20 16:09:15 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-06-18 16:16:59 -0400
commit4e4dd7173023502b5b3e7c3d7ccd7e6fe45b7afe (patch)
tree05ac29b83c9c3ca7c545ffa86052754ea826c4a5 /libavresample
parent6c63cbfe7aa24f37064e2384f9b39431a91bfb29 (diff)
downloadffmpeg-4e4dd7173023502b5b3e7c3d7ccd7e6fe45b7afe.tar.gz
lavr: Add x86-optimized function for flt to s32 conversion
Diffstat (limited to 'libavresample')
-rw-r--r--libavresample/x86/audio_convert.asm42
-rw-r--r--libavresample/x86/audio_convert_init.c7
2 files changed, 49 insertions, 0 deletions
diff --git a/libavresample/x86/audio_convert.asm b/libavresample/x86/audio_convert.asm
index a28198197f..7b3cc223c7 100644
--- a/libavresample/x86/audio_convert.asm
+++ b/libavresample/x86/audio_convert.asm
@@ -27,6 +27,7 @@
SECTION_RODATA 32
pf_s32_inv_scale: times 8 dd 0x30000000
+pf_s32_scale: times 8 dd 0x4f000000
pf_s16_inv_scale: times 4 dd 0x38000000
pf_s16_scale: times 4 dd 0x47000000
@@ -191,6 +192,47 @@ cglobal conv_flt_to_s16, 3,3,5, dst, src, len
jl .loop
REP_RET
+;------------------------------------------------------------------------------
+; void ff_conv_flt_to_s32(int32_t *dst, const float *src, int len);
+;------------------------------------------------------------------------------
+
+%macro CONV_FLT_TO_S32 0
+cglobal conv_flt_to_s32, 3,3,5, dst, src, len
+ lea lenq, [lend*4]
+ add srcq, lenq
+ add dstq, lenq
+ neg lenq
+ mova m4, [pf_s32_scale]
+.loop:
+ mulps m0, m4, [srcq+lenq ]
+ mulps m1, m4, [srcq+lenq+1*mmsize]
+ mulps m2, m4, [srcq+lenq+2*mmsize]
+ mulps m3, m4, [srcq+lenq+3*mmsize]
+ cvtps2dq m0, m0
+ cvtps2dq m1, m1
+ cvtps2dq m2, m2
+ cvtps2dq m3, m3
+ mova [dstq+lenq ], m0
+ mova [dstq+lenq+1*mmsize], m1
+ mova [dstq+lenq+2*mmsize], m2
+ mova [dstq+lenq+3*mmsize], m3
+ add lenq, mmsize*4
+ jl .loop
+%if mmsize == 32
+ vzeroupper
+ RET
+%else
+ REP_RET
+%endif
+%endmacro
+
+INIT_XMM sse2
+CONV_FLT_TO_S32
+%if HAVE_AVX
+INIT_YMM avx
+CONV_FLT_TO_S32
+%endif
+
;-----------------------------------------------------------------------------
; 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 1b2f93c1da..f41d974445 100644
--- a/libavresample/x86/audio_convert_init.c
+++ b/libavresample/x86/audio_convert_init.c
@@ -35,6 +35,9 @@ extern void ff_conv_s32_to_flt_avx (float *dst, const int32_t *src, int len);
extern void ff_conv_flt_to_s16_sse2(int16_t *dst, const float *src, int len);
+extern void ff_conv_flt_to_s32_sse2(int32_t *dst, const float *src, int len);
+extern void ff_conv_flt_to_s32_avx (int32_t *dst, const float *src, int len);
+
extern void ff_conv_fltp_to_flt_6ch_mmx (float *dst, float *const *src, int len);
extern void ff_conv_fltp_to_flt_6ch_sse4(float *dst, float *const *src, int len);
extern void ff_conv_fltp_to_flt_6ch_avx (float *dst, float *const *src, int len);
@@ -71,6 +74,8 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
0, 16, 8, "SSE2", ff_conv_s32_to_flt_sse2);
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT,
0, 16, 16, "SSE2", ff_conv_flt_to_s16_sse2);
+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
+ 0, 16, 16, "SSE2", ff_conv_flt_to_s32_sse2);
}
if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) {
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
@@ -79,6 +84,8 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) {
ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
0, 32, 16, "AVX", ff_conv_s32_to_flt_avx);
+ ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
+ 0, 32, 32, "AVX", ff_conv_flt_to_s32_avx);
}
#endif
}