00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "libavutil/cpu.h"
00022 #include "libavcodec/h264pred.h"
00023
00024 void ff_pred16x16_vertical_mmx (uint8_t *src, int stride);
00025 void ff_pred16x16_vertical_sse (uint8_t *src, int stride);
00026 void ff_pred16x16_horizontal_mmx (uint8_t *src, int stride);
00027 void ff_pred16x16_horizontal_mmxext(uint8_t *src, int stride);
00028 void ff_pred16x16_horizontal_ssse3 (uint8_t *src, int stride);
00029 void ff_pred16x16_dc_mmxext (uint8_t *src, int stride);
00030 void ff_pred16x16_dc_sse2 (uint8_t *src, int stride);
00031 void ff_pred16x16_dc_ssse3 (uint8_t *src, int stride);
00032 void ff_pred16x16_plane_h264_mmx (uint8_t *src, int stride);
00033 void ff_pred16x16_plane_h264_mmx2 (uint8_t *src, int stride);
00034 void ff_pred16x16_plane_h264_sse2 (uint8_t *src, int stride);
00035 void ff_pred16x16_plane_h264_ssse3 (uint8_t *src, int stride);
00036 void ff_pred16x16_plane_rv40_mmx (uint8_t *src, int stride);
00037 void ff_pred16x16_plane_rv40_mmx2 (uint8_t *src, int stride);
00038 void ff_pred16x16_plane_rv40_sse2 (uint8_t *src, int stride);
00039 void ff_pred16x16_plane_rv40_ssse3 (uint8_t *src, int stride);
00040 void ff_pred16x16_plane_svq3_mmx (uint8_t *src, int stride);
00041 void ff_pred16x16_plane_svq3_mmx2 (uint8_t *src, int stride);
00042 void ff_pred16x16_plane_svq3_sse2 (uint8_t *src, int stride);
00043 void ff_pred16x16_plane_svq3_ssse3 (uint8_t *src, int stride);
00044 void ff_pred16x16_tm_vp8_mmx (uint8_t *src, int stride);
00045 void ff_pred16x16_tm_vp8_mmxext (uint8_t *src, int stride);
00046 void ff_pred16x16_tm_vp8_sse2 (uint8_t *src, int stride);
00047 void ff_pred8x8_top_dc_mmxext (uint8_t *src, int stride);
00048 void ff_pred8x8_dc_rv40_mmxext (uint8_t *src, int stride);
00049 void ff_pred8x8_dc_mmxext (uint8_t *src, int stride);
00050 void ff_pred8x8_vertical_mmx (uint8_t *src, int stride);
00051 void ff_pred8x8_horizontal_mmx (uint8_t *src, int stride);
00052 void ff_pred8x8_horizontal_mmxext (uint8_t *src, int stride);
00053 void ff_pred8x8_horizontal_ssse3 (uint8_t *src, int stride);
00054 void ff_pred8x8_plane_mmx (uint8_t *src, int stride);
00055 void ff_pred8x8_plane_mmx2 (uint8_t *src, int stride);
00056 void ff_pred8x8_plane_sse2 (uint8_t *src, int stride);
00057 void ff_pred8x8_plane_ssse3 (uint8_t *src, int stride);
00058 void ff_pred8x8_tm_vp8_mmx (uint8_t *src, int stride);
00059 void ff_pred8x8_tm_vp8_mmxext (uint8_t *src, int stride);
00060 void ff_pred8x8_tm_vp8_sse2 (uint8_t *src, int stride);
00061 void ff_pred8x8_tm_vp8_ssse3 (uint8_t *src, int stride);
00062 void ff_pred8x8l_top_dc_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
00063 void ff_pred8x8l_top_dc_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
00064 void ff_pred8x8l_dc_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
00065 void ff_pred8x8l_dc_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
00066 void ff_pred8x8l_horizontal_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
00067 void ff_pred8x8l_horizontal_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
00068 void ff_pred8x8l_vertical_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
00069 void ff_pred8x8l_vertical_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
00070 void ff_pred8x8l_down_left_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
00071 void ff_pred8x8l_down_left_sse2 (uint8_t *src, int has_topleft, int has_topright, int stride);
00072 void ff_pred8x8l_down_left_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
00073 void ff_pred8x8l_down_right_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
00074 void ff_pred8x8l_down_right_sse2 (uint8_t *src, int has_topleft, int has_topright, int stride);
00075 void ff_pred8x8l_down_right_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
00076 void ff_pred8x8l_vertical_right_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
00077 void ff_pred8x8l_vertical_right_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
00078 void ff_pred8x8l_vertical_right_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
00079 void ff_pred8x8l_vertical_left_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
00080 void ff_pred8x8l_vertical_left_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
00081 void ff_pred8x8l_horizontal_up_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
00082 void ff_pred8x8l_horizontal_up_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
00083 void ff_pred8x8l_horizontal_down_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
00084 void ff_pred8x8l_horizontal_down_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
00085 void ff_pred8x8l_horizontal_down_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
00086 void ff_pred4x4_dc_mmxext (uint8_t *src, const uint8_t *topright, int stride);
00087 void ff_pred4x4_down_left_mmxext (uint8_t *src, const uint8_t *topright, int stride);
00088 void ff_pred4x4_down_right_mmxext (uint8_t *src, const uint8_t *topright, int stride);
00089 void ff_pred4x4_vertical_left_mmxext(uint8_t *src, const uint8_t *topright, int stride);
00090 void ff_pred4x4_vertical_right_mmxext(uint8_t *src, const uint8_t *topright, int stride);
00091 void ff_pred4x4_horizontal_up_mmxext(uint8_t *src, const uint8_t *topright, int stride);
00092 void ff_pred4x4_horizontal_down_mmxext(uint8_t *src, const uint8_t *topright, int stride);
00093 void ff_pred4x4_tm_vp8_mmx (uint8_t *src, const uint8_t *topright, int stride);
00094 void ff_pred4x4_tm_vp8_mmxext (uint8_t *src, const uint8_t *topright, int stride);
00095 void ff_pred4x4_tm_vp8_ssse3 (uint8_t *src, const uint8_t *topright, int stride);
00096 void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride);
00097
00098 void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
00099 {
00100 int mm_flags = av_get_cpu_flags();
00101
00102 #if HAVE_YASM
00103 if (mm_flags & AV_CPU_FLAG_MMX) {
00104 h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx;
00105 h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx;
00106 h->pred8x8 [VERT_PRED8x8] = ff_pred8x8_vertical_mmx;
00107 h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx;
00108 if (codec_id == CODEC_ID_VP8) {
00109 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx;
00110 h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx;
00111 h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx;
00112 } else {
00113 h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx;
00114 if (codec_id == CODEC_ID_SVQ3) {
00115 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx;
00116 } else if (codec_id == CODEC_ID_RV40) {
00117 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx;
00118 } else {
00119 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx;
00120 }
00121 }
00122 }
00123
00124 if (mm_flags & AV_CPU_FLAG_MMX2) {
00125 h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
00126 h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext;
00127 h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext;
00128 #if CONFIG_GPL
00129 h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext;
00130 h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext;
00131 h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext;
00132 h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext;
00133 h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_mmxext;
00134 h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext;
00135 h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext;
00136 h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext;
00137 h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext;
00138 h->pred4x4 [DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_mmxext;
00139 h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext;
00140 h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext;
00141 #endif
00142 h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext;
00143 #if CONFIG_GPL
00144 if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264)
00145 h->pred4x4 [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext;
00146 if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264)
00147 h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext;
00148 if (codec_id != CODEC_ID_RV40) {
00149 h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext;
00150 }
00151 if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) {
00152 h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext;
00153 h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext;
00154 }
00155 #endif
00156 if (codec_id == CODEC_ID_VP8) {
00157 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext;
00158 h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext;
00159 h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext;
00160 h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext;
00161 h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext;
00162 } else {
00163 h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2;
00164 if (codec_id == CODEC_ID_SVQ3) {
00165 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx2;
00166 } else if (codec_id == CODEC_ID_RV40) {
00167 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx2;
00168 } else {
00169 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx2;
00170 }
00171 }
00172 }
00173
00174 if (mm_flags & AV_CPU_FLAG_SSE) {
00175 h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse;
00176 }
00177
00178 if (mm_flags & AV_CPU_FLAG_SSE2) {
00179 h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2;
00180 #if CONFIG_GPL
00181 h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2;
00182 h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2;
00183 h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2;
00184 h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2;
00185 h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2;
00186 #endif
00187 if (codec_id == CODEC_ID_VP8) {
00188 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2;
00189 h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2;
00190 } else {
00191 h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_sse2;
00192 if (codec_id == CODEC_ID_SVQ3) {
00193 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2;
00194 } else if (codec_id == CODEC_ID_RV40) {
00195 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2;
00196 } else {
00197 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2;
00198 }
00199 }
00200 }
00201
00202 if (mm_flags & AV_CPU_FLAG_SSSE3) {
00203 h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
00204 h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3;
00205 h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3;
00206 #if CONFIG_GPL
00207 h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3;
00208 h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3;
00209 h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3;
00210 h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3;
00211 h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3;
00212 h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_ssse3;
00213 h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3;
00214 h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3;
00215 h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3;
00216 h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3;
00217 #endif
00218 if (codec_id == CODEC_ID_VP8) {
00219 h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3;
00220 h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3;
00221 } else {
00222 h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3;
00223 if (codec_id == CODEC_ID_SVQ3) {
00224 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3;
00225 } else if (codec_id == CODEC_ID_RV40) {
00226 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3;
00227 } else {
00228 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3;
00229 }
00230 }
00231 }
00232 #endif
00233 }