You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
7.4KB

  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. #include "libavutil/cpu.h"
  21. #include "libavcodec/h264pred.h"
  22. void ff_pred16x16_vertical_mmx (uint8_t *src, int stride);
  23. void ff_pred16x16_vertical_sse (uint8_t *src, int stride);
  24. void ff_pred16x16_horizontal_mmx (uint8_t *src, int stride);
  25. void ff_pred16x16_horizontal_mmxext(uint8_t *src, int stride);
  26. void ff_pred16x16_horizontal_ssse3 (uint8_t *src, int stride);
  27. void ff_pred16x16_dc_mmxext (uint8_t *src, int stride);
  28. void ff_pred16x16_dc_sse2 (uint8_t *src, int stride);
  29. void ff_pred16x16_dc_ssse3 (uint8_t *src, int stride);
  30. void ff_pred16x16_plane_h264_mmx (uint8_t *src, int stride);
  31. void ff_pred16x16_plane_h264_mmx2 (uint8_t *src, int stride);
  32. void ff_pred16x16_plane_h264_sse2 (uint8_t *src, int stride);
  33. void ff_pred16x16_plane_h264_ssse3 (uint8_t *src, int stride);
  34. void ff_pred16x16_plane_rv40_mmx (uint8_t *src, int stride);
  35. void ff_pred16x16_plane_rv40_mmx2 (uint8_t *src, int stride);
  36. void ff_pred16x16_plane_rv40_sse2 (uint8_t *src, int stride);
  37. void ff_pred16x16_plane_rv40_ssse3 (uint8_t *src, int stride);
  38. void ff_pred16x16_plane_svq3_mmx (uint8_t *src, int stride);
  39. void ff_pred16x16_plane_svq3_mmx2 (uint8_t *src, int stride);
  40. void ff_pred16x16_plane_svq3_sse2 (uint8_t *src, int stride);
  41. void ff_pred16x16_plane_svq3_ssse3 (uint8_t *src, int stride);
  42. void ff_pred16x16_tm_vp8_mmx (uint8_t *src, int stride);
  43. void ff_pred16x16_tm_vp8_mmxext (uint8_t *src, int stride);
  44. void ff_pred16x16_tm_vp8_sse2 (uint8_t *src, int stride);
  45. void ff_pred8x8_dc_rv40_mmxext (uint8_t *src, int stride);
  46. void ff_pred8x8_vertical_mmx (uint8_t *src, int stride);
  47. void ff_pred8x8_horizontal_mmx (uint8_t *src, int stride);
  48. void ff_pred8x8_horizontal_mmxext (uint8_t *src, int stride);
  49. void ff_pred8x8_horizontal_ssse3 (uint8_t *src, int stride);
  50. void ff_pred8x8_plane_mmx (uint8_t *src, int stride);
  51. void ff_pred8x8_plane_mmx2 (uint8_t *src, int stride);
  52. void ff_pred8x8_plane_sse2 (uint8_t *src, int stride);
  53. void ff_pred8x8_plane_ssse3 (uint8_t *src, int stride);
  54. void ff_pred8x8_tm_vp8_mmx (uint8_t *src, int stride);
  55. void ff_pred8x8_tm_vp8_mmxext (uint8_t *src, int stride);
  56. void ff_pred8x8_tm_vp8_sse2 (uint8_t *src, int stride);
  57. void ff_pred8x8_tm_vp8_ssse3 (uint8_t *src, int stride);
  58. void ff_pred4x4_dc_mmxext (uint8_t *src, const uint8_t *topright, int stride);
  59. void ff_pred4x4_tm_vp8_mmx (uint8_t *src, const uint8_t *topright, int stride);
  60. void ff_pred4x4_tm_vp8_mmxext (uint8_t *src, const uint8_t *topright, int stride);
  61. void ff_pred4x4_tm_vp8_ssse3 (uint8_t *src, const uint8_t *topright, int stride);
  62. void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride);
  63. void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
  64. {
  65. int mm_flags = av_get_cpu_flags();
  66. #if HAVE_YASM
  67. if (mm_flags & AV_CPU_FLAG_MMX) {
  68. h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx;
  69. h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx;
  70. h->pred8x8 [VERT_PRED8x8] = ff_pred8x8_vertical_mmx;
  71. h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx;
  72. if (codec_id == CODEC_ID_VP8) {
  73. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx;
  74. h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx;
  75. h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx;
  76. } else {
  77. h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx;
  78. if (codec_id == CODEC_ID_SVQ3) {
  79. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx;
  80. } else if (codec_id == CODEC_ID_RV40) {
  81. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx;
  82. } else {
  83. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx;
  84. }
  85. }
  86. }
  87. if (mm_flags & AV_CPU_FLAG_MMX2) {
  88. h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
  89. h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext;
  90. h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext;
  91. h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext;
  92. if (codec_id == CODEC_ID_VP8) {
  93. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext;
  94. h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext;
  95. h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext;
  96. h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext;
  97. h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext;
  98. } else {
  99. h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2;
  100. if (codec_id == CODEC_ID_SVQ3) {
  101. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx2;
  102. } else if (codec_id == CODEC_ID_RV40) {
  103. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx2;
  104. } else {
  105. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx2;
  106. }
  107. }
  108. }
  109. if (mm_flags & AV_CPU_FLAG_SSE) {
  110. h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse;
  111. }
  112. if (mm_flags & AV_CPU_FLAG_SSE2) {
  113. h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2;
  114. if (codec_id == CODEC_ID_VP8) {
  115. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2;
  116. h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2;
  117. } else {
  118. h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_sse2;
  119. if (codec_id == CODEC_ID_SVQ3) {
  120. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2;
  121. } else if (codec_id == CODEC_ID_RV40) {
  122. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2;
  123. } else {
  124. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2;
  125. }
  126. }
  127. }
  128. if (mm_flags & AV_CPU_FLAG_SSSE3) {
  129. h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
  130. h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3;
  131. h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3;
  132. if (codec_id == CODEC_ID_VP8) {
  133. h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3;
  134. h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3;
  135. } else {
  136. h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3;
  137. if (codec_id == CODEC_ID_SVQ3) {
  138. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3;
  139. } else if (codec_id == CODEC_ID_RV40) {
  140. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3;
  141. } else {
  142. h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3;
  143. }
  144. }
  145. }
  146. #endif
  147. }