summaryrefslogtreecommitdiff
path: root/libavcodec/x86/h264_intrapred_init.c
blob: 4142cc1edd0367d8673918423db7719e5d9887fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
 * Copyright (c) 2010 Jason Garrett-Glaser
 *
 * This file is part of Libav.
 *
 * Libav is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Libav is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Libav; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "libavutil/cpu.h"
#include "libavcodec/h264pred.h"

void ff_pred16x16_vertical_mmx     (uint8_t *src, int stride);
void ff_pred16x16_vertical_sse     (uint8_t *src, int stride);
void ff_pred16x16_horizontal_mmx   (uint8_t *src, int stride);
void ff_pred16x16_horizontal_mmxext(uint8_t *src, int stride);
void ff_pred16x16_horizontal_ssse3 (uint8_t *src, int stride);
void ff_pred16x16_dc_mmxext        (uint8_t *src, int stride);
void ff_pred16x16_dc_sse2          (uint8_t *src, int stride);
void ff_pred16x16_dc_ssse3         (uint8_t *src, int stride);
void ff_pred16x16_plane_h264_mmx   (uint8_t *src, int stride);
void ff_pred16x16_plane_h264_mmx2  (uint8_t *src, int stride);
void ff_pred16x16_plane_h264_sse2  (uint8_t *src, int stride);
void ff_pred16x16_plane_h264_ssse3 (uint8_t *src, int stride);
void ff_pred16x16_plane_rv40_mmx   (uint8_t *src, int stride);
void ff_pred16x16_plane_rv40_mmx2  (uint8_t *src, int stride);
void ff_pred16x16_plane_rv40_sse2  (uint8_t *src, int stride);
void ff_pred16x16_plane_rv40_ssse3 (uint8_t *src, int stride);
void ff_pred16x16_plane_svq3_mmx   (uint8_t *src, int stride);
void ff_pred16x16_plane_svq3_mmx2  (uint8_t *src, int stride);
void ff_pred16x16_plane_svq3_sse2  (uint8_t *src, int stride);
void ff_pred16x16_plane_svq3_ssse3 (uint8_t *src, int stride);
void ff_pred16x16_tm_vp8_mmx       (uint8_t *src, int stride);
void ff_pred16x16_tm_vp8_mmxext    (uint8_t *src, int stride);
void ff_pred16x16_tm_vp8_sse2      (uint8_t *src, int stride);
void ff_pred8x8_top_dc_mmxext      (uint8_t *src, int stride);
void ff_pred8x8_dc_rv40_mmxext     (uint8_t *src, int stride);
void ff_pred8x8_dc_mmxext          (uint8_t *src, int stride);
void ff_pred8x8_vertical_mmx       (uint8_t *src, int stride);
void ff_pred8x8_horizontal_mmx     (uint8_t *src, int stride);
void ff_pred8x8_horizontal_mmxext  (uint8_t *src, int stride);
void ff_pred8x8_horizontal_ssse3   (uint8_t *src, int stride);
void ff_pred8x8_plane_mmx          (uint8_t *src, int stride);
void ff_pred8x8_plane_mmx2         (uint8_t *src, int stride);
void ff_pred8x8_plane_sse2         (uint8_t *src, int stride);
void ff_pred8x8_plane_ssse3        (uint8_t *src, int stride);
void ff_pred8x8_tm_vp8_mmx         (uint8_t *src, int stride);
void ff_pred8x8_tm_vp8_mmxext      (uint8_t *src, int stride);
void ff_pred8x8_tm_vp8_sse2        (uint8_t *src, int stride);
void ff_pred8x8_tm_vp8_ssse3       (uint8_t *src, int stride);
void ff_pred8x8l_top_dc_mmxext     (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_top_dc_ssse3      (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_dc_mmxext         (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_dc_ssse3          (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_horizontal_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_horizontal_ssse3  (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_vertical_mmxext   (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_vertical_ssse3    (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_down_left_mmxext  (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_down_left_sse2    (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_down_left_ssse3   (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_down_right_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_down_right_sse2   (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_down_right_ssse3  (uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_vertical_right_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_vertical_right_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_vertical_right_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_vertical_left_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_vertical_left_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_horizontal_up_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_horizontal_up_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_horizontal_down_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_horizontal_down_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred8x8l_horizontal_down_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred4x4_dc_mmxext          (uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_down_left_mmxext   (uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_down_right_mmxext  (uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_vertical_left_mmxext(uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_vertical_right_mmxext(uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_horizontal_up_mmxext(uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_horizontal_down_mmxext(uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_tm_vp8_mmx         (uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_tm_vp8_mmxext      (uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_tm_vp8_ssse3       (uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride);

void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
{
    int mm_flags = av_get_cpu_flags();

#if HAVE_YASM
    if (mm_flags & AV_CPU_FLAG_MMX) {
        h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx;
        h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx;
        h->pred8x8  [VERT_PRED8x8] = ff_pred8x8_vertical_mmx;
        h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx;
        if (codec_id == CODEC_ID_VP8) {
            h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx;
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx;
            h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_mmx;
        } else {
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_mmx;
            if (codec_id == CODEC_ID_SVQ3) {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx;
            } else if (codec_id == CODEC_ID_RV40) {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx;
            } else {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx;
            }
        }
    }

    if (mm_flags & AV_CPU_FLAG_MMX2) {
        h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
        h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_mmxext;
        h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext;
#if CONFIG_GPL
        h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext;
        h->pred8x8l [DC_PRED     ] = ff_pred8x8l_dc_mmxext;
        h->pred8x8l [HOR_PRED    ] = ff_pred8x8l_horizontal_mmxext;
        h->pred8x8l [VERT_PRED   ] = ff_pred8x8l_vertical_mmxext;
        h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_mmxext;
        h->pred8x8l [VERT_RIGHT_PRED     ] = ff_pred8x8l_vertical_right_mmxext;
        h->pred8x8l [HOR_UP_PRED         ] = ff_pred8x8l_horizontal_up_mmxext;
        h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext;
        h->pred8x8l [HOR_DOWN_PRED       ] = ff_pred8x8l_horizontal_down_mmxext;
        h->pred4x4  [DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_mmxext;
        h->pred4x4  [VERT_RIGHT_PRED     ] = ff_pred4x4_vertical_right_mmxext;
        h->pred4x4  [HOR_DOWN_PRED       ] = ff_pred4x4_horizontal_down_mmxext;
#endif
        h->pred4x4  [DC_PRED     ] = ff_pred4x4_dc_mmxext;
#if CONFIG_GPL
        if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264)
            h->pred4x4  [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext;
        if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264)
            h->pred4x4  [VERT_LEFT_PRED      ] = ff_pred4x4_vertical_left_mmxext;
        if (codec_id != CODEC_ID_RV40) {
            h->pred4x4  [HOR_UP_PRED         ] = ff_pred4x4_horizontal_up_mmxext;
        }
        if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) {
            h->pred8x8  [TOP_DC_PRED8x8      ] = ff_pred8x8_top_dc_mmxext;
            h->pred8x8  [DC_PRED8x8          ] = ff_pred8x8_dc_mmxext;
        }
#endif
        if (codec_id == CODEC_ID_VP8) {
            h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext;
            h->pred8x8  [DC_PRED8x8   ] = ff_pred8x8_dc_rv40_mmxext;
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext;
            h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_mmxext;
            h->pred4x4  [VERT_PRED    ] = ff_pred4x4_vertical_vp8_mmxext;
        } else {
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2;
            if (codec_id == CODEC_ID_SVQ3) {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx2;
            } else if (codec_id == CODEC_ID_RV40) {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx2;
            } else {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx2;
            }
        }
    }

    if (mm_flags & AV_CPU_FLAG_SSE) {
        h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse;
    }

    if (mm_flags & AV_CPU_FLAG_SSE2) {
        h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_sse2;
#if CONFIG_GPL
        h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2;
        h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2;
        h->pred8x8l [VERT_RIGHT_PRED     ] = ff_pred8x8l_vertical_right_sse2;
        h->pred8x8l [VERT_LEFT_PRED      ] = ff_pred8x8l_vertical_left_sse2;
        h->pred8x8l [HOR_DOWN_PRED       ] = ff_pred8x8l_horizontal_down_sse2;
#endif
        if (codec_id == CODEC_ID_VP8) {
            h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2;
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2;
        } else {
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_sse2;
            if (codec_id == CODEC_ID_SVQ3) {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2;
            } else if (codec_id == CODEC_ID_RV40) {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2;
            } else {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2;
            }
        }
    }

    if (mm_flags & AV_CPU_FLAG_SSSE3) {
        h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
        h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_ssse3;
        h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3;
#if CONFIG_GPL
        h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3;
        h->pred8x8l [DC_PRED     ] = ff_pred8x8l_dc_ssse3;
        h->pred8x8l [HOR_PRED    ] = ff_pred8x8l_horizontal_ssse3;
        h->pred8x8l [VERT_PRED   ] = ff_pred8x8l_vertical_ssse3;
        h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3;
        h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_ssse3;
        h->pred8x8l [VERT_RIGHT_PRED     ] = ff_pred8x8l_vertical_right_ssse3;
        h->pred8x8l [VERT_LEFT_PRED      ] = ff_pred8x8l_vertical_left_ssse3;
        h->pred8x8l [HOR_UP_PRED         ] = ff_pred8x8l_horizontal_up_ssse3;
        h->pred8x8l [HOR_DOWN_PRED       ] = ff_pred8x8l_horizontal_down_ssse3;
#endif
        if (codec_id == CODEC_ID_VP8) {
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3;
            h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_ssse3;
        } else {
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3;
            if (codec_id == CODEC_ID_SVQ3) {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3;
            } else if (codec_id == CODEC_ID_RV40) {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3;
            } else {
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3;
            }
        }
    }
#endif
}