[FFmpeg-cvslog] lavr: x86: optimized 2-channel s16p to flt 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:38:11 2012 -0400| [46f929adada92a87fd3e5362b8ed8b4696e09dcd] | committer: Justin Ruggles

lavr: x86: optimized 2-channel s16p to flt conversion

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=46f929adada92a87fd3e5362b8ed8b4696e09dcd
---

 libavresample/x86/audio_convert.asm    |   49 ++++++++++++++++++++++++++++++++
 libavresample/x86/audio_convert_init.c |    9 ++++++
 2 files changed, 58 insertions(+)

diff --git a/libavresample/x86/audio_convert.asm b/libavresample/x86/audio_convert.asm
index ee05efc..c3cc76f 100644
--- a/libavresample/x86/audio_convert.asm
+++ b/libavresample/x86/audio_convert.asm
@@ -383,6 +383,55 @@ INIT_XMM avx
 CONV_S16P_TO_S16_6CH
 %endif
 
+;------------------------------------------------------------------------------
+; void ff_conv_s16p_to_flt_2ch(float *dst, int16_t *const *src, int len,
+;                              int channels);
+;------------------------------------------------------------------------------
+
+%macro CONV_S16P_TO_FLT_2CH 0
+cglobal conv_s16p_to_flt_2ch, 3,4,6, dst, src0, len, src1
+    lea       lenq, [2*lend]
+    mov      src1q, [src0q+gprsize]
+    mov      src0q, [src0q        ]
+    lea       dstq, [dstq+4*lenq]
+    add      src0q, lenq
+    add      src1q, lenq
+    neg       lenq
+    mova        m5, [pf_s32_inv_scale]
+.loop:
+    mova        m2, [src0q+lenq]    ; m2 =  0,  2,  4,  6,  8, 10, 12, 14
+    mova        m4, [src1q+lenq]    ; m4 =  1,  3,  5,  7,  9, 11, 13, 15
+    SBUTTERFLY2 wd, 2, 4, 3         ; m2 =  0,  1,  2,  3,  4,  5,  6,  7
+                                    ; m4 =  8,  9, 10, 11, 12, 13, 14, 15
+    pxor        m3, m3
+    punpcklwd   m0, m3, m2          ; m0 =      0,      1,      2,      3
+    punpckhwd   m1, m3, m2          ; m1 =      4,      5,      6,      7
+    punpcklwd   m2, m3, m4          ; m2 =      8,      9,     10,     11
+    punpckhwd   m3, m4              ; m3 =     12,     13,     14,     15
+    cvtdq2ps    m0, m0
+    cvtdq2ps    m1, m1
+    cvtdq2ps    m2, m2
+    cvtdq2ps    m3, m3
+    mulps       m0, m5
+    mulps       m1, m5
+    mulps       m2, m5
+    mulps       m3, m5
+    mova  [dstq+4*lenq         ], m0
+    mova  [dstq+4*lenq+  mmsize], m1
+    mova  [dstq+4*lenq+2*mmsize], m2
+    mova  [dstq+4*lenq+3*mmsize], m3
+    add       lenq, mmsize
+    jl .loop
+    REP_RET
+%endmacro
+
+INIT_XMM sse2
+CONV_S16P_TO_FLT_2CH
+%if HAVE_AVX
+INIT_XMM avx
+CONV_S16P_TO_FLT_2CH
+%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 d9d4714..9706c71 100644
--- a/libavresample/x86/audio_convert_init.c
+++ b/libavresample/x86/audio_convert_init.c
@@ -54,6 +54,11 @@ extern void ff_conv_s16p_to_s16_6ch_sse2slow(int16_t *dst, int16_t *const *src,
 extern void ff_conv_s16p_to_s16_6ch_avx (int16_t *dst, int16_t *const *src,
                                          int len, int channels);
 
+extern void ff_conv_s16p_to_flt_2ch_sse2(float *dst, int16_t *const *src,
+                                         int len, int channels);
+extern void ff_conv_s16p_to_flt_2ch_avx (float *dst, int16_t *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,
@@ -94,6 +99,8 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
                                   0, 16, 16, "SSE2", ff_conv_flt_to_s32_sse2);
         ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
                                   2, 16, 16, "SSE2", ff_conv_s16p_to_s16_2ch_sse2);
+        ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
+                                  2, 16, 8, "SSE2", ff_conv_s16p_to_flt_2ch_sse2);
     }
     if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) {
         ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
@@ -110,6 +117,8 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
                                   2, 16, 16, "AVX", ff_conv_s16p_to_s16_2ch_avx);
         ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
                                   6, 16, 8, "AVX", ff_conv_s16p_to_s16_6ch_avx);
+        ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
+                                  2, 16, 8, "AVX", ff_conv_s16p_to_flt_2ch_avx);
         ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
                                   6, 16, 4, "AVX", ff_conv_fltp_to_flt_6ch_avx);
     }



More information about the ffmpeg-cvslog mailing list