Statistics
| Branch: | Revision:

ffmpeg / libavcodec / x86 / h264_intrapred_init.c @ 2912e87a

History | View | Annotate | Download (13 KB)

1
/*
2
 * Copyright (c) 2010 Jason Garrett-Glaser
3
 *
4
 * This file is part of Libav.
5
 *
6
 * Libav 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
 * Libav 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 Libav; 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_plane_h264_mmx   (uint8_t *src, int stride);
33
void ff_pred16x16_plane_h264_mmx2  (uint8_t *src, int stride);
34
void ff_pred16x16_plane_h264_sse2  (uint8_t *src, int stride);
35
void ff_pred16x16_plane_h264_ssse3 (uint8_t *src, int stride);
36
void ff_pred16x16_plane_rv40_mmx   (uint8_t *src, int stride);
37
void ff_pred16x16_plane_rv40_mmx2  (uint8_t *src, int stride);
38
void ff_pred16x16_plane_rv40_sse2  (uint8_t *src, int stride);
39
void ff_pred16x16_plane_rv40_ssse3 (uint8_t *src, int stride);
40
void ff_pred16x16_plane_svq3_mmx   (uint8_t *src, int stride);
41
void ff_pred16x16_plane_svq3_mmx2  (uint8_t *src, int stride);
42
void ff_pred16x16_plane_svq3_sse2  (uint8_t *src, int stride);
43
void ff_pred16x16_plane_svq3_ssse3 (uint8_t *src, int stride);
44
void ff_pred16x16_tm_vp8_mmx       (uint8_t *src, int stride);
45
void ff_pred16x16_tm_vp8_mmxext    (uint8_t *src, int stride);
46
void ff_pred16x16_tm_vp8_sse2      (uint8_t *src, int stride);
47
void ff_pred8x8_top_dc_mmxext      (uint8_t *src, int stride);
48
void ff_pred8x8_dc_rv40_mmxext     (uint8_t *src, int stride);
49
void ff_pred8x8_dc_mmxext          (uint8_t *src, int stride);
50
void ff_pred8x8_vertical_mmx       (uint8_t *src, int stride);
51
void ff_pred8x8_horizontal_mmx     (uint8_t *src, int stride);
52
void ff_pred8x8_horizontal_mmxext  (uint8_t *src, int stride);
53
void ff_pred8x8_horizontal_ssse3   (uint8_t *src, int stride);
54
void ff_pred8x8_plane_mmx          (uint8_t *src, int stride);
55
void ff_pred8x8_plane_mmx2         (uint8_t *src, int stride);
56
void ff_pred8x8_plane_sse2         (uint8_t *src, int stride);
57
void ff_pred8x8_plane_ssse3        (uint8_t *src, int stride);
58
void ff_pred8x8_tm_vp8_mmx         (uint8_t *src, int stride);
59
void ff_pred8x8_tm_vp8_mmxext      (uint8_t *src, int stride);
60
void ff_pred8x8_tm_vp8_sse2        (uint8_t *src, int stride);
61
void ff_pred8x8_tm_vp8_ssse3       (uint8_t *src, int stride);
62
void ff_pred8x8l_top_dc_mmxext     (uint8_t *src, int has_topleft, int has_topright, int stride);
63
void ff_pred8x8l_top_dc_ssse3      (uint8_t *src, int has_topleft, int has_topright, int stride);
64
void ff_pred8x8l_dc_mmxext         (uint8_t *src, int has_topleft, int has_topright, int stride);
65
void ff_pred8x8l_dc_ssse3          (uint8_t *src, int has_topleft, int has_topright, int stride);
66
void ff_pred8x8l_horizontal_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
67
void ff_pred8x8l_horizontal_ssse3  (uint8_t *src, int has_topleft, int has_topright, int stride);
68
void ff_pred8x8l_vertical_mmxext   (uint8_t *src, int has_topleft, int has_topright, int stride);
69
void ff_pred8x8l_vertical_ssse3    (uint8_t *src, int has_topleft, int has_topright, int stride);
70
void ff_pred8x8l_down_left_mmxext  (uint8_t *src, int has_topleft, int has_topright, int stride);
71
void ff_pred8x8l_down_left_sse2    (uint8_t *src, int has_topleft, int has_topright, int stride);
72
void ff_pred8x8l_down_left_ssse3   (uint8_t *src, int has_topleft, int has_topright, int stride);
73
void ff_pred8x8l_down_right_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
74
void ff_pred8x8l_down_right_sse2   (uint8_t *src, int has_topleft, int has_topright, int stride);
75
void ff_pred8x8l_down_right_ssse3  (uint8_t *src, int has_topleft, int has_topright, int stride);
76
void ff_pred8x8l_vertical_right_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
77
void ff_pred8x8l_vertical_right_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
78
void ff_pred8x8l_vertical_right_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
79
void ff_pred8x8l_vertical_left_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
80
void ff_pred8x8l_vertical_left_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
81
void ff_pred8x8l_horizontal_up_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
82
void ff_pred8x8l_horizontal_up_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
83
void ff_pred8x8l_horizontal_down_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
84
void ff_pred8x8l_horizontal_down_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
85
void ff_pred8x8l_horizontal_down_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
86
void ff_pred4x4_dc_mmxext          (uint8_t *src, const uint8_t *topright, int stride);
87
void ff_pred4x4_down_left_mmxext   (uint8_t *src, const uint8_t *topright, int stride);
88
void ff_pred4x4_down_right_mmxext  (uint8_t *src, const uint8_t *topright, int stride);
89
void ff_pred4x4_vertical_left_mmxext(uint8_t *src, const uint8_t *topright, int stride);
90
void ff_pred4x4_vertical_right_mmxext(uint8_t *src, const uint8_t *topright, int stride);
91
void ff_pred4x4_horizontal_up_mmxext(uint8_t *src, const uint8_t *topright, int stride);
92
void ff_pred4x4_horizontal_down_mmxext(uint8_t *src, const uint8_t *topright, int stride);
93
void ff_pred4x4_tm_vp8_mmx         (uint8_t *src, const uint8_t *topright, int stride);
94
void ff_pred4x4_tm_vp8_mmxext      (uint8_t *src, const uint8_t *topright, int stride);
95
void ff_pred4x4_tm_vp8_ssse3       (uint8_t *src, const uint8_t *topright, int stride);
96
void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride);
97

    
98
void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
99
{
100
    int mm_flags = av_get_cpu_flags();
101

    
102
#if HAVE_YASM
103
    if (mm_flags & AV_CPU_FLAG_MMX) {
104
        h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx;
105
        h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx;
106
        h->pred8x8  [VERT_PRED8x8] = ff_pred8x8_vertical_mmx;
107
        h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx;
108
        if (codec_id == CODEC_ID_VP8) {
109
            h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx;
110
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx;
111
            h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_mmx;
112
        } else {
113
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_mmx;
114
            if (codec_id == CODEC_ID_SVQ3) {
115
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx;
116
            } else if (codec_id == CODEC_ID_RV40) {
117
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx;
118
            } else {
119
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx;
120
            }
121
        }
122
    }
123

    
124
    if (mm_flags & AV_CPU_FLAG_MMX2) {
125
        h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
126
        h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_mmxext;
127
        h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext;
128
#if CONFIG_GPL
129
        h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext;
130
        h->pred8x8l [DC_PRED     ] = ff_pred8x8l_dc_mmxext;
131
        h->pred8x8l [HOR_PRED    ] = ff_pred8x8l_horizontal_mmxext;
132
        h->pred8x8l [VERT_PRED   ] = ff_pred8x8l_vertical_mmxext;
133
        h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_mmxext;
134
        h->pred8x8l [VERT_RIGHT_PRED     ] = ff_pred8x8l_vertical_right_mmxext;
135
        h->pred8x8l [HOR_UP_PRED         ] = ff_pred8x8l_horizontal_up_mmxext;
136
        h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext;
137
        h->pred8x8l [HOR_DOWN_PRED       ] = ff_pred8x8l_horizontal_down_mmxext;
138
        h->pred4x4  [DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_mmxext;
139
        h->pred4x4  [VERT_RIGHT_PRED     ] = ff_pred4x4_vertical_right_mmxext;
140
        h->pred4x4  [HOR_DOWN_PRED       ] = ff_pred4x4_horizontal_down_mmxext;
141
#endif
142
        h->pred4x4  [DC_PRED     ] = ff_pred4x4_dc_mmxext;
143
#if CONFIG_GPL
144
        if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264)
145
            h->pred4x4  [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext;
146
        if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264)
147
            h->pred4x4  [VERT_LEFT_PRED      ] = ff_pred4x4_vertical_left_mmxext;
148
        if (codec_id != CODEC_ID_RV40) {
149
            h->pred4x4  [HOR_UP_PRED         ] = ff_pred4x4_horizontal_up_mmxext;
150
        }
151
        if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) {
152
            h->pred8x8  [TOP_DC_PRED8x8      ] = ff_pred8x8_top_dc_mmxext;
153
            h->pred8x8  [DC_PRED8x8          ] = ff_pred8x8_dc_mmxext;
154
        }
155
#endif
156
        if (codec_id == CODEC_ID_VP8) {
157
            h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext;
158
            h->pred8x8  [DC_PRED8x8   ] = ff_pred8x8_dc_rv40_mmxext;
159
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext;
160
            h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_mmxext;
161
            h->pred4x4  [VERT_PRED    ] = ff_pred4x4_vertical_vp8_mmxext;
162
        } else {
163
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2;
164
            if (codec_id == CODEC_ID_SVQ3) {
165
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx2;
166
            } else if (codec_id == CODEC_ID_RV40) {
167
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx2;
168
            } else {
169
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx2;
170
            }
171
        }
172
    }
173

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

    
178
    if (mm_flags & AV_CPU_FLAG_SSE2) {
179
        h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_sse2;
180
#if CONFIG_GPL
181
        h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2;
182
        h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2;
183
        h->pred8x8l [VERT_RIGHT_PRED     ] = ff_pred8x8l_vertical_right_sse2;
184
        h->pred8x8l [VERT_LEFT_PRED      ] = ff_pred8x8l_vertical_left_sse2;
185
        h->pred8x8l [HOR_DOWN_PRED       ] = ff_pred8x8l_horizontal_down_sse2;
186
#endif
187
        if (codec_id == CODEC_ID_VP8) {
188
            h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2;
189
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2;
190
        } else {
191
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_sse2;
192
            if (codec_id == CODEC_ID_SVQ3) {
193
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2;
194
            } else if (codec_id == CODEC_ID_RV40) {
195
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2;
196
            } else {
197
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2;
198
            }
199
        }
200
    }
201

    
202
    if (mm_flags & AV_CPU_FLAG_SSSE3) {
203
        h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
204
        h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_ssse3;
205
        h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3;
206
#if CONFIG_GPL
207
        h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3;
208
        h->pred8x8l [DC_PRED     ] = ff_pred8x8l_dc_ssse3;
209
        h->pred8x8l [HOR_PRED    ] = ff_pred8x8l_horizontal_ssse3;
210
        h->pred8x8l [VERT_PRED   ] = ff_pred8x8l_vertical_ssse3;
211
        h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3;
212
        h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_ssse3;
213
        h->pred8x8l [VERT_RIGHT_PRED     ] = ff_pred8x8l_vertical_right_ssse3;
214
        h->pred8x8l [VERT_LEFT_PRED      ] = ff_pred8x8l_vertical_left_ssse3;
215
        h->pred8x8l [HOR_UP_PRED         ] = ff_pred8x8l_horizontal_up_ssse3;
216
        h->pred8x8l [HOR_DOWN_PRED       ] = ff_pred8x8l_horizontal_down_ssse3;
217
#endif
218
        if (codec_id == CODEC_ID_VP8) {
219
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3;
220
            h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_ssse3;
221
        } else {
222
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3;
223
            if (codec_id == CODEC_ID_SVQ3) {
224
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3;
225
            } else if (codec_id == CODEC_ID_RV40) {
226
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3;
227
            } else {
228
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3;
229
            }
230
        }
231
    }
232
#endif
233
}