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 "libavutil/x86/cpu.h" 00021 #include "libavcodec/dsputil.h" 00022 #include "libavcodec/dct.h" 00023 #include "fft.h" 00024 00025 av_cold void ff_fft_init_mmx(FFTContext *s) 00026 { 00027 int has_vectors = av_get_cpu_flags(); 00028 #if ARCH_X86_32 00029 if (EXTERNAL_AMD3DNOW(has_vectors)) { 00030 /* 3DNow! for K6-2/3 */ 00031 s->imdct_calc = ff_imdct_calc_3dnow; 00032 s->imdct_half = ff_imdct_half_3dnow; 00033 s->fft_calc = ff_fft_calc_3dnow; 00034 } 00035 if (EXTERNAL_AMD3DNOWEXT(has_vectors)) { 00036 /* 3DNowEx for K7 */ 00037 s->imdct_calc = ff_imdct_calc_3dnowext; 00038 s->imdct_half = ff_imdct_half_3dnowext; 00039 s->fft_calc = ff_fft_calc_3dnowext; 00040 } 00041 #endif 00042 if (EXTERNAL_SSE(has_vectors)) { 00043 /* SSE for P3/P4/K8 */ 00044 s->imdct_calc = ff_imdct_calc_sse; 00045 s->imdct_half = ff_imdct_half_sse; 00046 s->fft_permute = ff_fft_permute_sse; 00047 s->fft_calc = ff_fft_calc_sse; 00048 s->fft_permutation = FF_FFT_PERM_SWAP_LSBS; 00049 } 00050 if (EXTERNAL_AVX(has_vectors) && s->nbits >= 5) { 00051 /* AVX for SB */ 00052 s->imdct_half = ff_imdct_half_avx; 00053 s->fft_calc = ff_fft_calc_avx; 00054 s->fft_permutation = FF_FFT_PERM_AVX; 00055 } 00056 } 00057 00058 #if CONFIG_DCT 00059 av_cold void ff_dct_init_mmx(DCTContext *s) 00060 { 00061 int has_vectors = av_get_cpu_flags(); 00062 if (EXTERNAL_SSE(has_vectors)) 00063 s->dct32 = ff_dct32_float_sse; 00064 if (EXTERNAL_SSE2(has_vectors)) 00065 s->dct32 = ff_dct32_float_sse2; 00066 if (EXTERNAL_AVX(has_vectors)) 00067 s->dct32 = ff_dct32_float_avx; 00068 } 00069 #endif