---
 libavresample/x86/audio_convert.asm    |  118 ++++++++++++++++++++++++++++++++
 libavresample/x86/audio_convert_init.c |   15 ++++
 2 files changed, 133 insertions(+), 0 deletions(-)

diff --git a/libavresample/x86/audio_convert.asm 
b/libavresample/x86/audio_convert.asm
index b241542..0a34bc3 100644
--- a/libavresample/x86/audio_convert.asm
+++ b/libavresample/x86/audio_convert.asm
@@ -500,6 +500,124 @@ INIT_XMM avx
 CONV_FLTP_TO_S16_2CH
 %endif
 
+;------------------------------------------------------------------------------
+; void ff_conv_fltp_to_s16_6ch(int16_t *dst, float *const *src, int len,
+;                              int channels);
+;------------------------------------------------------------------------------
+
+%macro CONV_FLTP_TO_S16_6CH 0
+cglobal conv_fltp_to_s16_6ch, 2,8,7, dst, src, src1, src2, src3, src4, src5, 
len
+%if ARCH_X86_64
+    mov     lend, r2d
+%else
+    %define lend dword r2m
+%endif
+    mov     src1q, [srcq+1*gprsize]
+    mov     src2q, [srcq+2*gprsize]
+    mov     src3q, [srcq+3*gprsize]
+    mov     src4q, [srcq+4*gprsize]
+    mov     src5q, [srcq+5*gprsize]
+    mov      srcq, [srcq]
+    sub     src1q, srcq
+    sub     src2q, srcq
+    sub     src3q, srcq
+    sub     src4q, srcq
+    sub     src5q, srcq
+    movaps   xmm6, [pf_s16_scale]
+    ALIGN 16
+.loop:
+%if cpuflag(sse2)
+    mulps      m0, m6, [srcq      ]
+    mulps      m1, m6, [srcq+src1q]
+    mulps      m2, m6, [srcq+src2q]
+    mulps      m3, m6, [srcq+src3q]
+    mulps      m4, m6, [srcq+src4q]
+    mulps      m5, m6, [srcq+src5q]
+    cvtps2dq   m0, m0
+    cvtps2dq   m1, m1
+    cvtps2dq   m2, m2
+    cvtps2dq   m3, m3
+    cvtps2dq   m4, m4
+    cvtps2dq   m5, m5
+    packssdw   m0, m3            ; m0 =  0,  6, 12, 18,  3,  9, 15, 21
+    packssdw   m1, m4            ; m1 =  1,  7, 13, 19,  4, 10, 16, 22
+    packssdw   m2, m5            ; m2 =  2,  8, 14, 20,  5, 11, 17, 23
+                                 ; unpack words:
+    movhlps    m3, m0            ; m3 =  3,  9, 15, 21,  x,  x,  x,  x
+    punpcklwd  m0, m1            ; m0 =  0,  1,  6,  7, 12, 13, 18, 19
+    punpckhwd  m1, m2            ; m1 =  4,  5, 10, 11, 16, 17, 22, 23
+    punpcklwd  m2, m3            ; m2 =  2,  3,  8,  9, 14, 15, 20, 21
+                                 ; blend dwords:
+    shufps     m3, m0, m2, q2020 ; m3 =  0,  1, 12, 13,  2,  3, 14, 15
+    shufps     m0, m1, q2031     ; m0 =  6,  7, 18, 19,  4,  5, 16, 17
+    shufps     m2, m1, q3131     ; m2 =  8,  9, 20, 21, 10, 11, 22, 23
+                                 ; shuffle dwords:
+    pshufd     m3, m3, q3120     ; m3 =  0,  1,  2,  3, 12, 13, 14, 15
+    pshufd     m0, m0, q1302     ; m0 =  4,  5,  6,  7, 16, 17, 18, 19
+    pshufd     m2, m2, q3120     ; m2 =  8,  9, 10, 11, 20, 21, 22, 23
+    movq   [dstq   ], m3
+    movq   [dstq+ 8], m0
+    movq   [dstq+16], m2
+    movhps [dstq+24], m3
+    movhps [dstq+32], m0
+    movhps [dstq+40], m2
+%else ; sse
+    mova      xmm0, [srcq      ]
+    mova      xmm1, [srcq+src1q]
+    mova      xmm2, [srcq+src2q]
+    mova      xmm3, [srcq+src3q]
+    mova      xmm4, [srcq+src4q]
+    mova      xmm5, [srcq+src5q]
+    mulps     xmm0, xmm6
+    mulps     xmm1, xmm6
+    mulps     xmm2, xmm6
+    mulps     xmm3, xmm6
+    mulps     xmm4, xmm6
+    mulps     xmm5, xmm6
+    cvtps2pi    m0, xmm0
+    cvtps2pi    m1, xmm1
+    cvtps2pi    m2, xmm2
+    cvtps2pi    m3, xmm3
+    cvtps2pi    m4, xmm4
+    cvtps2pi    m5, xmm5
+    packssdw    m0, m3          ; m0 =  0,  6,  3,  9
+    packssdw    m1, m4          ; m1 =  1,  7,  4, 10
+    packssdw    m2, m5          ; m2 =  2,  8,  5, 11
+                                ; unpack words
+    pshufw      m3, m0, q1032   ; m3 =  3,  9,  0,  6
+    punpcklwd   m0, m1          ; m0 =  0,  1,  6,  7
+    punpckhwd   m1, m2          ; m1 =  4,  5, 10, 11
+    punpcklwd   m2, m3          ; m2 =  2,  3,  8,  9
+                                ; unpack dwords
+    pshufw      m3, m0, q1032   ; m3 =  6,  7,  0,  1
+    punpckldq   m0, m2          ; m0 =  0,  1,  2,  3 (final)
+    punpckhdq   m2, m1          ; m2 =  8,  9, 10, 11 (final)
+    punpckldq   m1, m3          ; m1 =  4,  5,  6,  7 (final)
+    mova [dstq   ], m0
+    mova [dstq+ 8], m1
+    mova [dstq+16], m2
+%endif
+    add       srcq, mmsize
+    add       dstq, mmsize*3
+    sub       lend, mmsize/4
+    jg .loop
+%if mmsize == 8
+    emms
+    RET
+%else
+    REP_RET
+%endif
+%endmacro
+
+INIT_MMX sse
+CONV_FLTP_TO_S16_6CH
+INIT_XMM sse2
+CONV_FLTP_TO_S16_6CH
+%if HAVE_AVX
+INIT_XMM avx
+CONV_FLTP_TO_S16_6CH
+%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 04cec00..a5b0f93 100644
--- a/libavresample/x86/audio_convert_init.c
+++ b/libavresample/x86/audio_convert_init.c
@@ -67,6 +67,13 @@ extern void ff_conv_fltp_to_s16_2ch_sse2(int16_t *dst, float 
*const *src,
 extern void ff_conv_fltp_to_s16_2ch_avx (int16_t *dst, float *const *src,
                                          int len, int channels);
 
+extern void ff_conv_fltp_to_s16_6ch_sse (int16_t *dst, float *const *src,
+                                         int len, int channels);
+extern void ff_conv_fltp_to_s16_6ch_sse2(int16_t *dst, float *const *src,
+                                         int len, int channels);
+extern void ff_conv_fltp_to_s16_6ch_avx (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,
@@ -85,6 +92,10 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
         ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
                                   6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx);
     }
+    if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) {
+        ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
+                                  6, 1, 2, "SSE", ff_conv_fltp_to_s16_6ch_sse);
+    }
     if (mm_flags & AV_CPU_FLAG_SSE2 && HAVE_SSE) {
         if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) {
             ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
@@ -110,6 +121,8 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
                                   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);
+        ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
+                                  6, 16, 4, "SSE2", 
ff_conv_fltp_to_s16_6ch_sse2);
     }
     if (mm_flags & AV_CPU_FLAG_SSE4 && HAVE_SSE) {
         ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
@@ -132,6 +145,8 @@ av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
                                   6, 16, 4, "AVX", 
ff_conv_s16p_to_flt_6ch_avx);
         ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
                                   2, 16, 4, "AVX", 
ff_conv_fltp_to_s16_2ch_avx);
+        ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
+                                  6, 16, 4, "AVX", 
ff_conv_fltp_to_s16_6ch_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);
     }
-- 
1.7.1

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to