1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "config.h"
20 
21 #include "libavutil/attributes.h"
22 #include "libavutil/cpu.h"
23 #include "libavutil/x86/cpu.h"
24 #include "libavcodec/idctdsp.h"
25 #include "libavcodec/xvididct.h"
26 
27 #include "idctdsp.h"
28 #include "xvididct.h"
29 
ff_xvid_idct_init_x86(IDCTDSPContext * c,AVCodecContext * avctx,unsigned high_bit_depth)30 av_cold void ff_xvid_idct_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
31                                    unsigned high_bit_depth)
32 {
33     int cpu_flags = av_get_cpu_flags();
34 
35     if (high_bit_depth ||
36         !(avctx->idct_algo == FF_IDCT_AUTO ||
37           avctx->idct_algo == FF_IDCT_XVID))
38         return;
39 
40 #if (HAVE_MMX_INLINE == 1)
41     if (INLINE_MMX(cpu_flags)) {
42         c->idct_put  = ff_xvid_idct_mmx_put;
43         c->idct_add  = ff_xvid_idct_mmx_add;
44         c->idct      = ff_xvid_idct_mmx;
45         c->perm_type = FF_IDCT_PERM_NONE;
46     }
47 #endif
48 
49 #if (HAVE_MMXEXT_INLINE == 1)
50     if (INLINE_MMXEXT(cpu_flags)) {
51         c->idct_put  = ff_xvid_idct_mmxext_put;
52         c->idct_add  = ff_xvid_idct_mmxext_add;
53         c->idct      = ff_xvid_idct_mmxext;
54         c->perm_type = FF_IDCT_PERM_NONE;
55     }
56 #endif
57 
58 #if (HAVE_SSE2_INLINE == 1)
59     if (INLINE_SSE2(cpu_flags)) {
60         c->idct_put  = ff_xvid_idct_sse2_put;
61         c->idct_add  = ff_xvid_idct_sse2_add;
62         c->idct      = ff_xvid_idct_sse2;
63         c->perm_type = FF_IDCT_PERM_SSE2;
64     }
65 #endif
66 }
67