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
5.9KB

  1. /*
  2. * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com)
  3. * Zhou Xiaoyong <zhouxiaoyong@loongson.cn>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "config.h"
  22. #include "h264dsp_mips.h"
  23. #include "h264pred_mips.h"
  24. #if HAVE_MSA
  25. static av_cold void h264_pred_init_msa(H264PredContext *h, int codec_id,
  26. const int bit_depth,
  27. const int chroma_format_idc)
  28. {
  29. if (8 == bit_depth) {
  30. if (chroma_format_idc == 1) {
  31. h->pred8x8[VERT_PRED8x8] = ff_h264_intra_pred_vert_8x8_msa;
  32. h->pred8x8[HOR_PRED8x8] = ff_h264_intra_pred_horiz_8x8_msa;
  33. }
  34. if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) {
  35. if (chroma_format_idc == 1) {
  36. h->pred8x8[PLANE_PRED8x8] = ff_h264_intra_predict_plane_8x8_msa;
  37. }
  38. }
  39. if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7
  40. && codec_id != AV_CODEC_ID_VP8) {
  41. if (chroma_format_idc == 1) {
  42. h->pred8x8[DC_PRED8x8] = ff_h264_intra_predict_dc_4blk_8x8_msa;
  43. h->pred8x8[LEFT_DC_PRED8x8] =
  44. ff_h264_intra_predict_hor_dc_8x8_msa;
  45. h->pred8x8[TOP_DC_PRED8x8] =
  46. ff_h264_intra_predict_vert_dc_8x8_msa;
  47. h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] =
  48. ff_h264_intra_predict_mad_cow_dc_l0t_8x8_msa;
  49. h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] =
  50. ff_h264_intra_predict_mad_cow_dc_0lt_8x8_msa;
  51. h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] =
  52. ff_h264_intra_predict_mad_cow_dc_l00_8x8_msa;
  53. h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] =
  54. ff_h264_intra_predict_mad_cow_dc_0l0_8x8_msa;
  55. }
  56. } else {
  57. if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {
  58. h->pred8x8[7] = ff_vp8_pred8x8_127_dc_8_msa;
  59. h->pred8x8[8] = ff_vp8_pred8x8_129_dc_8_msa;
  60. }
  61. }
  62. if (chroma_format_idc == 1) {
  63. h->pred8x8[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_8x8_msa;
  64. }
  65. h->pred16x16[DC_PRED8x8] = ff_h264_intra_pred_dc_16x16_msa;
  66. h->pred16x16[VERT_PRED8x8] = ff_h264_intra_pred_vert_16x16_msa;
  67. h->pred16x16[HOR_PRED8x8] = ff_h264_intra_pred_horiz_16x16_msa;
  68. switch (codec_id) {
  69. case AV_CODEC_ID_SVQ3:
  70. ;
  71. break;
  72. case AV_CODEC_ID_RV40:
  73. ;
  74. break;
  75. case AV_CODEC_ID_VP7:
  76. case AV_CODEC_ID_VP8:
  77. h->pred16x16[7] = ff_vp8_pred16x16_127_dc_8_msa;
  78. h->pred16x16[8] = ff_vp8_pred16x16_129_dc_8_msa;
  79. break;
  80. default:
  81. h->pred16x16[PLANE_PRED8x8] =
  82. ff_h264_intra_predict_plane_16x16_msa;
  83. break;
  84. }
  85. h->pred16x16[LEFT_DC_PRED8x8] = ff_h264_intra_pred_dc_left_16x16_msa;
  86. h->pred16x16[TOP_DC_PRED8x8] = ff_h264_intra_pred_dc_top_16x16_msa;
  87. h->pred16x16[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_16x16_msa;
  88. }
  89. }
  90. #endif // #if HAVE_MSA
  91. #if HAVE_MMI
  92. static av_cold void h264_pred_init_mmi(H264PredContext *h, int codec_id,
  93. const int bit_depth, const int chroma_format_idc)
  94. {
  95. if (bit_depth == 8) {
  96. if (chroma_format_idc == 1) {
  97. h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_8_mmi;
  98. h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_mmi;
  99. } else {
  100. h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x16_vertical_8_mmi;
  101. h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x16_horizontal_8_mmi;
  102. }
  103. h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_mmi;
  104. h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_8_mmi;
  105. h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_mmi;
  106. h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_8_mmi;
  107. h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_8_mmi;
  108. #if ARCH_MIPS64
  109. switch (codec_id) {
  110. case AV_CODEC_ID_SVQ3:
  111. h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_8_mmi;
  112. break;
  113. case AV_CODEC_ID_RV40:
  114. h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_rv40_8_mmi;
  115. break;
  116. case AV_CODEC_ID_VP7:
  117. case AV_CODEC_ID_VP8:
  118. break;
  119. default:
  120. h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_h264_8_mmi;
  121. break;
  122. }
  123. #endif
  124. if (codec_id == AV_CODEC_ID_SVQ3 || codec_id == AV_CODEC_ID_H264) {
  125. if (chroma_format_idc == 1) {
  126. h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_8_mmi;
  127. h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_8_mmi;
  128. }
  129. }
  130. }
  131. }
  132. #endif /* HAVE_MMI */
  133. av_cold void ff_h264_pred_init_mips(H264PredContext *h, int codec_id,
  134. int bit_depth,
  135. const int chroma_format_idc)
  136. {
  137. #if HAVE_MSA
  138. h264_pred_init_msa(h, codec_id, bit_depth, chroma_format_idc);
  139. #endif // #if HAVE_MSA
  140. #if HAVE_MMI
  141. h264_pred_init_mmi(h, codec_id, bit_depth, chroma_format_idc);
  142. #endif /* HAVE_MMI */
  143. }