Statistics
| Branch: | Revision:

ffmpeg / libavcodec / x86 / h264_intrapred_init.c @ 92f441ae

History | View | Annotate | Download (12.1 KB)

1 de1c253b Ronald S. Bultje
/*
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 c6c98d08 Stefano Sabatini
#include "libavutil/cpu.h"
22 de1c253b Ronald S. Bultje
#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 dd68d4db Ronald S. Bultje
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 de1c253b Ronald S. Bultje
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 725a3f9d Daniel Kang
void ff_pred8x8_top_dc_mmxext      (uint8_t *src, int stride);
48 de1c253b Ronald S. Bultje
void ff_pred8x8_dc_rv40_mmxext     (uint8_t *src, int stride);
49 a2dfe8d1 Ronald S. Bultje
void ff_pred8x8_dc_mmxext          (uint8_t *src, int stride);
50 de1c253b Ronald S. Bultje
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 dd68d4db Ronald S. Bultje
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 de1c253b Ronald S. Bultje
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 2e93fd4b Daniel Kang
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 abab14ea Daniel Kang
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 04207ef3 Daniel Kang
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 ee1ba9c3 Daniel Kang
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 c249e665 Daniel Kang
void ff_pred8x8l_down_left_sse2    (uint8_t *src, int has_topleft, int has_topright, int stride);
71
void ff_pred8x8l_down_left_ssse3   (uint8_t *src, int has_topleft, int has_topright, int stride);
72 e916acbc Daniel Kang
void ff_pred8x8l_down_right_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
73 602a4cb2 Daniel Kang
void ff_pred8x8l_down_right_sse2   (uint8_t *src, int has_topleft, int has_topright, int stride);
74
void ff_pred8x8l_down_right_ssse3  (uint8_t *src, int has_topleft, int has_topright, int stride);
75 f25112fc Daniel Kang
void ff_pred8x8l_vertical_right_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
76 bdd93f1b Daniel Kang
void ff_pred8x8l_vertical_right_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
77
void ff_pred8x8l_vertical_right_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
78 ecc7efbb Daniel Kang
void ff_pred8x8l_vertical_left_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
79
void ff_pred8x8l_vertical_left_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
80 98c6053c Daniel Kang
void ff_pred8x8l_horizontal_up_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
81
void ff_pred8x8l_horizontal_up_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
82 04cbdf3d Daniel Kang
void ff_pred8x8l_horizontal_down_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
83 57b1f334 Daniel Kang
void ff_pred8x8l_horizontal_down_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
84
void ff_pred8x8l_horizontal_down_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
85 de1c253b Ronald S. Bultje
void ff_pred4x4_dc_mmxext          (uint8_t *src, const uint8_t *topright, int stride);
86 911b32f4 Daniel Kang
void ff_pred4x4_down_left_mmxext   (uint8_t *src, const uint8_t *topright, int stride);
87 92f441ae Daniel Kang
void ff_pred4x4_vertical_left_mmxext(uint8_t *src, const uint8_t *topright, int stride);
88 de1c253b Ronald S. Bultje
void ff_pred4x4_tm_vp8_mmx         (uint8_t *src, const uint8_t *topright, int stride);
89
void ff_pred4x4_tm_vp8_mmxext      (uint8_t *src, const uint8_t *topright, int stride);
90
void ff_pred4x4_tm_vp8_ssse3       (uint8_t *src, const uint8_t *topright, int stride);
91
void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride);
92
93
void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
94
{
95 c6c98d08 Stefano Sabatini
    int mm_flags = av_get_cpu_flags();
96 de1c253b Ronald S. Bultje
97
#if HAVE_YASM
98 7160bb71 Stefano Sabatini
    if (mm_flags & AV_CPU_FLAG_MMX) {
99 de1c253b Ronald S. Bultje
        h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx;
100
        h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx;
101
        h->pred8x8  [VERT_PRED8x8] = ff_pred8x8_vertical_mmx;
102
        h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx;
103
        if (codec_id == CODEC_ID_VP8) {
104
            h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx;
105
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx;
106
            h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_mmx;
107 dd68d4db Ronald S. Bultje
        } else {
108
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_mmx;
109
            if (codec_id == CODEC_ID_SVQ3) {
110
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx;
111
            } else if (codec_id == CODEC_ID_RV40) {
112
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx;
113
            } else {
114
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx;
115
            }
116 de1c253b Ronald S. Bultje
        }
117
    }
118
119 7160bb71 Stefano Sabatini
    if (mm_flags & AV_CPU_FLAG_MMX2) {
120 de1c253b Ronald S. Bultje
        h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
121
        h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_mmxext;
122
        h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext;
123 2e93fd4b Daniel Kang
#if CONFIG_GPL
124
        h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext;
125 abab14ea Daniel Kang
        h->pred8x8l [DC_PRED     ] = ff_pred8x8l_dc_mmxext;
126 04207ef3 Daniel Kang
        h->pred8x8l [HOR_PRED    ] = ff_pred8x8l_horizontal_mmxext;
127 ee1ba9c3 Daniel Kang
        h->pred8x8l [VERT_PRED   ] = ff_pred8x8l_vertical_mmxext;
128 e916acbc Daniel Kang
        h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_mmxext;
129 f25112fc Daniel Kang
        h->pred8x8l [VERT_RIGHT_PRED     ] = ff_pred8x8l_vertical_right_mmxext;
130 98c6053c Daniel Kang
        h->pred8x8l [HOR_UP_PRED         ] = ff_pred8x8l_horizontal_up_mmxext;
131 04cbdf3d Daniel Kang
        h->pred8x8l [HOR_DOWN_PRED       ] = ff_pred8x8l_horizontal_down_mmxext;
132 2e93fd4b Daniel Kang
#endif
133 de1c253b Ronald S. Bultje
        h->pred4x4  [DC_PRED     ] = ff_pred4x4_dc_mmxext;
134 98928c83 Ronald S. Bultje
#if CONFIG_GPL
135 911b32f4 Daniel Kang
        if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264)
136
            h->pred4x4  [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext;
137 92f441ae Daniel Kang
        if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264)
138
            h->pred4x4  [VERT_LEFT_PRED      ] = ff_pred4x4_vertical_left_mmxext;
139 725a3f9d Daniel Kang
        if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) {
140
            h->pred8x8  [TOP_DC_PRED8x8      ] = ff_pred8x8_top_dc_mmxext;
141 a2dfe8d1 Ronald S. Bultje
            h->pred8x8  [DC_PRED8x8          ] = ff_pred8x8_dc_mmxext;
142 725a3f9d Daniel Kang
        }
143 98928c83 Ronald S. Bultje
#endif
144 de1c253b Ronald S. Bultje
        if (codec_id == CODEC_ID_VP8) {
145
            h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext;
146
            h->pred8x8  [DC_PRED8x8   ] = ff_pred8x8_dc_rv40_mmxext;
147
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext;
148
            h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_mmxext;
149
            h->pred4x4  [VERT_PRED    ] = ff_pred4x4_vertical_vp8_mmxext;
150 dd68d4db Ronald S. Bultje
        } else {
151
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2;
152
            if (codec_id == CODEC_ID_SVQ3) {
153
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx2;
154
            } else if (codec_id == CODEC_ID_RV40) {
155
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx2;
156
            } else {
157
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx2;
158
            }
159 de1c253b Ronald S. Bultje
        }
160
    }
161
162 7160bb71 Stefano Sabatini
    if (mm_flags & AV_CPU_FLAG_SSE) {
163 de1c253b Ronald S. Bultje
        h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse;
164
    }
165
166 7160bb71 Stefano Sabatini
    if (mm_flags & AV_CPU_FLAG_SSE2) {
167 de1c253b Ronald S. Bultje
        h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_sse2;
168 c249e665 Daniel Kang
#if CONFIG_GPL
169 42a59278 Ronald S. Bultje
        h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2;
170 602a4cb2 Daniel Kang
        h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2;
171 bdd93f1b Daniel Kang
        h->pred8x8l [VERT_RIGHT_PRED     ] = ff_pred8x8l_vertical_right_sse2;
172 ecc7efbb Daniel Kang
        h->pred8x8l [VERT_LEFT_PRED      ] = ff_pred8x8l_vertical_left_sse2;
173 57b1f334 Daniel Kang
        h->pred8x8l [HOR_DOWN_PRED       ] = ff_pred8x8l_horizontal_down_sse2;
174 c249e665 Daniel Kang
#endif
175 de1c253b Ronald S. Bultje
        if (codec_id == CODEC_ID_VP8) {
176
            h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2;
177
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2;
178 dd68d4db Ronald S. Bultje
        } else {
179
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_sse2;
180
            if (codec_id == CODEC_ID_SVQ3) {
181
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2;
182
            } else if (codec_id == CODEC_ID_RV40) {
183
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2;
184
            } else {
185
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2;
186
            }
187 de1c253b Ronald S. Bultje
        }
188
    }
189
190 7160bb71 Stefano Sabatini
    if (mm_flags & AV_CPU_FLAG_SSSE3) {
191 de1c253b Ronald S. Bultje
        h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
192
        h->pred16x16[DC_PRED8x8  ] = ff_pred16x16_dc_ssse3;
193
        h->pred8x8  [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3;
194 2e93fd4b Daniel Kang
#if CONFIG_GPL
195
        h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3;
196 abab14ea Daniel Kang
        h->pred8x8l [DC_PRED     ] = ff_pred8x8l_dc_ssse3;
197 04207ef3 Daniel Kang
        h->pred8x8l [HOR_PRED    ] = ff_pred8x8l_horizontal_ssse3;
198 ee1ba9c3 Daniel Kang
        h->pred8x8l [VERT_PRED   ] = ff_pred8x8l_vertical_ssse3;
199 42a59278 Ronald S. Bultje
        h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3;
200 602a4cb2 Daniel Kang
        h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_ssse3;
201 bdd93f1b Daniel Kang
        h->pred8x8l [VERT_RIGHT_PRED     ] = ff_pred8x8l_vertical_right_ssse3;
202 ecc7efbb Daniel Kang
        h->pred8x8l [VERT_LEFT_PRED      ] = ff_pred8x8l_vertical_left_ssse3;
203 98c6053c Daniel Kang
        h->pred8x8l [HOR_UP_PRED         ] = ff_pred8x8l_horizontal_up_ssse3;
204 57b1f334 Daniel Kang
        h->pred8x8l [HOR_DOWN_PRED       ] = ff_pred8x8l_horizontal_down_ssse3;
205 2e93fd4b Daniel Kang
#endif
206 de1c253b Ronald S. Bultje
        if (codec_id == CODEC_ID_VP8) {
207
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3;
208
            h->pred4x4  [TM_VP8_PRED  ] = ff_pred4x4_tm_vp8_ssse3;
209 dd68d4db Ronald S. Bultje
        } else {
210
            h->pred8x8  [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3;
211
            if (codec_id == CODEC_ID_SVQ3) {
212
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3;
213
            } else if (codec_id == CODEC_ID_RV40) {
214
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3;
215
            } else {
216
                h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3;
217
            }
218 de1c253b Ronald S. Bultje
        }
219
    }
220
#endif
221
}