fft_init.c 2.38 KB
Newer Older
1
/*
2
 * This file is part of Libav.
3
 *
4
 * Libav is free software; you can redistribute it and/or
5 6 7 8
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
9
 * Libav is distributed in the hope that it will be useful,
10 11 12 13 14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with Libav; if not, write to the Free Software
16 17 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

19
#include "libavutil/cpu.h"
20
#include "libavcodec/dsputil.h"
21
#include "libavcodec/dct.h"
22 23 24 25 26
#include "fft.h"

av_cold void ff_fft_init_mmx(FFTContext *s)
{
#if HAVE_YASM
27
    int has_vectors = av_get_cpu_flags();
28
#if ARCH_X86_32
29 30
    if (has_vectors & AV_CPU_FLAG_3DNOW && HAVE_AMD3DNOW) {
        /* 3DNow! for K6-2/3 */
31 32 33
        s->imdct_calc = ff_imdct_calc_3dnow;
        s->imdct_half = ff_imdct_half_3dnow;
        s->fft_calc   = ff_fft_calc_3dnow;
34 35 36
    }
    if (has_vectors & AV_CPU_FLAG_3DNOWEXT && HAVE_AMD3DNOWEXT) {
        /* 3DNowEx for K7 */
37 38 39
        s->imdct_calc = ff_imdct_calc_3dnowext;
        s->imdct_half = ff_imdct_half_3dnowext;
        s->fft_calc   = ff_fft_calc_3dnowext;
40
    }
41
#endif
42
    if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) {
43 44 45 46 47
        /* SSE for P3/P4/K8 */
        s->imdct_calc  = ff_imdct_calc_sse;
        s->imdct_half  = ff_imdct_half_sse;
        s->fft_permute = ff_fft_permute_sse;
        s->fft_calc    = ff_fft_calc_sse;
48
        s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
49 50 51 52 53 54
    }
    if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX && s->nbits >= 5) {
        /* AVX for SB */
        s->imdct_half      = ff_imdct_half_avx;
        s->fft_calc        = ff_fft_calc_avx;
        s->fft_permutation = FF_FFT_PERM_AVX;
55 56 57
    }
#endif
}
Vitor Sessak's avatar
Vitor Sessak committed
58

59
#if CONFIG_DCT
Vitor Sessak's avatar
Vitor Sessak committed
60 61
av_cold void ff_dct_init_mmx(DCTContext *s)
{
62
#if HAVE_YASM
63
    int has_vectors = av_get_cpu_flags();
64 65 66 67
    if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE)
        s->dct32 = ff_dct32_float_sse;
    if (has_vectors & AV_CPU_FLAG_SSE2 && HAVE_SSE)
        s->dct32 = ff_dct32_float_sse2;
68 69
    if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX)
        s->dct32 = ff_dct32_float_avx;
70
#endif
Vitor Sessak's avatar
Vitor Sessak committed
71
}
72
#endif