libavcodec/x86/fft.c
Go to the documentation of this file.
00001 /*
00002  * This file is part of Libav.
00003  *
00004  * Libav is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * Libav is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with Libav; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00017  */
00018 
00019 #include "libavutil/cpu.h"
00020 #include "libavcodec/dsputil.h"
00021 #include "libavcodec/dct.h"
00022 #include "fft.h"
00023 
00024 av_cold void ff_fft_init_mmx(FFTContext *s)
00025 {
00026 #if HAVE_YASM
00027     int has_vectors = av_get_cpu_flags();
00028     if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX && s->nbits >= 5) {
00029         /* AVX for SB */
00030         s->imdct_calc      = ff_imdct_calc_sse;
00031         s->imdct_half      = ff_imdct_half_avx;
00032         s->fft_permute     = ff_fft_permute_sse;
00033         s->fft_calc        = ff_fft_calc_avx;
00034         s->fft_permutation = FF_FFT_PERM_AVX;
00035     } else if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) {
00036         /* SSE for P3/P4/K8 */
00037         s->imdct_calc  = ff_imdct_calc_sse;
00038         s->imdct_half  = ff_imdct_half_sse;
00039         s->fft_permute = ff_fft_permute_sse;
00040         s->fft_calc    = ff_fft_calc_sse;
00041         s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
00042     }
00043 #endif
00044 }
00045 
00046 #if CONFIG_DCT
00047 av_cold void ff_dct_init_mmx(DCTContext *s)
00048 {
00049 #if HAVE_YASM
00050     int has_vectors = av_get_cpu_flags();
00051     if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX)
00052         s->dct32 = ff_dct32_float_avx;
00053     else if (has_vectors & AV_CPU_FLAG_SSE2 && HAVE_SSE)
00054         s->dct32 = ff_dct32_float_sse2;
00055     else if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE)
00056         s->dct32 = ff_dct32_float_sse;
00057 #endif
00058 }
00059 #endif
00060