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/cpu.h"
23 #include "libavutil/x86/asm.h"
24 #include "libavutil/x86/cpu.h"
25 #include "libavcodec/avcodec.h"
26 #include "libavcodec/dsputil.h"
27 #include "libavcodec/mpegvideo.h"
28 #include "dsputil_mmx.h"
30 extern uint16_t ff_inv_zigzag_direct16[64];
33 #define COMPILE_TEMPLATE_MMXEXT 0
34 #define COMPILE_TEMPLATE_SSE2 0
35 #define COMPILE_TEMPLATE_SSSE3 0
36 #define RENAME(a) a ## _MMX
37 #define RENAMEl(a) a ## _mmx
38 #include "mpegvideoenc_template.c"
39 #endif /* HAVE_MMX_INLINE */
41 #if HAVE_MMXEXT_INLINE
42 #undef COMPILE_TEMPLATE_SSSE3
43 #undef COMPILE_TEMPLATE_SSE2
44 #undef COMPILE_TEMPLATE_MMXEXT
45 #define COMPILE_TEMPLATE_MMXEXT 1
46 #define COMPILE_TEMPLATE_SSE2 0
47 #define COMPILE_TEMPLATE_SSSE3 0
50 #define RENAME(a) a ## _MMXEXT
51 #define RENAMEl(a) a ## _mmxext
52 #include "mpegvideoenc_template.c"
53 #endif /* HAVE_MMXEXT_INLINE */
56 #undef COMPILE_TEMPLATE_MMXEXT
57 #undef COMPILE_TEMPLATE_SSE2
58 #undef COMPILE_TEMPLATE_SSSE3
59 #define COMPILE_TEMPLATE_MMXEXT 0
60 #define COMPILE_TEMPLATE_SSE2 1
61 #define COMPILE_TEMPLATE_SSSE3 0
64 #define RENAME(a) a ## _SSE2
65 #define RENAMEl(a) a ## _sse2
66 #include "mpegvideoenc_template.c"
67 #endif /* HAVE_SSE2_INLINE */
70 #undef COMPILE_TEMPLATE_MMXEXT
71 #undef COMPILE_TEMPLATE_SSE2
72 #undef COMPILE_TEMPLATE_SSSE3
73 #define COMPILE_TEMPLATE_MMXEXT 0
74 #define COMPILE_TEMPLATE_SSE2 1
75 #define COMPILE_TEMPLATE_SSSE3 1
78 #define RENAME(a) a ## _SSSE3
79 #define RENAMEl(a) a ## _sse2
80 #include "mpegvideoenc_template.c"
81 #endif /* HAVE_SSSE3_INLINE */
83 void ff_dct_encode_init_x86(MpegEncContext *s)
85 int mm_flags = av_get_cpu_flags();
86 const int dct_algo = s->avctx->dct_algo;
88 if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
90 if (INLINE_MMX(mm_flags))
91 s->dct_quantize = dct_quantize_MMX;
93 #if HAVE_MMXEXT_INLINE
94 if (INLINE_MMXEXT(mm_flags))
95 s->dct_quantize = dct_quantize_MMXEXT;
98 if (INLINE_SSE2(mm_flags))
99 s->dct_quantize = dct_quantize_SSE2;
101 #if HAVE_SSSE3_INLINE
102 if (INLINE_SSSE3(mm_flags))
103 s->dct_quantize = dct_quantize_SSSE3;