From ca986a06ad1ad81bf4c16720aec608c70f958ef4 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Sun, 13 May 2012 20:53:30 +0200
Subject: [PATCH] libswresample-simd: add ff_pack_6ch_int32_to_float_a_avx and
 ff_pack_6ch_int32_to_float_a_sse4

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
---
 libswresample/x86/audio_convert.asm | 25 ++++++++++++++++++-------
 libswresample/x86/swresample_x86.c  |  4 ++++
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/libswresample/x86/audio_convert.asm b/libswresample/x86/audio_convert.asm
index 6f335758012..19e3e047326 100644
--- a/libswresample/x86/audio_convert.asm
+++ b/libswresample/x86/audio_convert.asm
@@ -199,7 +199,7 @@ cglobal %2_to_%1_%3, 3, 3, 6, dst, src, len
     REP_RET
 %endmacro
 
-%macro PACK_6CH 3
+%macro PACK_6CH 5-7
 cglobal pack_6ch_%2_to_%1_%3, 2,8,7, dst, src, src1, src2, src3, src4, src5, len
 %if ARCH_X86_64
     mov     lend, r2d
@@ -241,6 +241,7 @@ pack_6ch_%2_to_%1_u_int %+ SUFFIX
     mov%3     m3, [srcq+src3q]
     mov%3     m4, [srcq+src4q]
     mov%3     m5, [srcq+src5q]
+    %7 x,x,x,x,m7,x
 %if cpuflag(sse4)
     SBUTTERFLYPS 0, 1, 6
     SBUTTERFLYPS 2, 3, 6
@@ -253,6 +254,10 @@ pack_6ch_%2_to_%1_u_int %+ SUFFIX
     movlhps   m1, m3
     movhlps   m5, m3
 
+    %6 m0,m6,x,x,m7,m3
+    %6 m4,m1,x,x,m7,m3
+    %6 m2,m5,x,x,m7,m3
+
     mov %+ %3 %+ ps [dstq   ], m0
     mov %+ %3 %+ ps [dstq+16], m6
     mov %+ %3 %+ ps [dstq+32], m4
@@ -369,8 +374,8 @@ CONV int32, int16, a, 2, 1, INT16_TO_INT32_N, NOP_N
 CONV int16, int32, u, 1, 2, INT32_TO_INT16_N, NOP_N
 CONV int16, int32, a, 1, 2, INT32_TO_INT16_N, NOP_N
 
-PACK_6CH float,float,u
-PACK_6CH float,float,a
+PACK_6CH float, float, u, 2, 2, NOP_N, NOP_N
+PACK_6CH float, float, a, 2, 2, NOP_N, NOP_N
 
 INIT_XMM sse
 CONV int32, int16, u, 2, 1, INT16_TO_INT32_N, NOP_N
@@ -434,13 +439,19 @@ UNPACK_2CH float, int16, u, 2, 1, INT16_TO_FLOAT_N, INT16_TO_FLOAT_INIT
 UNPACK_2CH float, int16, a, 2, 1, INT16_TO_FLOAT_N, INT16_TO_FLOAT_INIT
 
 INIT_XMM sse4
-PACK_6CH float,float,u
-PACK_6CH float,float,a
+PACK_6CH float, float, u, 2, 2, NOP_N, NOP_N
+PACK_6CH float, float, a, 2, 2, NOP_N, NOP_N
+
+PACK_6CH float, int32, u, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
+PACK_6CH float, int32, a, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
 
 %if HAVE_AVX
 INIT_XMM avx
-PACK_6CH float,float,u
-PACK_6CH float,float,a
+PACK_6CH float, float, u, 2, 2, NOP_N, NOP_N
+PACK_6CH float, float, a, 2, 2, NOP_N, NOP_N
+
+PACK_6CH float, int32, u, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
+PACK_6CH float, int32, a, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
 
 INIT_YMM avx
 CONV float, int32, u, 2, 2, INT32_TO_FLOAT_N, INT32_TO_FLOAT_INIT
diff --git a/libswresample/x86/swresample_x86.c b/libswresample/x86/swresample_x86.c
index f2349b505ae..3a91d365a13 100644
--- a/libswresample/x86/swresample_x86.c
+++ b/libswresample/x86/swresample_x86.c
@@ -123,6 +123,8 @@ MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE, sse)
         if(channels == 6) {
             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
                 ac->simd_f =  ff_pack_6ch_float_to_float_a_sse4;
+            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
+                ac->simd_f =  ff_pack_6ch_int32_to_float_a_sse4;
         }
     }
     if(HAVE_AVX && mm_flags & AV_CPU_FLAG_AVX) {
@@ -131,6 +133,8 @@ MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE, sse)
         if(channels == 6) {
             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
                 ac->simd_f =  ff_pack_6ch_float_to_float_a_avx;
+            if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
+                ac->simd_f =  ff_pack_6ch_int32_to_float_a_avx;
         }
     }
 }
-- 
GitLab