History

Revert "x86: fft: convert sse inline asm to yasm"

This reverts commit 82992604706144910f4a2f875d48cfc66c1b70d7. It breaks shared builds on x86_64.

Nicolas George committed 14 years ago

Commit fd91a3e1 parent f7676583 files · +121 −129Browse files

Unified · Split

3 files
  1. libavcodec/x86/Makefile +1 −0
  2. libavcodec/x86/fft_mmx.asm +10 −129
  3. libavcodec/x86/fft_sse.c +110 −0
libavcodec/x86/Makefile+1−0
@@ -43,6 +43,7 @@ YASM-OBJS-$(CONFIG_DIRAC_DECODER) += x86/diracdsp_mmx.o x86/diracdsp_yasm.o · 42 unmodified lines
43YASM-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_yasm.o43YASM-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_yasm.o
44YASM-OBJS-FFT-$(HAVE_AMD3DNOW) += x86/fft_3dn.o44YASM-OBJS-FFT-$(HAVE_AMD3DNOW) += x86/fft_3dn.o
45YASM-OBJS-FFT-$(HAVE_AMD3DNOWEXT) += x86/fft_3dn2.o45YASM-OBJS-FFT-$(HAVE_AMD3DNOWEXT) += x86/fft_3dn2.o
46YASM-OBJS-FFT-$(HAVE_SSE) += x86/fft_sse.o
46YASM-OBJS-$(CONFIG_FFT) += x86/fft_mmx.o \47YASM-OBJS-$(CONFIG_FFT) += x86/fft_mmx.o \
47 $(YASM-OBJS-FFT-yes)48 $(YASM-OBJS-FFT-yes)
48 49
libavcodec/x86/fft_mmx.asm+10−129
@@ -47,10 +47,6 @@ struc FFTContext · 46 unmodified lines
47 .mdctbits: resd 147 .mdctbits: resd 1
48 .tcos: pointer 148 .tcos: pointer 1
49 .tsin: pointer 149 .tsin: pointer 1
50 .fftperm: pointer 1
51 .fftcalc: pointer 1
52 .imdctcalc:pointer 1
53 .imdcthalf:pointer 1
54endstruc50endstruc
55 51
56%define M_SQRT1_2 0.7071067811865475244052%define M_SQRT1_2 0.70710678118654752440
@@ -69,7 +65,6 @@ perm1: dd 0x00, 0x02, 0x03, 0x01, 0x03, 0x00, 0x02, 0x01 · 12 unmodified lines
69perm2: dd 0x00, 0x01, 0x02, 0x03, 0x01, 0x00, 0x02, 0x0365perm2: dd 0x00, 0x01, 0x02, 0x03, 0x01, 0x00, 0x02, 0x03
70ps_p1p1m1p1root2: dd 1.0, 1.0, -1.0, 1.0, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, M_SQRT1_266ps_p1p1m1p1root2: dd 1.0, 1.0, -1.0, 1.0, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2
71ps_m1m1p1m1p1m1m1m1: dd 1<<31, 1<<31, 0, 1<<31, 0, 1<<31, 1<<31, 1<<3167ps_m1m1p1m1p1m1m1m1: dd 1<<31, 1<<31, 0, 1<<31, 0, 1<<31, 1<<31, 1<<31
72ps_m1m1m1m1: times 4 dd 1<<31
73ps_m1p1: dd 1<<31, 068ps_m1p1: dd 1<<31, 0
74 69
75%assign i 1670%assign i 16
@@ -538,16 +533,6 @@ DEFINE_ARGS z, w, n, o1, o3 · 462 unmodified lines
538 rep ret533 rep ret
539%endmacro534%endmacro
540 535
541%macro FFT_DISPATCH 2; clobbers 5 GPRs, 8 XMMs
542 lea r2, [dispatch_tab%1]
543 mov r2, [r2 + (%2q-2)*gprsize]
544%ifdef PIC
545 lea r3, [$$]
546 add r2, r3
547%endif
548 call r2
549%endmacro ; FFT_DISPATCH
550
551INIT_YMM avx536INIT_YMM avx
552 537
553%if HAVE_AVX538%if HAVE_AVX
@@ -564,14 +549,6 @@ INIT_YMM avx · 10 unmodified lines
564 549
565DECL_PASS pass_avx, PASS_BIG 1550DECL_PASS pass_avx, PASS_BIG 1
566DECL_PASS pass_interleave_avx, PASS_BIG 0551DECL_PASS pass_interleave_avx, PASS_BIG 0
567
568cglobal fft_calc, 2,5,8
569 mov r3d, [r0 + FFTContext.nbits]
570 mov r0, r1
571 mov r1, r3
572 FFT_DISPATCH _interleave %+ SUFFIX, r1
573 REP_RET
574
575%endif552%endif
576 553
577INIT_XMM sse554INIT_XMM sse
@@ -589,112 +566,6 @@ INIT_XMM sse · 11 unmodified lines
589DECL_PASS pass_sse, PASS_BIG 1566DECL_PASS pass_sse, PASS_BIG 1
590DECL_PASS pass_interleave_sse, PASS_BIG 0567DECL_PASS pass_interleave_sse, PASS_BIG 0
591 568
592cglobal fft_calc, 2,5,8
593 mov r3d, [r0 + FFTContext.nbits]
594 PUSH r1
595 PUSH r3
596 mov r0, r1
597 mov r1, r3
598 FFT_DISPATCH _interleave %+ SUFFIX, r1
599 POP rcx
600 POP r4
601 cmp rcx, 4
602 jg .end
603 mov r2, -1
604 add rcx, 3
605 shl r2, cl
606 sub r4, r2
607.loop
608 movaps xmm0, [r4 + r2]
609 movaps xmm1, xmm0
610 unpcklps xmm0, [r4 + r2 + 16]
611 unpckhps xmm1, [r4 + r2 + 16]
612 movaps [r4 + r2], xmm0
613 movaps [r4 + r2 + 16], xmm1
614 add r2, 32
615 jl .loop
616.end:
617 REP_RET
618
619cextern_naked memcpy
620
621cglobal fft_permute, 2,7,1
622 mov r4, [r0 + FFTContext.revtab]
623 mov r5, [r0 + FFTContext.tmpbuf]
624 mov ecx, [r0 + FFTContext.nbits]
625 mov r2, 1
626 shl r2, cl
627 xor r0, r0
628%if ARCH_X86_32
629 mov r1, r1m
630%endif
631.loop:
632 movaps xmm0, [r1 + 8*r0]
633 movzx r6, word [r4 + 2*r0]
634 movzx r3, word [r4 + 2*r0 + 2]
635 movlps [r5 + 8*r6], xmm0
636 movhps [r5 + 8*r3], xmm0
637 add r0, 2
638 cmp r0, r2
639 jl .loop
640 shl r2, 3
641%if ARCH_X86_64
642 mov r0, r1
643 mov r1, r5
644%else
645 push r2
646 push r5
647 push r1
648%endif
649%if ARCH_X86_64 && WIN64 == 0
650 jmp memcpy
651%else
652 call memcpy
653%if ARCH_X86_32
654 add esp, 12
655%endif
656 REP_RET
657%endif
658
659cglobal imdct_calc, 3,5,3
660 mov r3d, [r0 + FFTContext.mdctsize]
661 mov r4, [r0 + FFTContext.imdcthalf]
662 add r1, r3
663 PUSH r3
664 PUSH r1
665%if ARCH_X86_32
666 push r2
667 push r1
668 push r0
669%else
670 sub rsp, 8
671%endif
672 call r4
673%if ARCH_X86_32
674 add esp, 12
675%else
676 add rsp, 8
677%endif
678 POP r1
679 POP r3
680 lea r0, [r1 + 2*r3]
681 mov r2, r3
682 sub r3, 16
683 neg r2
684 movaps xmm2, [ps_m1m1m1m1]
685.loop:
686 movaps xmm0, [r1 + r3]
687 movaps xmm1, [r0 + r2]
688 shufps xmm0, xmm0, 0x1b
689 shufps xmm1, xmm1, 0x1b
690 xorps xmm0, xmm2
691 movaps [r0 + r3], xmm1
692 movaps [r1 + r2], xmm0
693 sub r3, 16
694 add r2, 16
695 jl .loop
696 REP_RET
697
698INIT_MMX 3dnow569INIT_MMX 3dnow
699%define mulps pfmul570%define mulps pfmul
700%define addps pfadd571%define addps pfadd
@@ -712,6 +583,16 @@ DECL_PASS pass_interleave_3dnow, PASS_BIG 0 · 11 unmodified lines
712%define SECTION_REL583%define SECTION_REL
713%endif584%endif
714 585
586%macro FFT_DISPATCH 2; clobbers 5 GPRs, 8 XMMs
587 lea r2, [dispatch_tab%1]
588 mov r2, [r2 + (%2q-2)*gprsize]
589%ifdef PIC
590 lea r3, [$$]
591 add r2, r3
592%endif
593 call r2
594%endmacro ; FFT_DISPATCH
595
715%macro DECL_FFT 1-2 ; nbits, suffix596%macro DECL_FFT 1-2 ; nbits, suffix
716%ifidn %0, 1597%ifidn %0, 1
717%xdefine fullsuffix SUFFIX598%xdefine fullsuffix SUFFIX
libavcodec/x86/fft_sse.c+110−0
@@ -0,0 +1,110 @@
1/*
2 * FFT/MDCT transform with SSE optimizations
3 * Copyright (c) 2008 Loren Merritt
4 *
5 * This file is part of Libav.
6 *
7 * Libav is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * Libav is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Libav; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "libavutil/x86_cpu.h"
23#include "libavcodec/dsputil.h"
24#include "fft.h"
25#include "config.h"
26
27DECLARE_ASM_CONST(16, unsigned int, ff_m1m1m1m1)[4] =
28 { 1U << 31, 1U << 31, 1U << 31, 1U << 31 };
29
30void ff_fft_dispatch_sse(FFTComplex *z, int nbits);
31void ff_fft_dispatch_interleave_sse(FFTComplex *z, int nbits);
32void ff_fft_dispatch_interleave_avx(FFTComplex *z, int nbits);
33
34#if HAVE_AVX
35void ff_fft_calc_avx(FFTContext *s, FFTComplex *z)
36{
37 ff_fft_dispatch_interleave_avx(z, s->nbits);
38}
39#endif
40
41void ff_fft_calc_sse(FFTContext *s, FFTComplex *z)
42{
43 int n = 1 << s->nbits;
44
45 ff_fft_dispatch_interleave_sse(z, s->nbits);
46
47 if(n <= 16) {
48 x86_reg i = -8*n;
49 __asm__ volatile(
50 "1: \n"
51 "movaps (%0,%1), %%xmm0 \n"
52 "movaps %%xmm0, %%xmm1 \n"
53 "unpcklps 16(%0,%1), %%xmm0 \n"
54 "unpckhps 16(%0,%1), %%xmm1 \n"
55 "movaps %%xmm0, (%0,%1) \n"
56 "movaps %%xmm1, 16(%0,%1) \n"
57 "add $32, %0 \n"
58 "jl 1b \n"
59 :"+r"(i)
60 :"r"(z+n)
61 :"memory"
62 );
63 }
64}
65
66void ff_fft_permute_sse(FFTContext *s, FFTComplex *z)
67{
68 int n = 1 << s->nbits;
69 int i;
70 for(i=0; i<n; i+=2) {
71 __asm__ volatile(
72 "movaps %2, %%xmm0 \n"
73 "movlps %%xmm0, %0 \n"
74 "movhps %%xmm0, %1 \n"
75 :"=m"(s->tmp_buf[s->revtab[i]]),
76 "=m"(s->tmp_buf[s->revtab[i+1]])
77 :"m"(z[i])
78 );
79 }
80 memcpy(z, s->tmp_buf, n*sizeof(FFTComplex));
81}
82
83void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input)
84{
85 x86_reg j, k;
86 long n = s->mdct_size;
87 long n4 = n >> 2;
88
89 s->imdct_half(s, output + n4, input);
90
91 j = -n;
92 k = n-16;
93 __asm__ volatile(
94 "movaps "MANGLE(ff_m1m1m1m1)", %%xmm7 \n"
95 "1: \n"
96 "movaps (%2,%1), %%xmm0 \n"
97 "movaps (%3,%0), %%xmm1 \n"
98 "shufps $0x1b, %%xmm0, %%xmm0 \n"
99 "shufps $0x1b, %%xmm1, %%xmm1 \n"
100 "xorps %%xmm7, %%xmm0 \n"
101 "movaps %%xmm1, (%3,%1) \n"
102 "movaps %%xmm0, (%2,%0) \n"
103 "sub $16, %1 \n"
104 "add $16, %0 \n"
105 "jl 1b \n"
106 :"+r"(j), "+r"(k)
107 :"r"(output+n4), "r"(output+n4*3)
108 XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm7")
109 );
110}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t