]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/h264_intrapred_init.c
Unroll loop in h264_idct_add8_sse2(). This means we can inline scan8[] in the
[ffmpeg] / libavcodec / x86 / h264_intrapred_init.c
1 /*
2  * Copyright (c) 2010 Jason Garrett-Glaser
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #include "libavutil/cpu.h"
22 #include "libavcodec/h264pred.h"
23
24 void ff_pred16x16_vertical_mmx     (uint8_t *src, int stride);
25 void ff_pred16x16_vertical_sse     (uint8_t *src, int stride);
26 void ff_pred16x16_horizontal_mmx   (uint8_t *src, int stride);
27 void ff_pred16x16_horizontal_mmxext(uint8_t *src, int stride);
28 void ff_pred16x16_horizontal_ssse3 (uint8_t *src, int stride);
29 void ff_pred16x16_dc_mmxext        (uint8_t *src, int stride);
30 void ff_pred16x16_dc_sse2          (uint8_t *src, int stride);
31 void ff_pred16x16_dc_ssse3         (uint8_t *src, int stride);
32 void ff_pred16x16_tm_vp8_mmx       (uint8_t *src, int stride);
33 void ff_pred16x16_tm_vp8_mmxext    (uint8_t *src, int stride);
34 void ff_pred16x16_tm_vp8_sse2      (uint8_t *src, int stride);
35 void ff_pred8x8_dc_rv40_mmxext     (uint8_t *src, int stride);
36 void ff_pred8x8_vertical_mmx       (uint8_t *src, int stride);
37 void ff_pred8x8_horizontal_mmx     (uint8_t *src, int stride);
38 void ff_pred8x8_horizontal_mmxext  (uint8_t *src, int stride);
39 void ff_pred8x8_horizontal_ssse3   (uint8_t *src, int stride);
40 void ff_pred8x8_tm_vp8_mmx         (uint8_t *src, int stride);
41 void ff_pred8x8_tm_vp8_mmxext      (uint8_t *src, int stride);
42 void ff_pred8x8_tm_vp8_sse2        (uint8_t *src, int stride);
43 void ff_pred8x8_tm_vp8_ssse3       (uint8_t *src, int stride);
44 void ff_pred4x4_dc_mmxext          (uint8_t *src, const uint8_t *topright, int stride);
45 void ff_pred4x4_tm_vp8_mmx         (uint8_t *src, const uint8_t *topright, int stride);
46 void ff_pred4x4_tm_vp8_mmxext      (uint8_t *src, const uint8_t *topright, int stride);
47 void ff_pred4x4_tm_vp8_ssse3       (uint8_t *src, const uint8_t *topright, int stride);
48 void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride);
49
50 void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
51 {
52     int mm_flags = av_get_cpu_flags();
53
54 #if HAVE_YASM
55     if (mm_flags & AV_CPU_FLAG_MMX) {
56         h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx;
57         h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx;
58         h->pred8x8  [VERT_PRED8x8] = ff_pred8x8_vertical_mmx;
59         h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx;
60         if (codec_id == CODEC_ID_VP8) {
61             h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx;
62             h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx;
63             h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_mmx;
64         }
65     }
66
67     if (mm_flags & AV_CPU_FLAG_MMX2) {
68         h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
69         h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_mmxext;
70         h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext;
71         h->pred4x4  [DC_PRED     ] = ff_pred4x4_dc_mmxext;
72         if (codec_id == CODEC_ID_VP8) {
73             h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext;
74             h->pred8x8  [DC_PRED8x8   ] = ff_pred8x8_dc_rv40_mmxext;
75             h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext;
76             h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_mmxext;
77             h->pred4x4  [VERT_PRED    ] = ff_pred4x4_vertical_vp8_mmxext;
78         }
79     }
80
81     if (mm_flags & AV_CPU_FLAG_SSE) {
82         h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse;
83     }
84
85     if (mm_flags & AV_CPU_FLAG_SSE2) {
86         h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_sse2;
87         if (codec_id == CODEC_ID_VP8) {
88             h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2;
89             h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2;
90         }
91     }
92
93     if (mm_flags & AV_CPU_FLAG_SSSE3) {
94         h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
95         h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_ssse3;
96         h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3;
97         if (codec_id == CODEC_ID_VP8) {
98             h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3;
99             h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_ssse3;
100         }
101     }
102 #endif
103 }