FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mpegvideoenc.c
Go to the documentation of this file.
1 /*
2  * The simplest mpeg encoder (well, it was the simplest!)
3  * Copyright (c) 2000,2001 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
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.
11  *
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.
16  *
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
20  */
21 
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/dct.h"
28 #include "libavcodec/mpegvideo.h"
29 #include "dsputil_mmx.h"
30 
31 extern uint16_t ff_inv_zigzag_direct16[64];
32 
33 #if HAVE_MMX_INLINE
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 */
41 
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
49 #undef RENAME
50 #undef RENAMEl
51 #define RENAME(a) a ## _MMXEXT
52 #define RENAMEl(a) a ## _mmxext
53 #include "mpegvideoenc_template.c"
54 #endif /* HAVE_MMXEXT_INLINE */
55 
56 #if HAVE_SSE2_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
63 #undef RENAME
64 #undef RENAMEl
65 #define RENAME(a) a ## _SSE2
66 #define RENAMEl(a) a ## _sse2
67 #include "mpegvideoenc_template.c"
68 #endif /* HAVE_SSE2_INLINE */
69 
70 #if HAVE_SSSE3_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
77 #undef RENAME
78 #undef RENAMEl
79 #define RENAME(a) a ## _SSSE3
80 #define RENAMEl(a) a ## _sse2
81 #include "mpegvideoenc_template.c"
82 #endif /* HAVE_SSSE3_INLINE */
83 
85 {
86  int mm_flags = av_get_cpu_flags();
87  const int dct_algo = s->avctx->dct_algo;
88 
89  if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
90 #if HAVE_MMX_INLINE
91  if (INLINE_MMX(mm_flags))
92  s->dct_quantize = dct_quantize_MMX;
93 #endif
94 #if HAVE_MMXEXT_INLINE
95  if (INLINE_MMXEXT(mm_flags))
96  s->dct_quantize = dct_quantize_MMXEXT;
97 #endif
98 #if HAVE_SSE2_INLINE
99  if (INLINE_SSE2(mm_flags))
100  s->dct_quantize = dct_quantize_SSE2;
101 #endif
102 #if HAVE_SSSE3_INLINE
103  if (INLINE_SSSE3(mm_flags))
104  s->dct_quantize = dct_quantize_SSSE3;
105 #endif
106  }
107 }