FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dsputil_init.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000, 2001 Fabrice Bellard
3  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
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 "config.h"
23 #include "libavutil/attributes.h"
24 #include "libavutil/cpu.h"
25 #include "libavutil/internal.h"
26 #include "libavutil/x86/cpu.h"
27 #include "libavcodec/avcodec.h"
28 #include "libavcodec/dsputil.h"
29 #include "libavcodec/simple_idct.h"
30 #include "libavcodec/version.h"
31 #include "dsputil_x86.h"
32 #include "idct_xvid.h"
33 
34 
35 int32_t ff_scalarproduct_int16_mmxext(const int16_t *v1, const int16_t *v2,
36  int order);
37 int32_t ff_scalarproduct_int16_sse2(const int16_t *v1, const int16_t *v2,
38  int order);
39 
40 void ff_bswap32_buf_ssse3(uint32_t *dst, const uint32_t *src, int w);
41 void ff_bswap32_buf_sse2(uint32_t *dst, const uint32_t *src, int w);
42 
44  int32_t min, int32_t max, unsigned int len);
46  int32_t min, int32_t max, unsigned int len);
48  int32_t min, int32_t max, unsigned int len);
50  int32_t min, int32_t max, unsigned int len);
51 
53  int cpu_flags, unsigned high_bit_depth)
54 {
55 #if HAVE_MMX_INLINE
58 
59  if (!high_bit_depth) {
61  }
62 
63 #if CONFIG_VIDEODSP && (ARCH_X86_32 || !HAVE_YASM)
64  c->gmc = ff_gmc_mmx;
65 #endif
66 #endif /* HAVE_MMX_INLINE */
67 
68 #if HAVE_MMX_EXTERNAL
69  if (!high_bit_depth) {
72  }
75 #endif /* HAVE_MMX_EXTERNAL */
76 }
77 
79  int cpu_flags, unsigned high_bit_depth)
80 {
81 #if HAVE_MMXEXT_INLINE
82  if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX && avctx->lowres == 0) {
86  }
87 #endif /* HAVE_MMXEXT_INLINE */
88 
89 #if HAVE_MMXEXT_EXTERNAL
91 #endif /* HAVE_MMXEXT_EXTERNAL */
92 }
93 
95  int cpu_flags, unsigned high_bit_depth)
96 {
97 #if HAVE_YASM
98 #if HAVE_SSE_EXTERNAL
100 
101  /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
102  if (CONFIG_XVMC && avctx->hwaccel && avctx->hwaccel->decode_mb)
103  return;
104 
105  if (!high_bit_depth) {
108  }
109 #endif
110 #if HAVE_INLINE_ASM && CONFIG_VIDEODSP
111  c->gmc = ff_gmc_sse;
112 #endif
113 #endif /* HAVE_YASM */
114 }
115 
117  int cpu_flags, unsigned high_bit_depth)
118 {
119 #if HAVE_SSE2_INLINE
120  if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX && avctx->lowres == 0) {
123  c->idct = ff_idct_xvid_sse2;
125  }
126 #endif /* HAVE_SSE2_INLINE */
127 
128 #if HAVE_SSE2_EXTERNAL
130  if (cpu_flags & AV_CPU_FLAG_ATOM) {
132  } else {
134  }
137 #endif /* HAVE_SSE2_EXTERNAL */
138 }
139 
141  int cpu_flags, unsigned high_bit_depth)
142 {
143 #if HAVE_SSSE3_EXTERNAL
145 #endif /* HAVE_SSSE3_EXTERNAL */
146 }
147 
149  int cpu_flags, unsigned high_bit_depth)
150 {
151 #if HAVE_SSE4_EXTERNAL
153 #endif /* HAVE_SSE4_EXTERNAL */
154 }
155 
157  unsigned high_bit_depth)
158 {
159  int cpu_flags = av_get_cpu_flags();
160 
161  if (X86_MMX(cpu_flags)) {
162 #if HAVE_INLINE_ASM
163  const int idct_algo = avctx->idct_algo;
164 
165  if (avctx->lowres == 0 && !high_bit_depth) {
166  if (idct_algo == FF_IDCT_AUTO || idct_algo == FF_IDCT_SIMPLEMMX) {
171  } else if (idct_algo == FF_IDCT_XVIDMMX) {
174  c->idct = ff_idct_xvid_mmx;
175  }
176  }
177 #endif /* HAVE_INLINE_ASM */
178 
179  dsputil_init_mmx(c, avctx, cpu_flags, high_bit_depth);
180  }
181 
182  if (X86_MMXEXT(cpu_flags))
183  dsputil_init_mmxext(c, avctx, cpu_flags, high_bit_depth);
184 
185  if (X86_SSE(cpu_flags))
186  dsputil_init_sse(c, avctx, cpu_flags, high_bit_depth);
187 
188  if (X86_SSE2(cpu_flags))
189  dsputil_init_sse2(c, avctx, cpu_flags, high_bit_depth);
190 
191  if (EXTERNAL_SSSE3(cpu_flags))
192  dsputil_init_ssse3(c, avctx, cpu_flags, high_bit_depth);
193 
194  if (EXTERNAL_SSE4(cpu_flags))
195  dsputil_init_sse4(c, avctx, cpu_flags, high_bit_depth);
196 
197  if (CONFIG_ENCODERS)
198  ff_dsputilenc_init_mmx(c, avctx, high_bit_depth);
199 }