2 * The simplest mpeg encoder (well, it was the simplest!)
3 * Copyright (c) 2000,2001 Fabrice Bellard
5 * This file is part of FFmpeg.
7 * FFmpeg 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.
12 * FFmpeg 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.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "libavutil/attributes.h"
23 #include "libavutil/cpu.h"
24 #include "libavutil/x86/asm.h"
25 #include "libavutil/x86/cpu.h"
26 #include "libavcodec/avcodec.h"
27 #include "libavcodec/dsputil.h"
28 #include "libavcodec/mpegvideo.h"
29 #include "dsputil_mmx.h"
31 extern uint16_t ff_inv_zigzag_direct16[64];
34 #define COMPILE_TEMPLATE_MMXEXT 0
35 #define COMPILE_TEMPLATE_SSE2 0
36 #define COMPILE_TEMPLATE_SSSE3 0
37 #define RENAME(a) a ## _MMX
38 #define RENAMEl(a) a ## _mmx
39 #include "mpegvideoenc_template.c"
40 #endif /* HAVE_MMX_INLINE */
42 #if HAVE_MMXEXT_INLINE
43 #undef COMPILE_TEMPLATE_SSSE3
44 #undef COMPILE_TEMPLATE_SSE2
45 #undef COMPILE_TEMPLATE_MMXEXT
46 #define COMPILE_TEMPLATE_MMXEXT 1
47 #define COMPILE_TEMPLATE_SSE2 0
48 #define COMPILE_TEMPLATE_SSSE3 0
51 #define RENAME(a) a ## _MMXEXT
52 #define RENAMEl(a) a ## _mmxext
53 #include "mpegvideoenc_template.c"
54 #endif /* HAVE_MMXEXT_INLINE */
57 #undef COMPILE_TEMPLATE_MMXEXT
58 #undef COMPILE_TEMPLATE_SSE2
59 #undef COMPILE_TEMPLATE_SSSE3
60 #define COMPILE_TEMPLATE_MMXEXT 0
61 #define COMPILE_TEMPLATE_SSE2 1
62 #define COMPILE_TEMPLATE_SSSE3 0
65 #define RENAME(a) a ## _SSE2
66 #define RENAMEl(a) a ## _sse2
67 #include "mpegvideoenc_template.c"
68 #endif /* HAVE_SSE2_INLINE */
71 #undef COMPILE_TEMPLATE_MMXEXT
72 #undef COMPILE_TEMPLATE_SSE2
73 #undef COMPILE_TEMPLATE_SSSE3
74 #define COMPILE_TEMPLATE_MMXEXT 0
75 #define COMPILE_TEMPLATE_SSE2 1
76 #define COMPILE_TEMPLATE_SSSE3 1
79 #define RENAME(a) a ## _SSSE3
80 #define RENAMEl(a) a ## _sse2
81 #include "mpegvideoenc_template.c"
82 #endif /* HAVE_SSSE3_INLINE */
84 av_cold void ff_dct_encode_init_x86(MpegEncContext *s)
86 int mm_flags = av_get_cpu_flags();
87 const int dct_algo = s->avctx->dct_algo;
89 if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
91 if (INLINE_MMX(mm_flags))
92 s->dct_quantize = dct_quantize_MMX;
94 #if HAVE_MMXEXT_INLINE
95 if (INLINE_MMXEXT(mm_flags))
96 s->dct_quantize = dct_quantize_MMXEXT;
99 if (INLINE_SSE2(mm_flags))
100 s->dct_quantize = dct_quantize_SSE2;
102 #if HAVE_SSSE3_INLINE
103 if (INLINE_SSSE3(mm_flags))
104 s->dct_quantize = dct_quantize_SSSE3;