This reverts commit 82992604706144910f4a2f875d48cfc66c1b70d7. It breaks shared builds on x86_64.
Unified · Split
| @@ -43,6 +43,7 @@ YASM-OBJS-$(CONFIG_DIRAC_DECODER) += x86/diracdsp_mmx.o x86/diracdsp_yasm.o · 42 unmodified lines | ||
| 43 | 43 | YASM-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_yasm.o |
| 44 | 44 | YASM-OBJS-FFT-$(HAVE_AMD3DNOW) += x86/fft_3dn.o |
| 45 | 45 | YASM-OBJS-FFT-$(HAVE_AMD3DNOWEXT) += x86/fft_3dn2.o |
| 46 | +YASM-OBJS-FFT-$(HAVE_SSE) += x86/fft_sse.o | |
| 46 | 47 | YASM-OBJS-$(CONFIG_FFT) += x86/fft_mmx.o \ |
| 47 | 48 | $(YASM-OBJS-FFT-yes) |
| 48 | 49 | |
| @@ -47,10 +47,6 @@ struc FFTContext · 46 unmodified lines | ||
| 47 | 47 | .mdctbits: resd 1 |
| 48 | 48 | .tcos: pointer 1 |
| 49 | 49 | .tsin: pointer 1 |
| 50 | − .fftperm: pointer 1 | |
| 51 | − .fftcalc: pointer 1 | |
| 52 | − .imdctcalc:pointer 1 | |
| 53 | − .imdcthalf:pointer 1 | |
| 54 | 50 | endstruc |
| 55 | 51 | |
| 56 | 52 | %define M_SQRT1_2 0.70710678118654752440 |
| @@ -69,7 +65,6 @@ perm1: dd 0x00, 0x02, 0x03, 0x01, 0x03, 0x00, 0x02, 0x01 · 12 unmodified lines | ||
| 69 | 65 | perm2: dd 0x00, 0x01, 0x02, 0x03, 0x01, 0x00, 0x02, 0x03 |
| 70 | 66 | ps_p1p1m1p1root2: dd 1.0, 1.0, -1.0, 1.0, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2 |
| 71 | 67 | ps_m1m1p1m1p1m1m1m1: dd 1<<31, 1<<31, 0, 1<<31, 0, 1<<31, 1<<31, 1<<31 |
| 72 | −ps_m1m1m1m1: times 4 dd 1<<31 | |
| 73 | 68 | ps_m1p1: dd 1<<31, 0 |
| 74 | 69 | |
| 75 | 70 | %assign i 16 |
| @@ -538,16 +533,6 @@ DEFINE_ARGS z, w, n, o1, o3 · 462 unmodified lines | ||
| 538 | 533 | rep ret |
| 539 | 534 | %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 | − | |
| 551 | 536 | INIT_YMM avx |
| 552 | 537 | |
| 553 | 538 | %if HAVE_AVX |
| @@ -564,14 +549,6 @@ INIT_YMM avx · 10 unmodified lines | ||
| 564 | 549 | |
| 565 | 550 | DECL_PASS pass_avx, PASS_BIG 1 |
| 566 | 551 | DECL_PASS pass_interleave_avx, PASS_BIG 0 |
| 567 | − | |
| 568 | −cglobal 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 | 552 | %endif |
| 576 | 553 | |
| 577 | 554 | INIT_XMM sse |
| @@ -589,112 +566,6 @@ INIT_XMM sse · 11 unmodified lines | ||
| 589 | 566 | DECL_PASS pass_sse, PASS_BIG 1 |
| 590 | 567 | DECL_PASS pass_interleave_sse, PASS_BIG 0 |
| 591 | 568 | |
| 592 | −cglobal 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 | − | |
| 619 | −cextern_naked memcpy | |
| 620 | − | |
| 621 | −cglobal 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 | − | |
| 659 | −cglobal 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 | − | |
| 698 | 569 | INIT_MMX 3dnow |
| 699 | 570 | %define mulps pfmul |
| 700 | 571 | %define addps pfadd |
| @@ -712,6 +583,16 @@ DECL_PASS pass_interleave_3dnow, PASS_BIG 0 · 11 unmodified lines | ||
| 712 | 583 | %define SECTION_REL |
| 713 | 584 | %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 | 596 | %macro DECL_FFT 1-2 ; nbits, suffix |
| 716 | 597 | %ifidn %0, 1 |
| 717 | 598 | %xdefine fullsuffix SUFFIX |
| @@ -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 | + | |
| 27 | +DECLARE_ASM_CONST(16, unsigned int, ff_m1m1m1m1)[4] = | |
| 28 | + { 1U << 31, 1U << 31, 1U << 31, 1U << 31 }; | |
| 29 | + | |
| 30 | +void ff_fft_dispatch_sse(FFTComplex *z, int nbits); | |
| 31 | +void ff_fft_dispatch_interleave_sse(FFTComplex *z, int nbits); | |
| 32 | +void ff_fft_dispatch_interleave_avx(FFTComplex *z, int nbits); | |
| 33 | + | |
| 34 | +#if HAVE_AVX | |
| 35 | +void ff_fft_calc_avx(FFTContext *s, FFTComplex *z) | |
| 36 | +{ | |
| 37 | + ff_fft_dispatch_interleave_avx(z, s->nbits); | |
| 38 | +} | |
| 39 | +#endif | |
| 40 | + | |
| 41 | +void 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 | + | |
| 66 | +void 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 | + | |
| 83 | +void 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 | +} | |