2 * The simplest mpeg encoder (well, it was the simplest!)
3 * Copyright (c) 2000,2001 Fabrice Bellard
5 * This file is part of Libav.
7 * Libav 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 * Libav 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 Libav; 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 "libavcodec/avcodec.h"
25 #include "libavcodec/dsputil.h"
26 #include "libavcodec/mpegvideo.h"
27 #include "dsputil_mmx.h"
31 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"
40 #undef COMPILE_TEMPLATE_SSSE3
41 #undef COMPILE_TEMPLATE_SSE2
42 #undef COMPILE_TEMPLATE_MMXEXT
43 #define COMPILE_TEMPLATE_MMXEXT 1
44 #define COMPILE_TEMPLATE_SSE2 0
45 #define COMPILE_TEMPLATE_SSSE3 0
48 #define RENAME(a) a ## _MMX2
49 #define RENAMEl(a) a ## _mmx2
50 #include "mpegvideoenc_template.c"
52 #undef COMPILE_TEMPLATE_MMXEXT
53 #undef COMPILE_TEMPLATE_SSE2
54 #undef COMPILE_TEMPLATE_SSSE3
55 #define COMPILE_TEMPLATE_MMXEXT 0
56 #define COMPILE_TEMPLATE_SSE2 1
57 #define COMPILE_TEMPLATE_SSSE3 0
60 #define RENAME(a) a ## _SSE2
61 #define RENAMEl(a) a ## _sse2
62 #include "mpegvideoenc_template.c"
65 #undef COMPILE_TEMPLATE_MMXEXT
66 #undef COMPILE_TEMPLATE_SSE2
67 #undef COMPILE_TEMPLATE_SSSE3
68 #define COMPILE_TEMPLATE_MMXEXT 0
69 #define COMPILE_TEMPLATE_SSE2 1
70 #define COMPILE_TEMPLATE_SSSE3 1
73 #define RENAME(a) a ## _SSSE3
74 #define RENAMEl(a) a ## _sse2
75 #include "mpegvideoenc_template.c"
78 #endif /* HAVE_INLINE_ASM */
80 void ff_MPV_encode_init_x86(MpegEncContext *s)
83 int mm_flags = av_get_cpu_flags();
84 const int dct_algo = s->avctx->dct_algo;
86 if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
88 if (mm_flags & AV_CPU_FLAG_SSSE3) {
89 s->dct_quantize = dct_quantize_SSSE3;
92 if (mm_flags & AV_CPU_FLAG_SSE2) {
93 s->dct_quantize = dct_quantize_SSE2;
94 } else if (mm_flags & AV_CPU_FLAG_MMXEXT) {
95 s->dct_quantize = dct_quantize_MMX2;
97 s->dct_quantize = dct_quantize_MMX;
100 #endif /* HAVE_INLINE_ASM */