00001 /* 00002 * This file is part of FFmpeg. 00003 * 00004 * FFmpeg 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 * FFmpeg 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 FFmpeg; 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_3DNOW && HAVE_AMD3DNOW) { 00029 /* 3DNow! for K6-2/3 */ 00030 s->imdct_calc = ff_imdct_calc_3dn; 00031 s->imdct_half = ff_imdct_half_3dn; 00032 s->fft_calc = ff_fft_calc_3dn; 00033 } 00034 if (has_vectors & AV_CPU_FLAG_3DNOWEXT && HAVE_AMD3DNOWEXT) { 00035 /* 3DNowEx for K7 */ 00036 s->imdct_calc = ff_imdct_calc_3dn2; 00037 s->imdct_half = ff_imdct_half_3dn2; 00038 s->fft_calc = ff_fft_calc_3dn2; 00039 } 00040 if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) { 00041 /* SSE for P3/P4/K8 */ 00042 s->imdct_calc = ff_imdct_calc_sse; 00043 s->imdct_half = ff_imdct_half_sse; 00044 s->fft_permute = ff_fft_permute_sse; 00045 s->fft_calc = ff_fft_calc_sse; 00046 s->fft_permutation = FF_FFT_PERM_SWAP_LSBS; 00047 } 00048 if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX && s->nbits >= 5) { 00049 /* AVX for SB */ 00050 s->imdct_half = ff_imdct_half_avx; 00051 s->fft_calc = ff_fft_calc_avx; 00052 s->fft_permutation = FF_FFT_PERM_AVX; 00053 } 00054 #endif 00055 } 00056 00057 #if CONFIG_DCT 00058 av_cold void ff_dct_init_mmx(DCTContext *s) 00059 { 00060 #if HAVE_YASM 00061 int has_vectors = av_get_cpu_flags(); 00062 if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) 00063 s->dct32 = ff_dct32_float_sse; 00064 if (has_vectors & AV_CPU_FLAG_SSE2 && HAVE_SSE) 00065 s->dct32 = ff_dct32_float_sse2; 00066 if (has_vectors & AV_CPU_FLAG_AVX && HAVE_AVX) 00067 s->dct32 = ff_dct32_float_avx; 00068 #endif 00069 } 00070 #endif