root/libavcodec/mips/qpeldsp_msa.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. horiz_mc_qpel_aver_src0_8width_msa
  2. horiz_mc_qpel_aver_src0_16width_msa
  3. horiz_mc_qpel_8width_msa
  4. horiz_mc_qpel_16width_msa
  5. horiz_mc_qpel_aver_src1_8width_msa
  6. horiz_mc_qpel_aver_src1_16width_msa
  7. horiz_mc_qpel_no_rnd_aver_src0_8width_msa
  8. horiz_mc_qpel_no_rnd_aver_src0_16width_msa
  9. horiz_mc_qpel_no_rnd_8width_msa
  10. horiz_mc_qpel_no_rnd_16width_msa
  11. horiz_mc_qpel_no_rnd_aver_src1_8width_msa
  12. horiz_mc_qpel_no_rnd_aver_src1_16width_msa
  13. horiz_mc_qpel_avg_dst_aver_src0_8width_msa
  14. horiz_mc_qpel_avg_dst_aver_src0_16width_msa
  15. horiz_mc_qpel_avg_dst_8width_msa
  16. horiz_mc_qpel_avg_dst_16width_msa
  17. horiz_mc_qpel_avg_dst_aver_src1_8width_msa
  18. horiz_mc_qpel_avg_dst_aver_src1_16width_msa
  19. vert_mc_qpel_aver_src0_8x8_msa
  20. vert_mc_qpel_aver_src0_16x16_msa
  21. vert_mc_qpel_8x8_msa
  22. vert_mc_qpel_16x16_msa
  23. vert_mc_qpel_aver_src1_8x8_msa
  24. vert_mc_qpel_aver_src1_16x16_msa
  25. vert_mc_qpel_no_rnd_aver_src0_8x8_msa
  26. vert_mc_qpel_no_rnd_aver_src0_16x16_msa
  27. vert_mc_qpel_no_rnd_8x8_msa
  28. vert_mc_qpel_no_rnd_16x16_msa
  29. vert_mc_qpel_no_rnd_aver_src1_8x8_msa
  30. vert_mc_qpel_no_rnd_aver_src1_16x16_msa
  31. vert_mc_qpel_avg_dst_aver_src0_8x8_msa
  32. vert_mc_qpel_avg_dst_aver_src0_16x16_msa
  33. vert_mc_qpel_avg_dst_8x8_msa
  34. vert_mc_qpel_avg_dst_16x16_msa
  35. vert_mc_qpel_avg_dst_aver_src1_8x8_msa
  36. vert_mc_qpel_avg_dst_aver_src1_16x16_msa
  37. hv_mc_qpel_no_rnd_horiz_src0_16x16_msa
  38. hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa
  39. hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa
  40. hv_mc_qpel_no_rnd_horiz_16x16_msa
  41. hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa
  42. hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa
  43. hv_mc_qpel_no_rnd_horiz_src1_16x16_msa
  44. hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa
  45. hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa
  46. hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa
  47. hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa
  48. hv_mc_qpel_no_rnd_16x16_msa
  49. hv_mc_qpel_no_rnd_8x8_msa
  50. hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa
  51. hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa
  52. hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa
  53. hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa
  54. hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa
  55. hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa
  56. hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa
  57. hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa
  58. hv_mc_qpel_aver_horiz_src0_16x16_msa
  59. hv_mc_qpel_aver_hv_src00_16x16_msa
  60. hv_mc_qpel_aver_hv_src00_8x8_msa
  61. hv_mc_qpel_aver_horiz_16x16_msa
  62. hv_mc_qpel_aver_v_src0_16x16_msa
  63. hv_mc_qpel_aver_v_src0_8x8_msa
  64. hv_mc_qpel_aver_horiz_src1_16x16_msa
  65. hv_mc_qpel_aver_hv_src10_16x16_msa
  66. hv_mc_qpel_aver_hv_src10_8x8_msa
  67. hv_mc_qpel_aver_h_src0_16x16_msa
  68. hv_mc_qpel_aver_h_src0_8x8_msa
  69. hv_mc_qpel_16x16_msa
  70. hv_mc_qpel_8x8_msa
  71. hv_mc_qpel_aver_h_src1_16x16_msa
  72. hv_mc_qpel_aver_h_src1_8x8_msa
  73. hv_mc_qpel_aver_hv_src01_16x16_msa
  74. hv_mc_qpel_aver_hv_src01_8x8_msa
  75. hv_mc_qpel_aver_v_src1_16x16_msa
  76. hv_mc_qpel_aver_v_src1_8x8_msa
  77. hv_mc_qpel_aver_hv_src11_16x16_msa
  78. hv_mc_qpel_aver_hv_src11_8x8_msa
  79. hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa
  80. hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa
  81. hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa
  82. hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa
  83. hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa
  84. hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa
  85. hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa
  86. hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa
  87. hv_mc_qpel_avg_dst_16x16_msa
  88. hv_mc_qpel_avg_dst_8x8_msa
  89. hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa
  90. hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa
  91. hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa
  92. hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa
  93. hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa
  94. hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa
  95. hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa
  96. hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa
  97. copy_8x8_msa
  98. copy_16x16_msa
  99. avg_width8_msa
  100. avg_width16_msa
  101. ff_copy_16x16_msa
  102. ff_copy_8x8_msa
  103. ff_horiz_mc_qpel_aver_src0_8width_msa
  104. ff_horiz_mc_qpel_aver_src0_16width_msa
  105. ff_horiz_mc_qpel_8width_msa
  106. ff_horiz_mc_qpel_16width_msa
  107. ff_horiz_mc_qpel_aver_src1_8width_msa
  108. ff_horiz_mc_qpel_aver_src1_16width_msa
  109. ff_horiz_mc_qpel_no_rnd_aver_src0_8width_msa
  110. ff_horiz_mc_qpel_no_rnd_aver_src0_16width_msa
  111. ff_horiz_mc_qpel_no_rnd_8width_msa
  112. ff_horiz_mc_qpel_no_rnd_16width_msa
  113. ff_horiz_mc_qpel_no_rnd_aver_src1_8width_msa
  114. ff_horiz_mc_qpel_no_rnd_aver_src1_16width_msa
  115. ff_avg_width8_msa
  116. ff_avg_width16_msa
  117. ff_horiz_mc_qpel_avg_dst_aver_src0_8width_msa
  118. ff_horiz_mc_qpel_avg_dst_aver_src0_16width_msa
  119. ff_horiz_mc_qpel_avg_dst_8width_msa
  120. ff_horiz_mc_qpel_avg_dst_16width_msa
  121. ff_horiz_mc_qpel_avg_dst_aver_src1_8width_msa
  122. ff_horiz_mc_qpel_avg_dst_aver_src1_16width_msa
  123. ff_vert_mc_qpel_aver_src0_8x8_msa
  124. ff_vert_mc_qpel_aver_src0_16x16_msa
  125. ff_vert_mc_qpel_8x8_msa
  126. ff_vert_mc_qpel_16x16_msa
  127. ff_vert_mc_qpel_aver_src1_8x8_msa
  128. ff_vert_mc_qpel_aver_src1_16x16_msa
  129. ff_vert_mc_qpel_no_rnd_aver_src0_8x8_msa
  130. ff_vert_mc_qpel_no_rnd_aver_src0_16x16_msa
  131. ff_vert_mc_qpel_no_rnd_8x8_msa
  132. ff_vert_mc_qpel_no_rnd_16x16_msa
  133. ff_vert_mc_qpel_no_rnd_aver_src1_8x8_msa
  134. ff_vert_mc_qpel_no_rnd_aver_src1_16x16_msa
  135. ff_vert_mc_qpel_avg_dst_aver_src0_8x8_msa
  136. ff_vert_mc_qpel_avg_dst_aver_src0_16x16_msa
  137. ff_vert_mc_qpel_avg_dst_8x8_msa
  138. ff_vert_mc_qpel_avg_dst_16x16_msa
  139. ff_vert_mc_qpel_avg_dst_aver_src1_8x8_msa
  140. ff_vert_mc_qpel_avg_dst_aver_src1_16x16_msa
  141. ff_hv_mc_qpel_aver_hv_src00_16x16_msa
  142. ff_hv_mc_qpel_aver_hv_src00_8x8_msa
  143. ff_hv_mc_qpel_aver_v_src0_16x16_msa
  144. ff_hv_mc_qpel_aver_v_src0_8x8_msa
  145. ff_hv_mc_qpel_aver_hv_src10_16x16_msa
  146. ff_hv_mc_qpel_aver_hv_src10_8x8_msa
  147. ff_hv_mc_qpel_aver_h_src0_16x16_msa
  148. ff_hv_mc_qpel_aver_h_src0_8x8_msa
  149. ff_hv_mc_qpel_16x16_msa
  150. ff_hv_mc_qpel_8x8_msa
  151. ff_hv_mc_qpel_aver_h_src1_16x16_msa
  152. ff_hv_mc_qpel_aver_h_src1_8x8_msa
  153. ff_hv_mc_qpel_aver_hv_src01_16x16_msa
  154. ff_hv_mc_qpel_aver_hv_src01_8x8_msa
  155. ff_hv_mc_qpel_aver_v_src1_16x16_msa
  156. ff_hv_mc_qpel_aver_v_src1_8x8_msa
  157. ff_hv_mc_qpel_aver_hv_src11_16x16_msa
  158. ff_hv_mc_qpel_aver_hv_src11_8x8_msa
  159. ff_hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa
  160. ff_hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa
  161. ff_hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa
  162. ff_hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa
  163. ff_hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa
  164. ff_hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa
  165. ff_hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa
  166. ff_hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa
  167. ff_hv_mc_qpel_avg_dst_16x16_msa
  168. ff_hv_mc_qpel_avg_dst_8x8_msa
  169. ff_hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa
  170. ff_hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa
  171. ff_hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa
  172. ff_hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa
  173. ff_hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa
  174. ff_hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa
  175. ff_hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa
  176. ff_hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa
  177. ff_hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa
  178. ff_hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa
  179. ff_hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa
  180. ff_hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa
  181. ff_hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa
  182. ff_hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa
  183. ff_hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa
  184. ff_hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa
  185. ff_hv_mc_qpel_no_rnd_16x16_msa
  186. ff_hv_mc_qpel_no_rnd_8x8_msa
  187. ff_hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa
  188. ff_hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa
  189. ff_hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa
  190. ff_hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa
  191. ff_hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa
  192. ff_hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa
  193. ff_hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa
  194. ff_hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa

/*
 * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com)
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "libavutil/mips/generic_macros_msa.h"
#include "qpeldsp_mips.h"

#define APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, coef0, coef1, coef2)  \
( {                                                                     \
    v16u8 out, tmp0, tmp1;                                              \
    v16u8 data0, data1, data2, data3, data4, data5;                     \
    v8i16 res_r, res_l;                                                 \
    v8u16 sum0_r, sum1_r, sum2_r, sum3_r;                               \
    v8u16 sum0_l, sum1_l, sum2_l, sum3_l;                               \
                                                                        \
    VSHF_B2_UB(inp0, inp0, inp1, inp1, mask, mask, tmp0, tmp1);         \
    ILVRL_B2_UH(inp1, inp0, sum0_r, sum0_l);                            \
    data0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 15);       \
    data3 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 1);        \
    HADD_UB2_UH(sum0_r, sum0_l, sum0_r, sum0_l);                        \
    ILVRL_B2_UH(data3, data0, sum1_r, sum1_l);                          \
    data1 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 14);       \
    data4 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 2);        \
    sum0_r *= (v8u16) (coef0);                                          \
    sum0_l *= (v8u16) (coef0);                                          \
    ILVRL_B2_UH(data4, data1, sum2_r, sum2_l);                          \
    data2 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 13);       \
    data5 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 3);        \
    DPADD_UB2_UH(sum2_r, sum2_l, coef2, coef2, sum0_r, sum0_l);         \
    ILVRL_B2_UH(data5, data2, sum3_r, sum3_l);                          \
    HADD_UB2_UH(sum3_r, sum3_l, sum3_r, sum3_l);                        \
    DPADD_UB2_UH(sum1_r, sum1_l, coef1, coef1, sum3_r, sum3_l);         \
    res_r = (v8i16) (sum0_r - sum3_r);                                  \
    res_l = (v8i16) (sum0_l - sum3_l);                                  \
    SRARI_H2_SH(res_r, res_l, 5);                                       \
    CLIP_SH2_0_255(res_r, res_l);                                       \
    out = (v16u8) __msa_pckev_b((v16i8) res_l, (v16i8) res_r);          \
                                                                        \
    out;                                                                \
} )

#define APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,                       \
                                      mask0, mask1, mask2, mask3,       \
                                      coef0, coef1, coef2)              \
( {                                                                     \
    v16u8 out;                                                          \
    v8u16 sum0_r, sum1_r, sum2_r, sum3_r;                               \
    v8u16 sum4_r, sum5_r, sum6_r, sum7_r;                               \
    v8i16 res0_r, res1_r;                                               \
                                                                        \
    VSHF_B2_UH(inp0, inp0, inp1, inp1, mask0, mask0, sum0_r, sum4_r);   \
    VSHF_B2_UH(inp0, inp0, inp1, inp1, mask3, mask3, sum3_r, sum7_r);   \
    HADD_UB2_UH(sum3_r, sum7_r, sum3_r, sum7_r);                        \
    DOTP_UB2_UH(sum0_r, sum4_r, coef0, coef0, sum0_r, sum4_r);          \
    VSHF_B2_UH(inp0, inp0, inp1, inp1, mask2, mask2, sum2_r, sum6_r);   \
    VSHF_B2_UH(inp0, inp0, inp1, inp1, mask1, mask1, sum1_r, sum5_r);   \
    DPADD_UB2_UH(sum2_r, sum6_r, coef2, coef2, sum0_r, sum4_r);         \
    DPADD_UB2_UH(sum1_r, sum5_r, coef1, coef1, sum3_r, sum7_r);         \
    res0_r = (v8i16) (sum0_r - sum3_r);                                 \
    res1_r = (v8i16) (sum4_r - sum7_r);                                 \
    SRARI_H2_SH(res0_r, res1_r, 5);                                     \
    CLIP_SH2_0_255(res0_r, res1_r);                                     \
    out = (v16u8) __msa_pckev_b((v16i8) res1_r, (v16i8) res0_r);        \
                                                                        \
    out;                                                                \
} )

#define APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0,                        \
                                           mask0, mask1, mask2, mask3,  \
                                           coef0, coef1, coef2)         \
( {                                                                     \
    v16u8 out;                                                          \
    v8i16 res0_r;                                                       \
    v8u16 sum0_r, sum1_r, sum2_r, sum3_r;                               \
                                                                        \
    VSHF_B2_UH(inp0, inp0, inp0, inp0, mask0, mask3, sum0_r, sum3_r);   \
    sum3_r = __msa_hadd_u_h((v16u8) sum3_r, (v16u8) sum3_r);            \
    sum0_r = __msa_dotp_u_h((v16u8) sum0_r, (v16u8) coef0);             \
    VSHF_B2_UH(inp0, inp0, inp0, inp0, mask2, mask1, sum2_r, sum1_r);   \
    DPADD_UB2_UH(sum2_r, sum1_r, coef2, coef1, sum0_r, sum3_r);         \
    res0_r = (v8i16) (sum0_r - sum3_r);                                 \
    res0_r = __msa_srari_h(res0_r, 5);                                  \
    CLIP_SH_0_255(res0_r);                                              \
    out = (v16u8) __msa_pckev_b((v16i8) res0_r, (v16i8) res0_r);        \
                                                                        \
    out;                                                                \
} )

#define APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1,   \
                                                    mask2, mask3, coef0,  \
                                                    coef1, coef2)         \
( {                                                                       \
    v16u8 out;                                                            \
    v8i16 res0_r;                                                         \
    v8u16 sum0_r, sum1_r, sum2_r, sum3_r;                                 \
                                                                          \
    VSHF_B2_UH(inp0, inp0, inp0, inp0, mask0, mask3, sum0_r, sum3_r);     \
    sum3_r = __msa_hadd_u_h((v16u8) sum3_r, (v16u8) sum3_r);              \
    sum0_r = __msa_dotp_u_h((v16u8) sum0_r, (v16u8) coef0);               \
    VSHF_B2_UH(inp0, inp0, inp0, inp0, mask2, mask1, sum2_r, sum1_r);     \
    DPADD_UB2_UH(sum2_r, sum1_r, coef2, coef1, sum0_r, sum3_r);           \
    res0_r = (v8i16) (sum0_r - sum3_r);                                   \
    res0_r += 15;                                                         \
    res0_r >>= 5;                                                         \
    CLIP_SH_0_255(res0_r);                                                \
    out = (v16u8) __msa_pckev_b((v16i8) res0_r, (v16i8) res0_r);          \
                                                                          \
    out;                                                                  \
} )

#define APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask,              \
                                         coef0, coef1, coef2)           \
( {                                                                     \
    v16u8 out, tmp0, tmp1;                                              \
    v16u8 data0, data1, data2, data3, data4, data5;                     \
    v8i16 res_r, res_l;                                                 \
    v8u16 sum0_r, sum1_r, sum2_r, sum3_r;                               \
    v8u16 sum0_l, sum1_l, sum2_l, sum3_l;                               \
                                                                        \
    VSHF_B2_UB(inp0, inp0, inp1, inp1, mask, mask, tmp0, tmp1);         \
    ILVRL_B2_UH(inp1, inp0, sum0_r, sum0_l);                            \
    data0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 15);       \
    data3 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 1);        \
    HADD_UB2_UH(sum0_r, sum0_l, sum0_r, sum0_l);                        \
    ILVRL_B2_UH(data3, data0, sum1_r, sum1_l);                          \
    data1 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 14);       \
    data4 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 2);        \
    sum0_r *= (v8u16) (coef0);                                          \
    sum0_l *= (v8u16) (coef0);                                          \
    ILVRL_B2_UH(data4, data1, sum2_r, sum2_l);                          \
    data2 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) tmp0, 13);       \
    data5 = (v16u8) __msa_sldi_b((v16i8) tmp1, (v16i8) inp1, 3);        \
    DPADD_UB2_UH(sum2_r, sum2_l, coef2, coef2, sum0_r, sum0_l);         \
    ILVRL_B2_UH(data5, data2, sum3_r, sum3_l);                          \
    HADD_UB2_UH(sum3_r, sum3_l, sum3_r, sum3_l);                        \
    DPADD_UB2_UH(sum1_r, sum1_l, coef1, coef1, sum3_r, sum3_l);         \
    res_r = (v8i16) (sum0_r - sum3_r);                                  \
    res_l = (v8i16) (sum0_l - sum3_l);                                  \
    res_r += 15;                                                        \
    res_l += 15;                                                        \
    res_r >>= 5;                                                        \
    res_l >>= 5;                                                        \
    CLIP_SH2_0_255(res_r, res_l);                                       \
    out = (v16u8) __msa_pckev_b((v16i8) res_l, (v16i8) res_r);          \
                                                                        \
    out;                                                                \
} )

#define APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1,                  \
                                               mask0, mask1, mask2, mask3,  \
                                               coef0, coef1, coef2)         \
( {                                                                         \
    v16u8 out;                                                              \
    v8i16 res0_r, res1_r;                                                   \
    v8u16 sum0_r, sum1_r, sum2_r, sum3_r;                                   \
    v8u16 sum4_r, sum5_r, sum6_r, sum7_r;                                   \
                                                                            \
    VSHF_B2_UH(inp0, inp0, inp1, inp1, mask0, mask0, sum0_r, sum4_r);       \
    VSHF_B2_UH(inp0, inp0, inp1, inp1, mask3, mask3, sum3_r, sum7_r);       \
    HADD_UB2_UH(sum3_r, sum7_r, sum3_r, sum7_r);                            \
    DOTP_UB2_UH(sum0_r, sum4_r, coef0, coef0, sum0_r, sum4_r);              \
    VSHF_B2_UH(inp0, inp0, inp1, inp1, mask2, mask2, sum2_r, sum6_r);       \
    VSHF_B2_UH(inp0, inp0, inp1, inp1, mask1, mask1, sum1_r, sum5_r);       \
    DPADD_UB2_UH(sum2_r, sum6_r, coef2, coef2, sum0_r, sum4_r);             \
    DPADD_UB2_UH(sum1_r, sum5_r, coef1, coef1, sum3_r, sum7_r);             \
    res0_r = (v8i16) (sum0_r - sum3_r);                                     \
    res1_r = (v8i16) (sum4_r - sum7_r);                                     \
    res0_r += 15;                                                           \
    res1_r += 15;                                                           \
    res0_r >>= 5;                                                           \
    res1_r >>= 5;                                                           \
    CLIP_SH2_0_255(res0_r, res1_r);                                         \
    out = (v16u8) __msa_pckev_b((v16i8) res1_r, (v16i8) res0_r);            \
                                                                            \
    out;                                                                    \
} )

#define APPLY_VERT_QPEL_FILTER(inp0, inp1, inp2, inp3,                  \
                               inp4, inp5, inp6, inp7,                  \
                               coef0, coef1, coef2)                     \
( {                                                                     \
    v16u8 res;                                                          \
    v8i16 res_r, res_l;                                                 \
    v8u16 sum0_r, sum1_r, sum2_r, sum3_r;                               \
    v8u16 sum0_l, sum1_l, sum2_l, sum3_l;                               \
                                                                        \
    ILVRL_B2_UH(inp4, inp0, sum0_r, sum0_l);                            \
    ILVRL_B2_UH(inp7, inp3, sum3_r, sum3_l);                            \
    DOTP_UB2_UH(sum0_r, sum0_l, coef0, coef0, sum0_r, sum0_l);          \
    HADD_UB2_UH(sum3_r, sum3_l, sum3_r, sum3_l);                        \
    ILVRL_B2_UH(inp6, inp2, sum2_r, sum2_l);                            \
    ILVRL_B2_UH(inp5, inp1, sum1_r, sum1_l);                            \
    DPADD_UB2_UH(sum2_r, sum2_l, coef2, coef2, sum0_r, sum0_l);         \
    DPADD_UB2_UH(sum1_r, sum1_l, coef1, coef1, sum3_r, sum3_l);         \
    res_r = (v8i16) (sum0_r - sum3_r);                                  \
    res_l = (v8i16) (sum0_l - sum3_l);                                  \
    SRARI_H2_SH(res_r, res_l, 5);                                       \
    CLIP_SH2_0_255(res_r, res_l);                                       \
    res = (v16u8) __msa_pckev_b((v16i8) res_l, (v16i8) res_r);          \
                                                                        \
    res;                                                                \
} )

#define APPLY_VERT_QPEL_FILTER_8BYTE(inp00, inp01, inp02, inp03,        \
                                     inp04, inp05, inp06, inp07,        \
                                     inp10, inp11, inp12, inp13,        \
                                     inp14, inp15, inp16, inp17,        \
                                     coef0, coef1, coef2)               \
( {                                                                     \
    v16u8 res;                                                          \
    v8i16 val0, val1;                                                   \
    v8u16 sum00, sum01, sum02, sum03;                                   \
    v8u16 sum10, sum11, sum12, sum13;                                   \
                                                                        \
    ILVR_B4_UH(inp04, inp00, inp14, inp10, inp07, inp03, inp17, inp13,  \
               sum00, sum10, sum03, sum13);                             \
    DOTP_UB2_UH(sum00, sum10, coef0, coef0, sum00, sum10);              \
    HADD_UB2_UH(sum03, sum13, sum03, sum13);                            \
    ILVR_B4_UH(inp06, inp02, inp16, inp12, inp05, inp01, inp15, inp11,  \
               sum02, sum12, sum01, sum11);                             \
    DPADD_UB2_UH(sum02, sum12, coef2, coef2, sum00, sum10);             \
    DPADD_UB2_UH(sum01, sum11, coef1, coef1, sum03, sum13);             \
    val0 = (v8i16) (sum00 - sum03);                                     \
    val1 = (v8i16) (sum10 - sum13);                                     \
    SRARI_H2_SH(val0, val1, 5);                                         \
    CLIP_SH2_0_255(val0, val1);                                         \
    res = (v16u8) __msa_pckev_b((v16i8) val1, (v16i8) val0);            \
                                                                        \
    res;                                                                \
} )

#define APPLY_VERT_QPEL_NO_ROUND_FILTER(inp0, inp1, inp2, inp3,         \
                                        inp4, inp5, inp6, inp7,         \
                                        coef0, coef1, coef2)            \
( {                                                                     \
    v16u8 res;                                                          \
    v8i16 res_r, res_l;                                                 \
    v8u16 sum0_r, sum1_r, sum2_r, sum3_r;                               \
    v8u16 sum0_l, sum1_l, sum2_l, sum3_l;                               \
                                                                        \
    ILVRL_B2_UH(inp4, inp0, sum0_r, sum0_l);                            \
    ILVRL_B2_UH(inp7, inp3, sum3_r, sum3_l);                            \
    DOTP_UB2_UH(sum0_r, sum0_l, coef0, coef0, sum0_r, sum0_l);          \
    HADD_UB2_UH(sum3_r, sum3_l, sum3_r, sum3_l);                        \
    ILVRL_B2_UH(inp6, inp2, sum2_r, sum2_l);                            \
    ILVRL_B2_UH(inp5, inp1, sum1_r, sum1_l);                            \
    DPADD_UB2_UH(sum2_r, sum2_l, coef2, coef2, sum0_r, sum0_l);         \
    DPADD_UB2_UH(sum1_r, sum1_l, coef1, coef1, sum3_r, sum3_l);         \
    res_r = (v8i16) (sum0_r - sum3_r);                                  \
    res_l = (v8i16) (sum0_l - sum3_l);                                  \
    res_r += 15;                                                        \
    res_l += 15;                                                        \
    res_r >>= 5;                                                        \
    res_l >>= 5;                                                        \
    CLIP_SH2_0_255(res_r, res_l);                                       \
    res = (v16u8) __msa_pckev_b((v16i8) res_l, (v16i8) res_r);          \
                                                                        \
    res;                                                                \
} )

#define APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp00, inp01, inp02, inp03,  \
                                              inp04, inp05, inp06, inp07,  \
                                              inp10, inp11, inp12, inp13,  \
                                              inp14, inp15, inp16, inp17,  \
                                              coef0, coef1, coef2)         \
( {                                                                        \
    v16u8 res;                                                             \
    v8i16 val0, val1;                                                      \
    v8u16 sum00, sum01, sum02, sum03;                                      \
    v8u16 sum10, sum11, sum12, sum13;                                      \
                                                                           \
    ILVR_B4_UH(inp04, inp00, inp14, inp10, inp07, inp03, inp17, inp13,     \
               sum00, sum10, sum03, sum13);                                \
    DOTP_UB2_UH(sum00, sum10, coef0, coef0, sum00, sum10);                 \
    HADD_UB2_UH(sum03, sum13, sum03, sum13);                               \
    ILVR_B4_UH(inp06, inp02, inp16, inp12, inp05, inp01, inp15, inp11,     \
               sum02, sum12, sum01, sum11);                                \
    DPADD_UB2_UH(sum02, sum12, coef2, coef2, sum00, sum10);                \
    DPADD_UB2_UH(sum01, sum11, coef1, coef1, sum03, sum13);                \
    val0 = (v8i16) (sum00 - sum03);                                        \
    val1 = (v8i16) (sum10 - sum13);                                        \
    val0 += 15;                                                            \
    val1 += 15;                                                            \
    val0 >>= 5;                                                            \
    val1 >>= 5;                                                            \
    CLIP_SH2_0_255(val0, val1);                                            \
    res = (v16u8) __msa_pckev_b((v16i8) val1, (v16i8) val0);               \
                                                                           \
    res;                                                                   \
} )

static void horiz_mc_qpel_aver_src0_8width_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride,
                                               int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
        inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
        AVER_UB2_UB(inp0, res0, inp2, res1, res0, res1);
        ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
        dst += (4 * dst_stride);
    }
}

static void horiz_mc_qpel_aver_src0_16width_msa(const uint8_t *src,
                                                int32_t src_stride,
                                                uint8_t *dst,
                                                int32_t dst_stride,
                                                int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(inp0, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(inp2, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(inp4, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(inp6, res);
        ST_UB(res, dst);
        dst += dst_stride;
    }
}

static void horiz_mc_qpel_8width_msa(const uint8_t *src,
                                     int32_t src_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
                                     int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
        dst += (4 * dst_stride);
    }
}

static void horiz_mc_qpel_16width_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
                                      int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v8u16 const20 = (v8u16) __msa_ldi_h(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask,
                                      const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask,
                                      const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask,
                                      const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask,
                                      const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;
    }
}

static void horiz_mc_qpel_aver_src1_8width_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride,
                                               int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        SLDI_B4_UB(inp0, inp0, inp1, inp1, inp2, inp2, inp3, inp3, 1,
                   inp0, inp1, inp2, inp3);
        inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
        inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
        AVER_UB2_UB(inp0, res0, inp2, res1, res0, res1);
        ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
        dst += (4 * dst_stride);
    }
}

static void horiz_mc_qpel_aver_src1_16width_msa(const uint8_t *src,
                                                int32_t src_stride,
                                                uint8_t *dst,
                                                int32_t dst_stride,
                                                int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v8u16 const20 = (v8u16) __msa_ldi_h(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(res, inp1);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(res, inp3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(res, inp5);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(res, inp7);
        ST_UB(res, dst);
        dst += dst_stride;
    }
}

static void horiz_mc_qpel_no_rnd_aver_src0_8width_msa(const uint8_t *src,
                                                      int32_t src_stride,
                                                      uint8_t *dst,
                                                      int32_t dst_stride,
                                                      int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                      mask2, mask3, const20,
                                                      const6, const3);
        res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                      mask2, mask3, const20,
                                                      const6, const3);
        inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
        inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
        res0 = __msa_ave_u_b(inp0, res0);
        res1 = __msa_ave_u_b(inp2, res1);
        ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
        dst += (4 * dst_stride);
    }
}

static void horiz_mc_qpel_no_rnd_aver_src0_16width_msa(const uint8_t *src,
                                                       int32_t src_stride,
                                                       uint8_t *dst,
                                                       int32_t dst_stride,
                                                       int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v8u16 const20 = (v8u16) __msa_ldi_h(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(inp0, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(inp2, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(inp4, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(inp6, res);
        ST_UB(res, dst);
        dst += dst_stride;
    }
}

static void horiz_mc_qpel_no_rnd_8width_msa(const uint8_t *src,
                                            int32_t src_stride,
                                            uint8_t *dst,
                                            int32_t dst_stride,
                                            int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                      mask2, mask3, const20,
                                                      const6, const3);
        res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                      mask2, mask3, const20,
                                                      const6, const3);
        ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
        dst += (4 * dst_stride);
    }
}

static void horiz_mc_qpel_no_rnd_16width_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride,
                                             int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask,
                                               const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask,
                                               const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask,
                                               const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask,
                                               const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;
    }
}

static void horiz_mc_qpel_no_rnd_aver_src1_8width_msa(const uint8_t *src,
                                                      int32_t src_stride,
                                                      uint8_t *dst,
                                                      int32_t dst_stride,
                                                      int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                      mask2, mask3, const20,
                                                      const6, const3);
        res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                      mask2, mask3, const20,
                                                      const6, const3);
        SLDI_B4_UB(inp0, inp0, inp1, inp1, inp2, inp2, inp3, inp3, 1,
                   inp0, inp1, inp2, inp3);
        inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
        inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
        res0 = __msa_ave_u_b(inp0, res0);
        res1 = __msa_ave_u_b(inp2, res1);
        ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
        dst += (4 * dst_stride);
    }
}

static void horiz_mc_qpel_no_rnd_aver_src1_16width_msa(const uint8_t *src,
                                                       int32_t src_stride,
                                                       uint8_t *dst,
                                                       int32_t dst_stride,
                                                       int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(res, inp1);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(res, inp3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(res, inp5);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(res, inp7);
        ST_UB(res, dst);
        dst += dst_stride;
    }
}

static void horiz_mc_qpel_avg_dst_aver_src0_8width_msa(const uint8_t *src,
                                                       int32_t src_stride,
                                                       uint8_t *dst,
                                                       int32_t dst_stride,
                                                       int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 dst0, dst1, dst2, dst3;
    v16u8 res0, res1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
        inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
        inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
        dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1);
        dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3);
        AVER_UB2_UB(inp0, res0, inp2, res1, res0, res1);
        AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1);
        ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
        dst += (4 * dst_stride);
    }
}

static void horiz_mc_qpel_avg_dst_aver_src0_16width_msa(const uint8_t *src,
                                                        int32_t src_stride,
                                                        uint8_t *dst,
                                                        int32_t dst_stride,
                                                        int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res0, res1;
    v16u8 dst0, dst1;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask,
                                       const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask,
                                       const20, const6, const3);
        LD_UB2(dst, dst_stride, dst0, dst1);
        AVER_UB2_UB(inp0, res0, inp2, res1, res0, res1);
        AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1);
        ST_UB2(res0, res1, dst, dst_stride);
        dst += (2 * dst_stride);

        res0 = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask,
                                       const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask,
                                       const20, const6, const3);
        LD_UB2(dst, dst_stride, dst0, dst1);
        AVER_UB2_UB(inp4, res0, inp6, res1, res0, res1);
        AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1);
        ST_UB2(res0, res1, dst, dst_stride);
        dst += (2 * dst_stride);
    }
}

static void horiz_mc_qpel_avg_dst_8width_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride,
                                             int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 dst0, dst1, dst2, dst3;
    v16u8 res0, res1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
        dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1);
        dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3);
        AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1);
        ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
        dst += (4 * dst_stride);
    }
}

static void horiz_mc_qpel_avg_dst_16width_msa(const uint8_t *src,
                                              int32_t src_stride,
                                              uint8_t *dst,
                                              int32_t dst_stride,
                                              int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res0, res1;
    v16u8 dst0, dst1;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask,
                                       const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask,
                                       const20, const6, const3);
        LD_UB2(dst, dst_stride, dst0, dst1);
        AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1);
        ST_UB2(res0, res1, dst, dst_stride);
        dst += (2 * dst_stride);

        res0 = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask,
                                       const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask,
                                       const20, const6, const3);
        LD_UB2(dst, dst_stride, dst0, dst1);
        AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1);
        ST_UB2(res0, res1, dst, dst_stride);
        dst += (2 * dst_stride);
    }
}

static void horiz_mc_qpel_avg_dst_aver_src1_8width_msa(const uint8_t *src,
                                                       int32_t src_stride,
                                                       uint8_t *dst,
                                                       int32_t dst_stride,
                                                       int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 dst0, dst1, dst2, dst3;
    v16u8 res0, res1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                             mask0, mask1, mask2, mask3,
                                             const20, const6, const3);
        LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
        SLDI_B4_UB(inp0, inp0, inp1, inp1, inp2, inp2, inp3, inp3, 1,
                   inp0, inp1, inp2, inp3);
        inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
        inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
        dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1);
        dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3);
        AVER_UB2_UB(inp0, res0, inp2, res1, res0, res1);
        AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1);
        ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
        dst += (4 * dst_stride);
    }
}

static void horiz_mc_qpel_avg_dst_aver_src1_16width_msa(const uint8_t *src,
                                                        int32_t src_stride,
                                                        uint8_t *dst,
                                                        int32_t dst_stride,
                                                        int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res0, res1, dst0, dst1;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res0 = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask,
                                       const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask,
                                       const20, const6, const3);
        LD_UB2(dst, dst_stride, dst0, dst1);
        AVER_UB2_UB(res0, inp1, res1, inp3, res0, res1);
        AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1);
        ST_UB2(res0, res1, dst, dst_stride);
        dst += (2 * dst_stride);
        res0 = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask,
                                       const20, const6, const3);
        res1 = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask,
                                       const20, const6, const3);
        LD_UB2(dst, dst_stride, dst0, dst1);
        AVER_UB2_UB(res0, inp5, res1, inp7, res0, res1);
        AVER_UB2_UB(dst0, res0, dst1, res1, res0, res1);
        ST_UB2(res0, res1, dst, dst_stride);
        dst += (2 * dst_stride);
    }
}


static void vert_mc_qpel_aver_src0_8x8_msa(const uint8_t *src,
                                           int32_t src_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 tmp0, tmp1, res0, res1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    LD_UB2(src, src_stride, inp4, inp5);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2,
                                        inp1, inp2, inp3, inp4,
                                        inp1, inp0, inp0, inp1,
                                        inp2, inp3, inp4, inp5,
                                        const20, const6, const3);
    LD_UB2(src, src_stride, inp6, inp7);
    src += (2 * src_stride);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0,
                                        inp3, inp4, inp5, inp6,
                                        inp3, inp2, inp1, inp0,
                                        inp4, inp5, inp6, inp7,
                                        const20, const6, const3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);

    inp8 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1,
                                        inp5, inp6, inp7, inp8,
                                        inp5, inp4, inp3, inp2,
                                        inp6, inp7, inp8, inp8,
                                        const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3,
                                        inp7, inp8, inp8, inp7,
                                        inp7, inp6, inp5, inp4,
                                        inp8, inp8, inp7, inp6,
                                        const20, const6, const3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp4, 1, (v2i64) inp5);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp6, 1, (v2i64) inp7);
    AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst + 4 * dst_stride, dst_stride);
}

static void vert_mc_qpel_aver_src0_16x16_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16;
    v16u8 res0;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4);
    src += (5 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2,
                                  inp1, inp2, inp3, inp4,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp0);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp5 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1,
                                  inp2, inp3, inp4, inp5,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp1);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp6 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0,
                                  inp3, inp4, inp5, inp6,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp2);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp7 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0,
                                  inp4, inp5, inp6, inp7,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp3);
    ST_UB(res0, dst);
    dst += dst_stride;

    LD_UB2(src, src_stride, inp8, inp9);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1,
                                  inp5, inp6, inp7, inp8,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp4);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2,
                                  inp6, inp7, inp8, inp9,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp5);
    ST_UB(res0, dst);
    dst += dst_stride;

    LD_UB2(src, src_stride, inp10, inp11);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3,
                                  inp7, inp8, inp9, inp10,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp6);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4,
                                  inp8, inp9, inp10, inp11,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp7);
    ST_UB(res0, dst);
    dst += dst_stride;

    LD_UB2(src, src_stride, inp12, inp13);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5,
                                  inp9, inp10, inp11, inp12,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp8);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6,
                                  inp10, inp11, inp12, inp13,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp9);
    ST_UB(res0, dst);
    dst += dst_stride;

    LD_UB2(src, src_stride, inp14, inp15);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7,
                                  inp11, inp12, inp13, inp14,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp10);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8,
                                  inp12, inp13, inp14, inp15,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp11);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp16 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9,
                                  inp13, inp14, inp15, inp16,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp12);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10,
                                  inp14, inp15, inp16, inp16,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp13);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11,
                                  inp15, inp16, inp16, inp15,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp14);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12,
                                  inp16, inp16, inp15, inp14,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp15);
    ST_UB(res0, dst);
}

static void vert_mc_qpel_8x8_msa(const uint8_t *src,
                                 int32_t src_stride,
                                 uint8_t *dst,
                                 int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 res0, res1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    LD_UB2(src, src_stride, inp4, inp5);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2,
                                        inp1, inp2, inp3, inp4,
                                        inp1, inp0, inp0, inp1,
                                        inp2, inp3, inp4, inp5,
                                        const20, const6, const3);
    LD_UB2(src, src_stride, inp6, inp7);
    src += (2 * src_stride);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0,
                                        inp3, inp4, inp5, inp6,
                                        inp3, inp2, inp1, inp0,
                                        inp4, inp5, inp6, inp7,
                                        const20, const6, const3);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);

    inp8 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1,
                                        inp5, inp6, inp7, inp8,
                                        inp5, inp4, inp3, inp2,
                                        inp6, inp7, inp8, inp8,
                                        const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3,
                                        inp7, inp8, inp8, inp7,
                                        inp7, inp6, inp5, inp4,
                                        inp8, inp8, inp7, inp6,
                                        const20, const6, const3);
    ST_D4(res0, res1, 0, 1, 0, 1, dst + 4 * dst_stride, dst_stride);
}

static void vert_mc_qpel_16x16_msa(const uint8_t *src,
                                   int32_t src_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16;
    v16u8 res0;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    inp4 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2,
                                  inp1, inp2, inp3, inp4,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp5 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1,
                                  inp2, inp3, inp4, inp5,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp6 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0,
                                  inp3, inp4, inp5, inp6,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp7 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0,
                                  inp4, inp5, inp6, inp7,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp8 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1,
                                  inp5, inp6, inp7, inp8,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp9 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2,
                                  inp6, inp7, inp8, inp9,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp10 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3,
                                  inp7, inp8, inp9, inp10,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp11 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4,
                                  inp8, inp9, inp10, inp11,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp12 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5,
                                  inp9, inp10, inp11, inp12,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp13 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6,
                                  inp10, inp11, inp12, inp13,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp14 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7,
                                  inp11, inp12, inp13, inp14,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp15 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8,
                                  inp12, inp13, inp14, inp15,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp16 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9,
                                  inp13, inp14, inp15, inp16,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10,
                                  inp14, inp15, inp16, inp16,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11,
                                  inp15, inp16, inp16, inp15,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12,
                                  inp16, inp16, inp15, inp14,
                                  const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;
}

static void vert_mc_qpel_aver_src1_8x8_msa(const uint8_t *src,
                                           int32_t src_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 tmp0, tmp1, res0, res1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    LD_UB2(src, src_stride, inp4, inp5);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2,
                                        inp1, inp2, inp3, inp4,
                                        inp1, inp0, inp0, inp1,
                                        inp2, inp3, inp4, inp5,
                                        const20, const6, const3);

    LD_UB2(src, src_stride, inp6, inp7);
    src += (2 * src_stride);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0,
                                        inp3, inp4, inp5, inp6,
                                        inp3, inp2, inp1, inp0,
                                        inp4, inp5, inp6, inp7,
                                        const20, const6, const3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp1, 1, (v2i64) inp2);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp3, 1, (v2i64) inp4);
    AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);

    inp8 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1,
                                        inp5, inp6, inp7, inp8,
                                        inp5, inp4, inp3, inp2,
                                        inp6, inp7, inp8, inp8,
                                        const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3,
                                        inp7, inp8, inp8, inp7,
                                        inp7, inp6, inp5, inp4,
                                        inp8, inp8, inp7, inp6,
                                        const20, const6, const3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp5, 1, (v2i64) inp6);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp7, 1, (v2i64) inp8);
    AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst + 4 * dst_stride, dst_stride);
}

static void vert_mc_qpel_aver_src1_16x16_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16;
    v16u8 res0;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    inp4 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2,
                                  inp1, inp2, inp3, inp4,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp1);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp5 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1,
                                  inp2, inp3, inp4, inp5,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp2);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp6 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0,
                                  inp3, inp4, inp5, inp6,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp7 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0,
                                  inp4, inp5, inp6, inp7,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp4);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp8 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1,
                                  inp5, inp6, inp7, inp8,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp5);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp9 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2,
                                  inp6, inp7, inp8, inp9,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp6);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp10 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3,
                                  inp7, inp8, inp9, inp10,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp7);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp11 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4,
                                  inp8, inp9, inp10, inp11,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp8);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp12 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5,
                                  inp9, inp10, inp11, inp12,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp9);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp13 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6,
                                  inp10, inp11, inp12, inp13,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp10);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp14 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7,
                                  inp11, inp12, inp13, inp14,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp11);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp15 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8,
                                  inp12, inp13, inp14, inp15,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp12);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp16 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9,
                                  inp13, inp14, inp15, inp16,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp13);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10,
                                  inp14, inp15, inp16, inp16,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp14);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11,
                                  inp15, inp16, inp16, inp15,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp15);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12,
                                  inp16, inp16, inp15, inp14,
                                  const20, const6, const3);
    res0 = __msa_aver_u_b(res0, inp16);
    ST_UB(res0, dst);
}

static void vert_mc_qpel_no_rnd_aver_src0_8x8_msa(const uint8_t *src,
                                                  int32_t src_stride,
                                                  uint8_t *dst,
                                                  int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 tmp0, tmp1, res0, res1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    LD_UB2(src, src_stride, inp4, inp5);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp0, inp1, inp2,
                                                 inp1, inp2, inp3, inp4,
                                                 inp1, inp0, inp0, inp1,
                                                 inp2, inp3, inp4, inp5,
                                                 const20, const6, const3);
    LD_UB2(src, src_stride, inp6, inp7);
    src += (2 * src_stride);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp1, inp0, inp0,
                                                 inp3, inp4, inp5, inp6,
                                                 inp3, inp2, inp1, inp0,
                                                 inp4, inp5, inp6, inp7,
                                                 const20, const6, const3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    res0 = __msa_ave_u_b(res0, tmp0);
    res1 = __msa_ave_u_b(res1, tmp1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);

    inp8 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp4, inp3, inp2, inp1,
                                                 inp5, inp6, inp7, inp8,
                                                 inp5, inp4, inp3, inp2,
                                                 inp6, inp7, inp8, inp8,
                                                 const20, const6, const3);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp6, inp5, inp4, inp3,
                                                 inp7, inp8, inp8, inp7,
                                                 inp7, inp6, inp5, inp4,
                                                 inp8, inp8, inp7, inp6,
                                                 const20, const6, const3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp4, 1, (v2i64) inp5);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp6, 1, (v2i64) inp7);
    res0 = __msa_ave_u_b(res0, tmp0);
    res1 = __msa_ave_u_b(res1, tmp1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst + 4 * dst_stride, dst_stride);
}

static void vert_mc_qpel_no_rnd_aver_src0_16x16_msa(const uint8_t *src,
                                                    int32_t src_stride,
                                                    uint8_t *dst,
                                                    int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16;
    v16u8 res0;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4);
    src += (5 * src_stride);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp0, inp0, inp1, inp2,
                                           inp1, inp2, inp3, inp4,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp0);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp5 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp1, inp0, inp0, inp1,
                                           inp2, inp3, inp4, inp5,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp1);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp6 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp2, inp1, inp0, inp0,
                                           inp3, inp4, inp5, inp6,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp2);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp7 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp3, inp2, inp1, inp0,
                                           inp4, inp5, inp6, inp7,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp8 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp4, inp3, inp2, inp1,
                                           inp5, inp6, inp7, inp8,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp4);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp9 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp5, inp4, inp3, inp2,
                                           inp6, inp7, inp8, inp9,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp5);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp10 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp6, inp5, inp4, inp3,
                                           inp7, inp8, inp9, inp10,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp6);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp11 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp7, inp6, inp5, inp4,
                                           inp8, inp9, inp10, inp11,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp7);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp12 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp8, inp7, inp6, inp5,
                                           inp9, inp10, inp11, inp12,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp8);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp13 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp9, inp8, inp7, inp6,
                                           inp10, inp11, inp12, inp13,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp9);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp14 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp10, inp9, inp8, inp7,
                                           inp11, inp12, inp13, inp14,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp10);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp15 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp11, inp10, inp9, inp8,
                                           inp12, inp13, inp14, inp15,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp11);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp16 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp12, inp11, inp10, inp9,
                                           inp13, inp14, inp15, inp16,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp12);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp13, inp12, inp11, inp10,
                                           inp14, inp15, inp16, inp16,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp13);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp14, inp13, inp12, inp11,
                                           inp15, inp16, inp16, inp15,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp14);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp15, inp14, inp13, inp12,
                                           inp16, inp16, inp15, inp14,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp15);
    ST_UB(res0, dst);
    dst += dst_stride;
}

static void vert_mc_qpel_no_rnd_8x8_msa(const uint8_t *src,
                                        int32_t src_stride,
                                        uint8_t *dst,
                                        int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 res0, res1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    LD_UB2(src, src_stride, inp4, inp5);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp0, inp1, inp2,
                                                 inp1, inp2, inp3, inp4,
                                                 inp1, inp0, inp0, inp1,
                                                 inp2, inp3, inp4, inp5,
                                                 const20, const6, const3);
    LD_UB2(src, src_stride, inp6, inp7);
    src += (2 * src_stride);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp1, inp0, inp0,
                                                 inp3, inp4, inp5, inp6,
                                                 inp3, inp2, inp1, inp0,
                                                 inp4, inp5, inp6, inp7,
                                                 const20, const6, const3);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);

    inp8 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp4, inp3, inp2, inp1,
                                                 inp5, inp6, inp7, inp8,
                                                 inp5, inp4, inp3, inp2,
                                                 inp6, inp7, inp8, inp8,
                                                 const20, const6, const3);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp6, inp5, inp4, inp3,
                                                 inp7, inp8, inp8, inp7,
                                                 inp7, inp6, inp5, inp4,
                                                 inp8, inp8, inp7, inp6,
                                                 const20, const6, const3);
    ST_D4(res0, res1, 0, 1, 0, 1, dst + 4 * dst_stride, dst_stride);
}

static void vert_mc_qpel_no_rnd_16x16_msa(const uint8_t *src,
                                          int32_t src_stride,
                                          uint8_t *dst,
                                          int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16;
    v16u8 res0;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4);
    src += (5 * src_stride);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp0, inp0, inp1, inp2,
                                           inp1, inp2, inp3, inp4,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp5 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp1, inp0, inp0, inp1,
                                           inp2, inp3, inp4, inp5,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp6 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp2, inp1, inp0, inp0,
                                           inp3, inp4, inp5, inp6,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp7 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp3, inp2, inp1, inp0,
                                           inp4, inp5, inp6, inp7,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp8 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp4, inp3, inp2, inp1,
                                           inp5, inp6, inp7, inp8,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp9 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp5, inp4, inp3, inp2,
                                           inp6, inp7, inp8, inp9,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp10 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp6, inp5, inp4, inp3,
                                           inp7, inp8, inp9, inp10,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp11 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp7, inp6, inp5, inp4,
                                           inp8, inp9, inp10, inp11,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp12 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp8, inp7, inp6, inp5,
                                           inp9, inp10, inp11, inp12,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp13 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp9, inp8, inp7, inp6,
                                           inp10, inp11, inp12, inp13,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp14 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp10, inp9, inp8, inp7,
                                           inp11, inp12, inp13, inp14,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp15 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp11, inp10, inp9, inp8,
                                           inp12, inp13, inp14, inp15,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp16 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp12, inp11, inp10, inp9,
                                           inp13, inp14, inp15, inp16,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp13, inp12, inp11, inp10,
                                           inp14, inp15, inp16, inp16,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp14, inp13, inp12, inp11,
                                           inp15, inp16, inp16, inp15,
                                           const20, const6, const3);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp15, inp14, inp13, inp12,
                                           inp16, inp16, inp15, inp14,
                                           const20, const6, const3);
    ST_UB(res0, dst);
}

static void vert_mc_qpel_no_rnd_aver_src1_8x8_msa(const uint8_t *src,
                                                  int32_t src_stride,
                                                  uint8_t *dst,
                                                  int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 tmp0, tmp1, res0, res1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    LD_UB2(src, src_stride, inp4, inp5);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp0, inp1, inp2,
                                                 inp1, inp2, inp3, inp4,
                                                 inp1, inp0, inp0, inp1,
                                                 inp2, inp3, inp4, inp5,
                                                 const20, const6, const3);
    LD_UB2(src, src_stride, inp6, inp7);
    src += (2 * src_stride);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp1, inp0, inp0,
                                                 inp3, inp4, inp5, inp6,
                                                 inp3, inp2, inp1, inp0,
                                                 inp4, inp5, inp6, inp7,
                                                 const20, const6, const3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp1, 1, (v2i64) inp2);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp3, 1, (v2i64) inp4);
    res0 = __msa_ave_u_b(res0, tmp0);
    res1 = __msa_ave_u_b(res1, tmp1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);

    inp8 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp4, inp3, inp2, inp1,
                                                 inp5, inp6, inp7, inp8,
                                                 inp5, inp4, inp3, inp2,
                                                 inp6, inp7, inp8, inp8,
                                                 const20, const6, const3);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(inp6, inp5, inp4, inp3,
                                                 inp7, inp8, inp8, inp7,
                                                 inp7, inp6, inp5, inp4,
                                                 inp8, inp8, inp7, inp6,
                                                 const20, const6, const3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp5, 1, (v2i64) inp6);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp7, 1, (v2i64) inp8);
    res0 = __msa_ave_u_b(res0, tmp0);
    res1 = __msa_ave_u_b(res1, tmp1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst + 4 * dst_stride, dst_stride);
}

static void vert_mc_qpel_no_rnd_aver_src1_16x16_msa(const uint8_t *src,
                                                    int32_t src_stride,
                                                    uint8_t *dst,
                                                    int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16;
    v16u8 res0;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4);
    src += (5 * src_stride);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp0, inp0, inp1, inp2,
                                           inp1, inp2, inp3, inp4,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp1);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp5 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp1, inp0, inp0, inp1,
                                           inp2, inp3, inp4, inp5,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp2);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp6 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp2, inp1, inp0, inp0,
                                           inp3, inp4, inp5, inp6,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp3);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp7 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp3, inp2, inp1, inp0,
                                           inp4, inp5, inp6, inp7,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp4);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp8 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp4, inp3, inp2, inp1,
                                           inp5, inp6, inp7, inp8,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp5);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp9 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp5, inp4, inp3, inp2,
                                           inp6, inp7, inp8, inp9,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp6);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp10 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp6, inp5, inp4, inp3,
                                           inp7, inp8, inp9, inp10,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp7);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp11 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp7, inp6, inp5, inp4,
                                           inp8, inp9, inp10, inp11,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp8);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp12 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp8, inp7, inp6, inp5,
                                           inp9, inp10, inp11, inp12,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp9);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp13 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp9, inp8, inp7, inp6,
                                           inp10, inp11, inp12, inp13,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp10);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp14 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp10, inp9, inp8, inp7,
                                           inp11, inp12, inp13, inp14,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp11);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp15 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp11, inp10, inp9, inp8,
                                           inp12, inp13, inp14, inp15,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp12);
    ST_UB(res0, dst);
    dst += dst_stride;

    inp16 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp12, inp11, inp10, inp9,
                                           inp13, inp14, inp15, inp16,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp13);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp13, inp12, inp11, inp10,
                                           inp14, inp15, inp16, inp16,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp14);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp14, inp13, inp12, inp11,
                                           inp15, inp16, inp16, inp15,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp15);
    ST_UB(res0, dst);
    dst += dst_stride;

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER(inp15, inp14, inp13, inp12,
                                           inp16, inp16, inp15, inp14,
                                           const20, const6, const3);
    res0 = __msa_ave_u_b(res0, inp16);
    ST_UB(res0, dst);
}

static void vert_mc_qpel_avg_dst_aver_src0_8x8_msa(const uint8_t *src,
                                                   int32_t src_stride,
                                                   uint8_t *dst,
                                                   int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 dst0, dst1, dst2, dst3;
    v16u8 tmp0, tmp1, res0, res1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    LD_UB2(src, src_stride, inp4, inp5);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2,
                                        inp1, inp2, inp3, inp4,
                                        inp1, inp0, inp0, inp1,
                                        inp2, inp3, inp4, inp5,
                                        const20, const6, const3);

    LD_UB2(src, src_stride, inp6, inp7);
    src += (2 * src_stride);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0,
                                        inp3, inp4, inp5, inp6,
                                        inp3, inp2, inp1, inp0,
                                        inp4, inp5, inp6, inp7,
                                        const20, const6, const3);

    LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1);
    dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3);
    AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1);
    AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
    dst += (4 * dst_stride);

    inp8 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1,
                                        inp5, inp6, inp7, inp8,
                                        inp5, inp4, inp3, inp2,
                                        inp6, inp7, inp8, inp8,
                                        const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3,
                                        inp7, inp8, inp8, inp7,
                                        inp7, inp6, inp5, inp4,
                                        inp8, inp8, inp7, inp6,
                                        const20, const6, const3);

    LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp4, 1, (v2i64) inp5);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp6, 1, (v2i64) inp7);
    dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1);
    dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3);
    AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1);
    AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void vert_mc_qpel_avg_dst_aver_src0_16x16_msa(const uint8_t *src,
                                                     int32_t src_stride,
                                                     uint8_t *dst,
                                                     int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16;
    v16u8 res0, res1, dst0, dst1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4);
    src += (5 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2,
                                  inp1, inp2, inp3, inp4,
                                  const20, const6, const3);

    inp5 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1,
                                  inp2, inp3, inp4, inp5,
                                  const20, const6, const3);

    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp0, res1, inp1, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp6 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0,
                                  inp3, inp4, inp5, inp6,
                                  const20, const6, const3);

    inp7 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0,
                                  inp4, inp5, inp6, inp7,
                                  const20, const6, const3);

    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp2, res1, inp3, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp8, inp9);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1,
                                  inp5, inp6, inp7, inp8,
                                  const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2,
                                  inp6, inp7, inp8, inp9,
                                  const20, const6, const3);

    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp4, res1, inp5, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp10, inp11);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3,
                                  inp7, inp8, inp9, inp10,
                                  const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4,
                                  inp8, inp9, inp10, inp11,
                                  const20, const6, const3);

    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp6, res1, inp7, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp12, inp13);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5,
                                  inp9, inp10, inp11, inp12,
                                  const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6,
                                  inp10, inp11, inp12, inp13,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp8, res1, inp9, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp14, inp15);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7,
                                  inp11, inp12, inp13, inp14,
                                  const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8,
                                  inp12, inp13, inp14, inp15,
                                  const20, const6, const3);

    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp10, res1, inp11, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp16 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9,
                                  inp13, inp14, inp15, inp16,
                                  const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10,
                                  inp14, inp15, inp16, inp16,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp12, res1, inp13, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11,
                                  inp15, inp16, inp16, inp15,
                                  const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12,
                                  inp16, inp16, inp15, inp14,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp14, res1, inp15, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
}

static void vert_mc_qpel_avg_dst_8x8_msa(const uint8_t *src,
                                         int32_t src_stride,
                                         uint8_t *dst,
                                         int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 dst0, dst1, dst2, dst3;
    v16u8 res0, res1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    LD_UB2(src, src_stride, inp4, inp5);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2,
                                        inp1, inp2, inp3, inp4,
                                        inp1, inp0, inp0, inp1,
                                        inp2, inp3, inp4, inp5,
                                        const20, const6, const3);
    LD_UB2(src, src_stride, inp6, inp7);
    src += (2 * src_stride);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0,
                                        inp3, inp4, inp5, inp6,
                                        inp3, inp2, inp1, inp0,
                                        inp4, inp5, inp6, inp7,
                                        const20, const6, const3);
    LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
    dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1);
    dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3);
    AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
    dst += (4 * dst_stride);

    inp8 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1,
                                        inp5, inp6, inp7, inp8,
                                        inp5, inp4, inp3, inp2,
                                        inp6, inp7, inp8, inp8,
                                        const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3,
                                        inp7, inp8, inp8, inp7,
                                        inp7, inp6, inp5, inp4,
                                        inp8, inp8, inp7, inp6,
                                        const20, const6, const3);
    LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
    dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1);
    dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3);
    AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void vert_mc_qpel_avg_dst_16x16_msa(const uint8_t *src,
                                           int32_t src_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16;
    v16u8 res0, res1, dst0, dst1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4);
    src += (5 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2,
                                  inp1, inp2, inp3, inp4,
                                  const20, const6, const3);
    inp5 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1,
                                  inp2, inp3, inp4, inp5,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp6 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0,
                                  inp3, inp4, inp5, inp6,
                                  const20, const6, const3);
    inp7 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0,
                                  inp4, inp5, inp6, inp7,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp8 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1,
                                  inp5, inp6, inp7, inp8,
                                  const20, const6, const3);
    inp9 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2,
                                  inp6, inp7, inp8, inp9,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp10 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3,
                                  inp7, inp8, inp9, inp10,
                                  const20, const6, const3);
    inp11 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4,
                                  inp8, inp9, inp10, inp11,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp12 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5,
                                  inp9, inp10, inp11, inp12,
                                  const20, const6, const3);
    inp13 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6,
                                  inp10, inp11, inp12, inp13,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp14 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7,
                                  inp11, inp12, inp13, inp14,
                                  const20, const6, const3);
    inp15 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8,
                                  inp12, inp13, inp14, inp15,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp16 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9,
                                  inp13, inp14, inp15, inp16,
                                  const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10,
                                  inp14, inp15, inp16, inp16,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11,
                                  inp15, inp16, inp16, inp15,
                                  const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12,
                                  inp16, inp16, inp15, inp14,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
}

static void vert_mc_qpel_avg_dst_aver_src1_8x8_msa(const uint8_t *src,
                                                   int32_t src_stride,
                                                   uint8_t *dst,
                                                   int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 dst0, dst1, dst2, dst3;
    v16u8 tmp0, tmp1, res0, res1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    LD_UB2(src, src_stride, inp4, inp5);
    src += (2 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp0, inp0, inp1, inp2,
                                        inp1, inp2, inp3, inp4,
                                        inp1, inp0, inp0, inp1,
                                        inp2, inp3, inp4, inp5,
                                        const20, const6, const3);
    LD_UB2(src, src_stride, inp6, inp7);
    src += (2 * src_stride);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp2, inp1, inp0, inp0,
                                        inp3, inp4, inp5, inp6,
                                        inp3, inp2, inp1, inp0,
                                        inp4, inp5, inp6, inp7,
                                        const20, const6, const3);
    LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp1, 1, (v2i64) inp2);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp3, 1, (v2i64) inp4);
    dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1);
    dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3);
    AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1);
    AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
    dst += (4 * dst_stride);

    inp8 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(inp4, inp3, inp2, inp1,
                                        inp5, inp6, inp7, inp8,
                                        inp5, inp4, inp3, inp2,
                                        inp6, inp7, inp8, inp8,
                                        const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(inp6, inp5, inp4, inp3,
                                        inp7, inp8, inp8, inp7,
                                        inp7, inp6, inp5, inp4,
                                        inp8, inp8, inp7, inp6,
                                        const20, const6, const3);
    LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
    tmp0 = (v16u8) __msa_insve_d((v2i64) inp5, 1, (v2i64) inp6);
    tmp1 = (v16u8) __msa_insve_d((v2i64) inp7, 1, (v2i64) inp8);
    dst0 = (v16u8) __msa_insve_d((v2i64) dst0, 1, (v2i64) dst1);
    dst2 = (v16u8) __msa_insve_d((v2i64) dst2, 1, (v2i64) dst3);
    AVER_UB2_UB(res0, tmp0, res1, tmp1, res0, res1);
    AVER_UB2_UB(dst0, res0, dst2, res1, res0, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void vert_mc_qpel_avg_dst_aver_src1_16x16_msa(const uint8_t *src,
                                                     int32_t src_stride,
                                                     uint8_t *dst,
                                                     int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8;
    v16u8 inp9, inp10, inp11, inp12, inp13, inp14, inp15, inp16;
    v16u8 res0, res1, dst0, dst1;
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB5(src, src_stride, inp0, inp1, inp2, inp3, inp4);
    src += (5 * src_stride);
    res0 = APPLY_VERT_QPEL_FILTER(inp0, inp0, inp1, inp2,
                                  inp1, inp2, inp3, inp4,
                                  const20, const6, const3);
    inp5 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp1, inp0, inp0, inp1,
                                  inp2, inp3, inp4, inp5,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp1, res1, inp2, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp6 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp2, inp1, inp0, inp0,
                                  inp3, inp4, inp5, inp6,
                                  const20, const6, const3);
    inp7 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp3, inp2, inp1, inp0,
                                  inp4, inp5, inp6, inp7,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp3, res1, inp4, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp8 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp4, inp3, inp2, inp1,
                                  inp5, inp6, inp7, inp8,
                                  const20, const6, const3);
    inp9 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp5, inp4, inp3, inp2,
                                  inp6, inp7, inp8, inp9,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp5, res1, inp6, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp10 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp6, inp5, inp4, inp3,
                                  inp7, inp8, inp9, inp10,
                                  const20, const6, const3);
    inp11 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp7, inp6, inp5, inp4,
                                  inp8, inp9, inp10, inp11,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp7, res1, inp8, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp12 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp8, inp7, inp6, inp5,
                                  inp9, inp10, inp11, inp12,
                                  const20, const6, const3);
    inp13 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp9, inp8, inp7, inp6,
                                  inp10, inp11, inp12, inp13,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp9, res1, inp10, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp14 = LD_UB(src);
    src += src_stride;
    res0 = APPLY_VERT_QPEL_FILTER(inp10, inp9, inp8, inp7,
                                  inp11, inp12, inp13, inp14,
                                  const20, const6, const3);
    inp15 = LD_UB(src);
    src += src_stride;
    res1 = APPLY_VERT_QPEL_FILTER(inp11, inp10, inp9, inp8,
                                  inp12, inp13, inp14, inp15,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp11, res1, inp12, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp16 = LD_UB(src);
    res0 = APPLY_VERT_QPEL_FILTER(inp12, inp11, inp10, inp9,
                                  inp13, inp14, inp15, inp16,
                                  const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER(inp13, inp12, inp11, inp10,
                                  inp14, inp15, inp16, inp16,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp13, res1, inp14, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
    dst += (2 * dst_stride);

    res0 = APPLY_VERT_QPEL_FILTER(inp14, inp13, inp12, inp11,
                                  inp15, inp16, inp16, inp15,
                                  const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER(inp15, inp14, inp13, inp12,
                                  inp16, inp16, inp15, inp14,
                                  const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    AVER_UB2_UB(res0, inp15, res1, inp16, res0, res1);
    AVER_UB2_UB(res0, dst0, res1, dst1, res0, res1);
    ST_UB2(res0, res1, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_horiz_src0_16x16_msa(const uint8_t *src,
                                                   int32_t src_stride,
                                                   uint8_t *dst,
                                                   int32_t dst_stride,
                                                   int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(inp0, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(inp2, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(inp4, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(inp6, res);
        ST_UB(res, dst);
        dst += dst_stride;
    }

    LD_UB2(src, 1, inp0, inp1);
    res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask,
                                           const20, const6, const3);
    res = __msa_ave_u_b(inp0, res);
    ST_UB(res, dst);
}

static void hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa(const uint8_t *src,
                                                      int32_t src_stride,
                                                      uint8_t *dst,
                                                      int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_no_rnd_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_no_rnd_aver_src0_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa(const uint8_t *src,
                                                    int32_t src_stride,
                                                    uint8_t *dst,
                                                    int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_ave_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_ave_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_ave_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                                 horiz1, horiz2, horiz3, horiz4,
                                                 horiz1, horiz0, horiz0, horiz1,
                                                 horiz2, horiz3, horiz4, horiz5,
                                                 const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0);
    res0 = __msa_ave_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_ave_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1,
                                                       mask2, mask3, const20,
                                                       const6, const3);
    horiz8 = __msa_ave_u_b(inp0, res0);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                                 horiz3, horiz4, horiz5, horiz6,
                                                 horiz3, horiz2, horiz1, horiz0,
                                                 horiz4, horiz5, horiz6, horiz7,
                                                 const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2);
    res1 = __msa_ave_u_b(avg1, res1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                                 horiz5, horiz6, horiz7, horiz8,
                                                 horiz5, horiz4, horiz3, horiz2,
                                                 horiz6, horiz7, horiz8, horiz8,
                                                 const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4);
    res0 = __msa_ave_u_b(avg0, res0);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                                 horiz7, horiz8, horiz8, horiz7,
                                                 horiz7, horiz6, horiz5, horiz4,
                                                 horiz8, horiz8, horiz7, horiz6,
                                                 const20, const6, const3);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6);
    res1 = __msa_ave_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_horiz_16x16_msa(const uint8_t *src,
                                              int32_t src_stride,
                                              uint8_t *dst,
                                              int32_t dst_stride,
                                              int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask,
                                               const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask,
                                               const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask,
                                               const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask,
                                               const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;
    }

    LD_UB2(src, 1, inp0, inp1);
    res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask,
                                           const20, const6, const3);
    ST_UB(res, dst);
}

static void hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa(const uint8_t *src,
                                                    int32_t src_stride,
                                                    uint8_t *dst,
                                                    int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_no_rnd_horiz_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_no_rnd_aver_src0_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa(const uint8_t *src,
                                                  int32_t src_stride,
                                                  uint8_t *dst,
                                                  int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz2 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz4 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                                 horiz1, horiz2, horiz3, horiz4,
                                                 horiz1, horiz0, horiz0, horiz1,
                                                 horiz2, horiz3, horiz4, horiz5,
                                                 const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0);
    res0 = __msa_ave_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz6 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    inp0 = LD_UB(src);
    horiz8 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1,
                                                         mask2, mask3, const20,
                                                         const6, const3);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                                 horiz3, horiz4, horiz5, horiz6,
                                                 horiz3, horiz2, horiz1, horiz0,
                                                 horiz4, horiz5, horiz6, horiz7,
                                                 const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2);
    res1 = __msa_ave_u_b(avg1, res1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0);
    res0 = __msa_ave_u_b(avg0, res0);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                                 horiz5, horiz6, horiz7, horiz8,
                                                 horiz5, horiz4, horiz3, horiz2,
                                                 horiz6, horiz7, horiz8, horiz8,
                                                 const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4);
    res0 = __msa_ave_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                                 horiz7, horiz8, horiz8, horiz7,
                                                 horiz7, horiz6, horiz5, horiz4,
                                                 horiz8, horiz8, horiz7, horiz6,
                                                 const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6);
    res1 = __msa_ave_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_horiz_src1_16x16_msa(const uint8_t *src,
                                                   int32_t src_stride,
                                                   uint8_t *dst,
                                                   int32_t dst_stride,
                                                   int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(res, inp1);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp2, inp3, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(res, inp3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp4, inp5, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(res, inp5);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp6, inp7, mask,
                                               const20, const6, const3);
        res = __msa_ave_u_b(res, inp7);
        ST_UB(res, dst);
        dst += dst_stride;
    }

    LD_UB2(src, 1, inp0, inp1);
    res = APPLY_HORIZ_QPEL_NO_ROUND_FILTER(inp0, inp1, mask,
                                           const20, const6, const3);
    res = __msa_ave_u_b(inp1, res);
    ST_UB(res, dst);
}

static void hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa(const uint8_t *src,
                                                      int32_t src_stride,
                                                      uint8_t *dst,
                                                      int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_no_rnd_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_no_rnd_aver_src0_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa(const uint8_t *src,
                                                    int32_t src_stride,
                                                    uint8_t *dst,
                                                    int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz0 = __msa_ave_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz2 = __msa_ave_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz4 = __msa_ave_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                                 horiz1, horiz2, horiz3, horiz4,
                                                 horiz1, horiz0, horiz0, horiz1,
                                                 horiz2, horiz3, horiz4, horiz5,
                                                 const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0);
    res0 = __msa_ave_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz6 = __msa_ave_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1,
                                                       mask2, mask3, const20,
                                                       const6, const3);
    inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1);
    horiz8 = __msa_ave_u_b(inp0, res0);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                                 horiz3, horiz4, horiz5, horiz6,
                                                 horiz3, horiz2, horiz1, horiz0,
                                                 horiz4, horiz5, horiz6, horiz7,
                                                 const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2);
    res1 = __msa_ave_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                                 horiz5, horiz6, horiz7, horiz8,
                                                 horiz5, horiz4, horiz3, horiz2,
                                                 horiz6, horiz7, horiz8, horiz8,
                                                 const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4);
    res0 = __msa_ave_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                                 horiz7, horiz8, horiz8, horiz7,
                                                 horiz7, horiz6, horiz5, horiz4,
                                                 horiz8, horiz8, horiz7, horiz6,
                                                 const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6);
    res1 = __msa_ave_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa(const uint8_t *src,
                                                    int32_t src_stride,
                                                    uint8_t *dst,
                                                    int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_no_rnd_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_no_rnd_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa(const uint8_t *src,
                                                  int32_t src_stride,
                                                  uint8_t *dst,
                                                  int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_ave_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_ave_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_ave_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                                 horiz1, horiz2, horiz3, horiz4,
                                                 horiz1, horiz0, horiz0, horiz1,
                                                 horiz2, horiz3, horiz4, horiz5,
                                                 const20, const6, const3);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_ave_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1,
                                                       mask2, mask3, const20,
                                                       const6, const3);
    horiz8 = __msa_ave_u_b(inp0, res0);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                                 horiz3, horiz4, horiz5, horiz6,
                                                 horiz3, horiz2, horiz1, horiz0,
                                                 horiz4, horiz5, horiz6, horiz7,
                                                 const20, const6, const3);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                                 horiz5, horiz6, horiz7, horiz8,
                                                 horiz5, horiz4, horiz3, horiz2,
                                                 horiz6, horiz7, horiz8, horiz8,
                                                 const20, const6, const3);
    ST_D4(res1, res0, 0, 1, 0, 1, dst, dst_stride);
    dst += (4 * dst_stride);

    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                                 horiz7, horiz8, horiz8, horiz7,
                                                 horiz7, horiz6, horiz5, horiz4,
                                                 horiz8, horiz8, horiz7, horiz6,
                                                 const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_16x16_msa(const uint8_t *src,
                                        int32_t src_stride,
                                        uint8_t *dst,
                                        int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_no_rnd_horiz_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_no_rnd_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_8x8_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz2 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz4 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                                 horiz1, horiz2, horiz3, horiz4,
                                                 horiz1, horiz0, horiz0, horiz1,
                                                 horiz2, horiz3, horiz4, horiz5,
                                                 const20, const6, const3);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    horiz6 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    inp0 = LD_UB(src);
    horiz8 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1,
                                                         mask2, mask3, const20,
                                                         const6, const3);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                                 horiz3, horiz4, horiz5, horiz6,
                                                 horiz3, horiz2, horiz1, horiz0,
                                                 horiz4, horiz5, horiz6, horiz7,
                                                 const20, const6, const3);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                                 horiz5, horiz6, horiz7, horiz8,
                                                 horiz5, horiz4, horiz3, horiz2,
                                                 horiz6, horiz7, horiz8, horiz8,
                                                 const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;


    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                                 horiz7, horiz8, horiz8, horiz7,
                                                 horiz7, horiz6, horiz5, horiz4,
                                                 horiz8, horiz8, horiz7, horiz6,
                                                 const20, const6, const3);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa(const uint8_t *src,
                                                    int32_t src_stride,
                                                    uint8_t *dst,
                                                    int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_no_rnd_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_no_rnd_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa(const uint8_t *src,
                                                  int32_t src_stride,
                                                  uint8_t *dst,
                                                  int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz0 = __msa_ave_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz2 = __msa_ave_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz4 = __msa_ave_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                                 horiz1, horiz2, horiz3, horiz4,
                                                 horiz1, horiz0, horiz0, horiz1,
                                                 horiz2, horiz3, horiz4, horiz5,
                                                 const20, const6, const3);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz6 = __msa_ave_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1,
                                                       mask2, mask3, const20,
                                                       const6, const3);
    inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1);
    horiz8 = __msa_ave_u_b(inp0, res0);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                                 horiz3, horiz4, horiz5, horiz6,
                                                 horiz3, horiz2, horiz1, horiz0,
                                                 horiz4, horiz5, horiz6, horiz7,
                                                 const20, const6, const3);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                                 horiz5, horiz6, horiz7, horiz8,
                                                 horiz5, horiz4, horiz3, horiz2,
                                                 horiz6, horiz7, horiz8, horiz8,
                                                 const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                                 horiz7, horiz8, horiz8, horiz7,
                                                 horiz7, horiz6, horiz5, horiz4,
                                                 horiz8, horiz8, horiz7, horiz6,
                                                 const20, const6, const3);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa(const uint8_t *src,
                                                      int32_t src_stride,
                                                      uint8_t *dst,
                                                      int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_no_rnd_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_no_rnd_aver_src1_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa(const uint8_t *src,
                                                    int32_t src_stride,
                                                    uint8_t *dst,
                                                    int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_ave_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_ave_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_ave_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                                 horiz1, horiz2, horiz3, horiz4,
                                                 horiz1, horiz0, horiz0, horiz1,
                                                 horiz2, horiz3, horiz4, horiz5,
                                                 const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1);
    res0 = __msa_ave_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_ave_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1,
                                                       mask2, mask3, const20,
                                                       const6, const3);
    horiz8 = __msa_ave_u_b(inp0, res0);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                                 horiz3, horiz4, horiz5, horiz6,
                                                 horiz3, horiz2, horiz1, horiz0,
                                                 horiz4, horiz5, horiz6, horiz7,
                                                 const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3);
    res1 = __msa_ave_u_b(avg1, res1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                                 horiz5, horiz6, horiz7, horiz8,
                                                 horiz5, horiz4, horiz3, horiz2,
                                                 horiz6, horiz7, horiz8, horiz8,
                                                 const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5);
    res0 = __msa_ave_u_b(avg0, res0);

    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                                 horiz7, horiz8, horiz8, horiz7,
                                                 horiz7, horiz6, horiz5, horiz4,
                                                 horiz8, horiz8, horiz7, horiz6,
                                                 const20, const6, const3);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7);
    res1 = __msa_ave_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa(const uint8_t *src,
                                                    int32_t src_stride,
                                                    uint8_t *dst,
                                                    int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_no_rnd_horiz_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_no_rnd_aver_src1_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa(const uint8_t *src,
                                                  int32_t src_stride,
                                                  uint8_t *dst,
                                                  int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz2 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz4 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                                 horiz1, horiz2, horiz3, horiz4,
                                                 horiz1, horiz0, horiz0, horiz1,
                                                 horiz2, horiz3, horiz4, horiz5,
                                                 const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1);
    res0 = __msa_ave_u_b(avg0, res0);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    horiz6 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                    mask2, mask3, const20,
                                                    const6, const3);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                                 horiz3, horiz4, horiz5, horiz6,
                                                 horiz3, horiz2, horiz1, horiz0,
                                                 horiz4, horiz5, horiz6, horiz7,
                                                 const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3);
    res1 = __msa_ave_u_b(avg1, res1);
    inp0 = LD_UB(src);
    horiz8 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1,
                                                         mask2, mask3, const20,
                                                         const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                                 horiz5, horiz6, horiz7, horiz8,
                                                 horiz5, horiz4, horiz3, horiz2,
                                                 horiz6, horiz7, horiz8, horiz8,
                                                 const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5);
    res0 = __msa_ave_u_b(avg0, res0);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                                 horiz7, horiz8, horiz8, horiz7,
                                                 horiz7, horiz6, horiz5, horiz4,
                                                 horiz8, horiz8, horiz7, horiz6,
                                                 const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7);
    res1 = __msa_ave_u_b(avg1, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa(const uint8_t *src,
                                                      int32_t src_stride,
                                                      uint8_t *dst,
                                                      int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_no_rnd_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_no_rnd_aver_src1_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa(const uint8_t *src,
                                                    int32_t src_stride,
                                                    uint8_t *dst,
                                                    int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz0 = __msa_ave_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz2 = __msa_ave_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp0, inp1, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);

    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);
    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz4 = __msa_ave_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                                 horiz1, horiz2, horiz3, horiz4,
                                                 horiz1, horiz0, horiz0, horiz1,
                                                 horiz2, horiz3, horiz4, horiz5,
                                                 const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1);
    res0 = __msa_ave_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE(inp2, inp3, mask0, mask1,
                                                  mask2, mask3, const20,
                                                  const6, const3);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz6 = __msa_ave_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                                 horiz3, horiz4, horiz5, horiz6,
                                                 horiz3, horiz2, horiz1, horiz0,
                                                 horiz4, horiz5, horiz6, horiz7,
                                                 const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3);
    res1 = __msa_ave_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_NO_ROUND_FILTER_8BYTE_1ROW(inp0, mask0, mask1,
                                                       mask2, mask3, const20,
                                                       const6, const3);
    inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1);
    horiz8 = __msa_ave_u_b(inp0, res0);
    res0 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                                 horiz5, horiz6, horiz7, horiz8,
                                                 horiz5, horiz4, horiz3, horiz2,
                                                 horiz6, horiz7, horiz8, horiz8,
                                                 const20, const6, const3);
    res1 = APPLY_VERT_QPEL_NO_ROUND_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                                 horiz7, horiz8, horiz8, horiz7,
                                                 horiz7, horiz6, horiz5, horiz4,
                                                 horiz8, horiz8, horiz7, horiz6,
                                                 const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5);
    res0 = __msa_ave_u_b(avg0, res0);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7);
    res1 = __msa_ave_u_b(avg1, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_aver_horiz_src0_16x16_msa(const uint8_t *src,
                                                 int32_t src_stride,
                                                 uint8_t *dst,
                                                 int32_t dst_stride,
                                                 int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(inp0, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(inp2, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(inp4, res);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(inp6, res);
        ST_UB(res, dst);
        dst += dst_stride;
    }

    LD_UB2(src, 1, inp0, inp1);
    res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, const20, const6, const3);
    res = __msa_aver_u_b(inp0, res);
    ST_UB(res, dst);
}

static void hv_mc_qpel_aver_hv_src00_16x16_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_aver_src0_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_aver_hv_src00_8x8_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2);
    res1 = __msa_aver_u_b(avg1, res1);

    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    horiz8 = __msa_aver_u_b(inp0, res0);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4);
    res0 = __msa_aver_u_b(avg0, res0);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_aver_horiz_16x16_msa(const uint8_t *src,
                                            int32_t src_stride,
                                            uint8_t *dst,
                                            int32_t dst_stride,
                                            int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask,
                                      const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask,
                                      const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask,
                                      const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask,
                                      const20, const6, const3);
        ST_UB(res, dst);
        dst += dst_stride;
    }

    LD_UB2(src, 1, inp0, inp1);
    res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, const20, const6, const3);
    ST_UB(res, dst);
}

static void hv_mc_qpel_aver_v_src0_16x16_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_aver_src0_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_aver_v_src0_8x8_msa(const uint8_t *src,
                                           int32_t src_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    inp0 = LD_UB(src);
    horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0,
                                                mask0, mask1, mask2, mask3,
                                                const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2);
    res1 = __msa_aver_u_b(avg1, res1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4);
    res0 = __msa_aver_u_b(avg0, res0);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_aver_horiz_src1_16x16_msa(const uint8_t *src,
                                                 int32_t src_stride,
                                                 uint8_t *dst,
                                                 int32_t dst_stride,
                                                 int32_t height)
{
    uint8_t loop_count;
    v16u8 inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7;
    v16u8 res;
    v16u8 mask = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);
    v8u16 const20 = (v8u16) __msa_ldi_h(20);

    for (loop_count = (height >> 2); loop_count--;) {
        LD_UB4(src, src_stride, inp0, inp2, inp4, inp6);
        LD_UB4((src + 1), src_stride, inp1, inp3, inp5, inp7);
        src += (4 * src_stride);
        res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(res, inp1);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp2, inp3, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(res, inp3);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp4, inp5, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(res, inp5);
        ST_UB(res, dst);
        dst += dst_stride;

        res = APPLY_HORIZ_QPEL_FILTER(inp6, inp7, mask,
                                      const20, const6, const3);
        res = __msa_aver_u_b(res, inp7);
        ST_UB(res, dst);
        dst += dst_stride;
    }

    LD_UB2(src, 1, inp0, inp1);
    res = APPLY_HORIZ_QPEL_FILTER(inp0, inp1, mask, const20, const6, const3);
    res = __msa_aver_u_b(inp1, res);
    ST_UB(res, dst);
}

static void hv_mc_qpel_aver_hv_src10_16x16_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_aver_src0_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_aver_hv_src10_8x8_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0);
    res0 = __msa_aver_u_b(avg0, res0);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2);
    res1 = __msa_aver_u_b(avg1, res1);
    inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1);
    horiz8 = __msa_aver_u_b(inp0, res0);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4);
    res0 = __msa_aver_u_b(avg0, res0);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_aver_h_src0_16x16_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_aver_h_src0_8x8_msa(const uint8_t *src,
                                           int32_t src_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    horiz8 = __msa_aver_u_b(inp0, res0);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_16x16_msa(const uint8_t *src,
                                 int32_t src_stride,
                                 uint8_t *dst,
                                 int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_8x8_msa(const uint8_t *src, int32_t src_stride,
                               uint8_t *dst, int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    inp0 = LD_UB(src);
    horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0,
                                                mask0, mask1, mask2, mask3,
                                                const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_aver_h_src1_16x16_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_aver_h_src1_8x8_msa(const uint8_t *src,
                                           int32_t src_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);

    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1);
    horiz8 = __msa_aver_u_b(inp0, res0);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
    dst += (4 * dst_stride);

    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_aver_hv_src01_16x16_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_aver_src1_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_aver_hv_src01_8x8_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);

    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);

    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_insve_d((v2i64) horiz1, 1, (v2i64) horiz2);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    horiz8 = __msa_aver_u_b(inp0, res0);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_insve_d((v2i64) horiz3, 1, (v2i64) horiz4);
    res1 = __msa_aver_u_b(avg1, res1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    avg0 = (v16u8) __msa_insve_d((v2i64) horiz5, 1, (v2i64) horiz6);
    res0 = __msa_aver_u_b(avg0, res0);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_insve_d((v2i64) horiz7, 1, (v2i64) horiz8);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_aver_v_src1_16x16_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst,
                                             int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_aver_src1_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_aver_v_src1_8x8_msa(const uint8_t *src,
                                           int32_t src_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_insve_d((v2i64) horiz1, 1, (v2i64) horiz2);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    inp0 = LD_UB(src);
    horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0,
                                                mask0, mask1, mask2, mask3,
                                                const20, const6, const3);
    avg1 = (v16u8) __msa_insve_d((v2i64) horiz3, 1, (v2i64) horiz4);
    res1 = __msa_aver_u_b(avg1, res1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;
    avg0 = (v16u8) __msa_insve_d((v2i64) horiz5, 1, (v2i64) horiz6);
    res0 = __msa_aver_u_b(avg0, res0);

    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_insve_d((v2i64) horiz7, 1, (v2i64) horiz8);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_aver_hv_src11_16x16_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_aver_src1_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_aver_hv_src11_8x8_msa(const uint8_t *src,
                                             int32_t src_stride,
                                             uint8_t *dst, int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB4(src, src_stride, inp0, inp1, inp2, inp3);
    src += (4 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                         mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_insve_d((v2i64) inp0, 1, (v2i64) inp1);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1);
    res0 = __msa_aver_u_b(avg0, res0);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_insve_d((v2i64) inp2, 1, (v2i64) inp3);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3);
    res1 = __msa_aver_u_b(avg1, res1);
    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1);
    horiz8 = __msa_aver_u_b(inp0, res0);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += 2 * dst_stride;

    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5);
    res0 = __msa_aver_u_b(avg0, res0);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D4(res0, res1, 0, 1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa(const uint8_t *src,
                                                       int32_t src_stride,
                                                       uint8_t *dst,
                                                       int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_avg_dst_aver_src0_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa(const uint8_t *src,
                                                     int32_t src_stride,
                                                     uint8_t *dst,
                                                     int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 dst0, dst1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    res0 = __msa_aver_u_b(avg0, res0);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    res1 = __msa_aver_u_b(avg1, res1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    horiz8 = __msa_aver_u_b(inp0, res0);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    res0 = __msa_aver_u_b(avg0, res0);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    res1 = __msa_aver_u_b(avg1, res1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa(const uint8_t *src,
                                                     int32_t src_stride,
                                                     uint8_t *dst,
                                                     int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_avg_dst_aver_src0_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa(const uint8_t *src,
                                                   int32_t src_stride,
                                                   uint8_t *dst,
                                                   int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 dst0, dst1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    res0 = __msa_aver_u_b(avg0, res0);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    res1 = __msa_aver_u_b(avg1, res1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp0 = LD_UB(src);
    horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0,
                                                mask0, mask1, mask2, mask3,
                                                const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    res0 = __msa_aver_u_b(avg0, res0);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    res1 = __msa_aver_u_b(avg1, res1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa(const uint8_t *src,
                                                       int32_t src_stride,
                                                       uint8_t *dst,
                                                       int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_avg_dst_aver_src0_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa(const uint8_t *src,
                                                     int32_t src_stride,
                                                     uint8_t *dst,
                                                     int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 dst0, dst1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);

    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz1, (v2i64) horiz0);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    res0 = __msa_aver_u_b(avg0, res0);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);

    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz3, (v2i64) horiz2);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    res1 = __msa_aver_u_b(avg1, res1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1);
    horiz8 = __msa_aver_u_b(inp0, res0);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz5, (v2i64) horiz4);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    res0 = __msa_aver_u_b(avg0, res0);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz7, (v2i64) horiz6);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    res1 = __msa_aver_u_b(avg1, res1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa(const uint8_t *src,
                                                     int32_t src_stride,
                                                     uint8_t *dst,
                                                     int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_avg_dst_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa(const uint8_t *src,
                                                   int32_t src_stride,
                                                   uint8_t *dst,
                                                   int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 dst0, dst1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    horiz8 = __msa_aver_u_b(inp0, res0);
    LD_UB2(dst, dst_stride, dst0, dst1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_16x16_msa(const uint8_t *src, int32_t src_stride,
                                         uint8_t *dst, int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_avg_dst_16x16_msa(buff, 16, dst, dst_stride);

}

static void hv_mc_qpel_avg_dst_8x8_msa(const uint8_t *src, int32_t src_stride,
                                       uint8_t *dst, int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 dst0, dst1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    inp0 = LD_UB(src);
    horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0,
                                                mask0, mask1, mask2, mask3,
                                                const20, const6, const3);
    LD_UB2(dst, dst_stride, dst0, dst1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa(const uint8_t *src,
                                                     int32_t src_stride,
                                                     uint8_t *dst,
                                                     int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_avg_dst_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa(const uint8_t *src,
                                                   int32_t src_stride,
                                                   uint8_t *dst,
                                                   int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 dst0, dst1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);

    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);

    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1);
    horiz8 = __msa_aver_u_b(inp0, res0);
    LD_UB2(dst, dst_stride, dst0, dst1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa(const uint8_t *src,
                                                       int32_t src_stride,
                                                       uint8_t *dst,
                                                       int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src0_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_avg_dst_aver_src1_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa(const uint8_t *src,
                                                     int32_t src_stride,
                                                     uint8_t *dst,
                                                     int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 dst0, dst1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);

    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1);
    res0 = __msa_aver_u_b(avg0, res0);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3);
    res1 = __msa_aver_u_b(avg1, res1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    horiz8 = __msa_aver_u_b(inp0, res0);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1,
                                        horiz5, horiz6, horiz7, horiz8,
                                        horiz5, horiz4, horiz3, horiz2,
                                        horiz6, horiz7, horiz8, horiz8,
                                        const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3,
                                        horiz7, horiz8, horiz8, horiz7,
                                        horiz7, horiz6, horiz5, horiz4,
                                        horiz8, horiz8, horiz7, horiz6,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5);
    res0 = __msa_aver_u_b(avg0, res0);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7);
    res1 = __msa_aver_u_b(avg1, res1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa(const uint8_t *src,
                                                     int32_t src_stride,
                                                     uint8_t *dst,
                                                     int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_avg_dst_aver_src1_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa(const uint8_t *src,
                                                   int32_t src_stride,
                                                   uint8_t *dst,
                                                   int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 dst0, dst1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz2 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    horiz4 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2,
                                        horiz1, horiz2, horiz3, horiz4,
                                        horiz1, horiz0, horiz0, horiz1,
                                        horiz2, horiz3, horiz4, horiz5,
                                        const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1);
    res0 = __msa_aver_u_b(avg0, res0);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    horiz6 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3,
                                           mask0, mask1, mask2, mask3,
                                           const20, const6, const3);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0,
                                        horiz3, horiz4, horiz5, horiz6,
                                        horiz3, horiz2, horiz1, horiz0,
                                        horiz4, horiz5, horiz6, horiz7,
                                        const20, const6, const3);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3);
    res1 = __msa_aver_u_b(avg1, res1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp0 = LD_UB(src);
    horiz8 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0,
                                                mask0, mask1, mask2, mask3,
                                                const20, const6, const3);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, horiz5,
                                        horiz6, horiz7, horiz8, horiz5, horiz4,
                                        horiz3, horiz2, horiz6, horiz7, horiz8,
                                        horiz8, const20, const6, const3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, horiz7,
                                        horiz8, horiz8, horiz7, horiz7, horiz6,
                                        horiz5, horiz4, horiz8, horiz8, horiz7,
                                        horiz6, const20, const6, const3);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5);
    res0 = __msa_aver_u_b(avg0, res0);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7);
    res1 = __msa_aver_u_b(avg1, res1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa(const uint8_t *src,
                                                       int32_t src_stride,
                                                       uint8_t *dst,
                                                       int32_t dst_stride)
{
    uint8_t buff[272];

    hv_mc_qpel_aver_horiz_src1_16x16_msa(src, src_stride, buff, 16, 16);
    vert_mc_qpel_avg_dst_aver_src1_16x16_msa(buff, 16, dst, dst_stride);
}

static void hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa(const uint8_t *src,
                                                     int32_t src_stride,
                                                     uint8_t *dst,
                                                     int32_t dst_stride)
{
    v16u8 inp0, inp1, inp2, inp3;
    v16u8 res0, res1, avg0, avg1;
    v16u8 horiz0, horiz1, horiz2, horiz3;
    v16u8 horiz4, horiz5, horiz6, horiz7, horiz8;
    v16u8 dst0, dst1;
    v16u8 mask0 = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
    v16u8 mask1 = { 0, 2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8 };
    v16u8 mask2 = { 1, 3, 0, 4, 0, 5, 1, 6, 2, 7, 3, 8, 4, 8, 5, 7 };
    v16u8 mask3 = { 2, 4, 1, 5, 0, 6, 0, 7, 1, 8, 2, 8, 3, 7, 4, 6 };
    v16u8 const20 = (v16u8) __msa_ldi_b(20);
    v16u8 const6 = (v16u8) __msa_ldi_b(6);
    v16u8 const3 = (v16u8) __msa_ldi_b(3);

    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz0 = __msa_aver_u_b(inp0, res0);
    horiz1 = (v16u8) __msa_splati_d((v2i64) horiz0, 1);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    LD_UB2(src, src_stride, inp0, inp1);
    src += (2 * src_stride);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz2 = __msa_aver_u_b(inp2, res1);
    horiz3 = (v16u8) __msa_splati_d((v2i64) horiz2, 1);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp0, inp1, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    SLDI_B2_UB(inp0, inp0, inp1, inp1, 1, inp0, inp1);

    inp0 = (v16u8) __msa_ilvr_d((v2i64) inp1, (v2i64) inp0);
    horiz4 = __msa_aver_u_b(inp0, res0);
    horiz5 = (v16u8) __msa_splati_d((v2i64) horiz4, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz2, (v2i64) horiz1);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz0, horiz0, horiz1, horiz2, horiz1,
                                        horiz2, horiz3, horiz4, horiz1, horiz0,
                                        horiz0, horiz1, horiz2, horiz3, horiz4,
                                        horiz5, const20, const6, const3);
    res0 = __msa_aver_u_b(avg0, res0);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(src, src_stride, inp2, inp3);
    src += (2 * src_stride);
    res1 = APPLY_HORIZ_QPEL_FILTER_8BYTE(inp2, inp3, mask0, mask1, mask2, mask3,
                                         const20, const6, const3);
    SLDI_B2_UB(inp2, inp2, inp3, inp3, 1, inp2, inp3);

    inp2 = (v16u8) __msa_ilvr_d((v2i64) inp3, (v2i64) inp2);
    horiz6 = __msa_aver_u_b(inp2, res1);
    horiz7 = (v16u8) __msa_splati_d((v2i64) horiz6, 1);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz4, (v2i64) horiz3);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz2, horiz1, horiz0, horiz0, horiz3,
                                        horiz4, horiz5, horiz6, horiz3, horiz2,
                                        horiz1, horiz0, horiz4, horiz5, horiz6,
                                        horiz7, const20, const6, const3);
    res1 = __msa_aver_u_b(avg1, res1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    inp0 = LD_UB(src);
    res0 = APPLY_HORIZ_QPEL_FILTER_8BYTE_1ROW(inp0, mask0, mask1, mask2, mask3,
                                              const20, const6, const3);
    inp0 = (v16u8) __msa_sldi_b((v16i8) inp0, (v16i8) inp0, 1);
    horiz8 = __msa_aver_u_b(inp0, res0);
    LD_UB2(dst, dst_stride, dst0, dst1);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) horiz6, (v2i64) horiz5);
    res0 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz4, horiz3, horiz2, horiz1, horiz5,
                                        horiz6, horiz7, horiz8, horiz5, horiz4,
                                        horiz3, horiz2, horiz6, horiz7, horiz8,
                                        horiz8, const20, const6, const3);
    res0 = __msa_aver_u_b(avg0, res0);
    avg0 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res0 = __msa_aver_u_b(avg0, res0);
    ST_D2(res0, 0, 1, dst, dst_stride);
    dst += (2 * dst_stride);

    LD_UB2(dst, dst_stride, dst0, dst1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) horiz8, (v2i64) horiz7);
    res1 = APPLY_VERT_QPEL_FILTER_8BYTE(horiz6, horiz5, horiz4, horiz3, horiz7,
                                        horiz8, horiz8, horiz7, horiz7, horiz6,
                                        horiz5, horiz4, horiz8, horiz8, horiz7,
                                        horiz6, const20, const6, const3);
    res1 = __msa_aver_u_b(avg1, res1);
    avg1 = (v16u8) __msa_ilvr_d((v2i64) dst1, (v2i64) dst0);
    res1 = __msa_aver_u_b(avg1, res1);
    ST_D2(res1, 0, 1, dst, dst_stride);
}

static void copy_8x8_msa(const uint8_t *src, int32_t src_stride,
                         uint8_t *dst, int32_t dst_stride)
{
    uint64_t src0, src1;
    int32_t loop_cnt;

    for (loop_cnt = 4; loop_cnt--;) {
        src0 = LD(src);
        src += src_stride;
        src1 = LD(src);
        src += src_stride;

        SD(src0, dst);
        dst += dst_stride;
        SD(src1, dst);
        dst += dst_stride;
    }
}

static void copy_16x16_msa(const uint8_t *src, int32_t src_stride,
                           uint8_t *dst, int32_t dst_stride)
{
    v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
    v16u8 src8, src9, src10, src11, src12, src13, src14, src15;

    LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
    src += (8 * src_stride);
    LD_UB8(src, src_stride,
           src8, src9, src10, src11, src12, src13, src14, src15);

    ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7, dst, dst_stride);
    dst += (8 * dst_stride);
    ST_UB8(src8, src9, src10, src11, src12, src13, src14, src15,
           dst, dst_stride);
}

static void avg_width8_msa(const uint8_t *src, int32_t src_stride,
                           uint8_t *dst, int32_t dst_stride,
                           int32_t height)
{
    int32_t cnt;
    uint64_t out0, out1, out2, out3;
    v16u8 src0, src1, src2, src3;
    v16u8 dst0, dst1, dst2, dst3;

    for (cnt = (height / 4); cnt--;) {
        LD_UB4(src, src_stride, src0, src1, src2, src3);
        src += (4 * src_stride);
        LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);

        AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3,
                    dst0, dst1, dst2, dst3);

        out0 = __msa_copy_u_d((v2i64) dst0, 0);
        out1 = __msa_copy_u_d((v2i64) dst1, 0);
        out2 = __msa_copy_u_d((v2i64) dst2, 0);
        out3 = __msa_copy_u_d((v2i64) dst3, 0);
        SD4(out0, out1, out2, out3, dst, dst_stride);
        dst += (4 * dst_stride);
    }
}

static void avg_width16_msa(const uint8_t *src, int32_t src_stride,
                            uint8_t *dst, int32_t dst_stride,
                            int32_t height)
{
    int32_t cnt;
    v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
    v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7;

    for (cnt = (height / 8); cnt--;) {
        LD_UB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
        src += (8 * src_stride);
        LD_UB8(dst, dst_stride, dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7);

        AVER_UB4_UB(src0, dst0, src1, dst1, src2, dst2, src3, dst3,
                    dst0, dst1, dst2, dst3);
        AVER_UB4_UB(src4, dst4, src5, dst5, src6, dst6, src7, dst7,
                    dst4, dst5, dst6, dst7);
        ST_UB8(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst, dst_stride);
        dst += (8 * dst_stride);
    }
}

void ff_copy_16x16_msa(uint8_t *dest, const uint8_t *src, ptrdiff_t stride)
{
    copy_16x16_msa(src, stride, dest, stride);
}

void ff_copy_8x8_msa(uint8_t *dest, const uint8_t *src, ptrdiff_t stride)
{
    copy_8x8_msa(src, stride, dest, stride);
}

void ff_horiz_mc_qpel_aver_src0_8width_msa(uint8_t *dest,
                                           const uint8_t *src,
                                           ptrdiff_t stride)
{
    horiz_mc_qpel_aver_src0_8width_msa(src, stride, dest, stride, 8);
}

void ff_horiz_mc_qpel_aver_src0_16width_msa(uint8_t *dest,
                                            const uint8_t *src,
                                            ptrdiff_t stride)
{
    horiz_mc_qpel_aver_src0_16width_msa(src, stride, dest, stride, 16);
}

void ff_horiz_mc_qpel_8width_msa(uint8_t *dest, const uint8_t *src,
                                 ptrdiff_t stride)
{
    horiz_mc_qpel_8width_msa(src, stride, dest, stride, 8);
}

void ff_horiz_mc_qpel_16width_msa(uint8_t *dest,
                                  const uint8_t *src, ptrdiff_t stride)
{
    horiz_mc_qpel_16width_msa(src, stride, dest, stride, 16);
}

void ff_horiz_mc_qpel_aver_src1_8width_msa(uint8_t *dest,
                                           const uint8_t *src,
                                           ptrdiff_t stride)
{
    horiz_mc_qpel_aver_src1_8width_msa(src, stride, dest, stride, 8);
}

void ff_horiz_mc_qpel_aver_src1_16width_msa(uint8_t *dest,
                                            const uint8_t *src,
                                            ptrdiff_t stride)
{
    horiz_mc_qpel_aver_src1_16width_msa(src, stride, dest, stride, 16);
}

void ff_horiz_mc_qpel_no_rnd_aver_src0_8width_msa(uint8_t *dest,
                                                  const uint8_t *src,
                                                  ptrdiff_t stride)
{
    horiz_mc_qpel_no_rnd_aver_src0_8width_msa(src, stride, dest, stride, 8);
}

void ff_horiz_mc_qpel_no_rnd_aver_src0_16width_msa(uint8_t *dest,
                                                   const uint8_t *src,
                                                   ptrdiff_t stride)
{
    horiz_mc_qpel_no_rnd_aver_src0_16width_msa(src, stride, dest, stride, 16);
}

void ff_horiz_mc_qpel_no_rnd_8width_msa(uint8_t *dest,
                                        const uint8_t *src, ptrdiff_t stride)
{
    horiz_mc_qpel_no_rnd_8width_msa(src, stride, dest, stride, 8);
}

void ff_horiz_mc_qpel_no_rnd_16width_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    horiz_mc_qpel_no_rnd_16width_msa(src, stride, dest, stride, 16);
}

void ff_horiz_mc_qpel_no_rnd_aver_src1_8width_msa(uint8_t *dest,
                                                  const uint8_t *src,
                                                  ptrdiff_t stride)
{
    horiz_mc_qpel_no_rnd_aver_src1_8width_msa(src, stride, dest, stride, 8);
}

void ff_horiz_mc_qpel_no_rnd_aver_src1_16width_msa(uint8_t *dest,
                                                   const uint8_t *src,
                                                   ptrdiff_t stride)
{
    horiz_mc_qpel_no_rnd_aver_src1_16width_msa(src, stride, dest, stride, 16);
}

void ff_avg_width8_msa(uint8_t *dest, const uint8_t *src, ptrdiff_t stride)
{
    avg_width8_msa(src, stride, dest, stride, 8);
}

void ff_avg_width16_msa(uint8_t *dest, const uint8_t *src, ptrdiff_t stride)
{
    avg_width16_msa(src, stride, dest, stride, 16);
}

void ff_horiz_mc_qpel_avg_dst_aver_src0_8width_msa(uint8_t *dest,
                                                   const uint8_t *src,
                                                   ptrdiff_t stride)
{
    horiz_mc_qpel_avg_dst_aver_src0_8width_msa(src, stride, dest, stride, 8);
}

void ff_horiz_mc_qpel_avg_dst_aver_src0_16width_msa(uint8_t *dest,
                                                    const uint8_t *src,
                                                    ptrdiff_t stride)
{
    horiz_mc_qpel_avg_dst_aver_src0_16width_msa(src, stride, dest, stride, 16);
}

void ff_horiz_mc_qpel_avg_dst_8width_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    horiz_mc_qpel_avg_dst_8width_msa(src, stride, dest, stride, 8);
}

void ff_horiz_mc_qpel_avg_dst_16width_msa(uint8_t *dest,
                                          const uint8_t *src, ptrdiff_t stride)
{
    horiz_mc_qpel_avg_dst_16width_msa(src, stride, dest, stride, 16);
}

void ff_horiz_mc_qpel_avg_dst_aver_src1_8width_msa(uint8_t *dest,
                                                   const uint8_t *src,
                                                   ptrdiff_t stride)
{
    horiz_mc_qpel_avg_dst_aver_src1_8width_msa(src, stride, dest, stride, 8);
}

void ff_horiz_mc_qpel_avg_dst_aver_src1_16width_msa(uint8_t *dest,
                                                    const uint8_t *src,
                                                    ptrdiff_t stride)
{
    horiz_mc_qpel_avg_dst_aver_src1_16width_msa(src, stride, dest, stride, 16);
}


void ff_vert_mc_qpel_aver_src0_8x8_msa(uint8_t *dest,
                                       const uint8_t *src, ptrdiff_t stride)
{
    vert_mc_qpel_aver_src0_8x8_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_aver_src0_16x16_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    vert_mc_qpel_aver_src0_16x16_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_8x8_msa(uint8_t *dest, const uint8_t *src,
                             ptrdiff_t stride)
{
    vert_mc_qpel_8x8_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_16x16_msa(uint8_t *dest, const uint8_t *src,
                               ptrdiff_t stride)
{
    vert_mc_qpel_16x16_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_aver_src1_8x8_msa(uint8_t *dest,
                                       const uint8_t *src, ptrdiff_t stride)
{
    vert_mc_qpel_aver_src1_8x8_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_aver_src1_16x16_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    vert_mc_qpel_aver_src1_16x16_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_no_rnd_aver_src0_8x8_msa(uint8_t *dest,
                                              const uint8_t *src,
                                              ptrdiff_t stride)
{
    vert_mc_qpel_no_rnd_aver_src0_8x8_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_no_rnd_aver_src0_16x16_msa(uint8_t *dest,
                                                const uint8_t *src,
                                                ptrdiff_t stride)
{
    vert_mc_qpel_no_rnd_aver_src0_16x16_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_no_rnd_8x8_msa(uint8_t *dest,
                                    const uint8_t *src, ptrdiff_t stride)
{
    vert_mc_qpel_no_rnd_8x8_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_no_rnd_16x16_msa(uint8_t *dest,
                                      const uint8_t *src, ptrdiff_t stride)
{
    vert_mc_qpel_no_rnd_16x16_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_no_rnd_aver_src1_8x8_msa(uint8_t *dest,
                                              const uint8_t *src,
                                              ptrdiff_t stride)
{
    vert_mc_qpel_no_rnd_aver_src1_8x8_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_no_rnd_aver_src1_16x16_msa(uint8_t *dest,
                                                const uint8_t *src,
                                                ptrdiff_t stride)
{
    vert_mc_qpel_no_rnd_aver_src1_16x16_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_avg_dst_aver_src0_8x8_msa(uint8_t *dest,
                                               const uint8_t *src,
                                               ptrdiff_t stride)
{
    vert_mc_qpel_avg_dst_aver_src0_8x8_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_avg_dst_aver_src0_16x16_msa(uint8_t *dest,
                                                 const uint8_t *src,
                                                 ptrdiff_t stride)
{
    vert_mc_qpel_avg_dst_aver_src0_16x16_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_avg_dst_8x8_msa(uint8_t *dest,
                                     const uint8_t *src, ptrdiff_t stride)
{
    vert_mc_qpel_avg_dst_8x8_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_avg_dst_16x16_msa(uint8_t *dest,
                                       const uint8_t *src, ptrdiff_t stride)
{
    vert_mc_qpel_avg_dst_16x16_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_avg_dst_aver_src1_8x8_msa(uint8_t *dest,
                                               const uint8_t *src,
                                               ptrdiff_t stride)
{
    vert_mc_qpel_avg_dst_aver_src1_8x8_msa(src, stride, dest, stride);
}

void ff_vert_mc_qpel_avg_dst_aver_src1_16x16_msa(uint8_t *dest,
                                                 const uint8_t *src,
                                                 ptrdiff_t stride)
{
    vert_mc_qpel_avg_dst_aver_src1_16x16_msa(src, stride, dest, stride);
}

/* HV cases */
void ff_hv_mc_qpel_aver_hv_src00_16x16_msa(uint8_t *dest,
                                           const uint8_t *src,
                                           ptrdiff_t stride)
{
    hv_mc_qpel_aver_hv_src00_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_hv_src00_8x8_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_hv_src00_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_v_src0_16x16_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_v_src0_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_v_src0_8x8_msa(uint8_t *dest,
                                       const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_v_src0_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_hv_src10_16x16_msa(uint8_t *dest,
                                           const uint8_t *src,
                                           ptrdiff_t stride)
{
    hv_mc_qpel_aver_hv_src10_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_hv_src10_8x8_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_hv_src10_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_h_src0_16x16_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_h_src0_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_h_src0_8x8_msa(uint8_t *dest,
                                       const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_h_src0_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_16x16_msa(uint8_t *dest, const uint8_t *src,
                             ptrdiff_t stride)
{
    hv_mc_qpel_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_8x8_msa(uint8_t *dest, const uint8_t *src,
                           ptrdiff_t stride)
{
    hv_mc_qpel_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_h_src1_16x16_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_h_src1_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_h_src1_8x8_msa(uint8_t *dest,
                                       const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_h_src1_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_hv_src01_16x16_msa(uint8_t *dest,
                                           const uint8_t *src,
                                           ptrdiff_t stride)
{
    hv_mc_qpel_aver_hv_src01_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_hv_src01_8x8_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_hv_src01_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_v_src1_16x16_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_v_src1_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_v_src1_8x8_msa(uint8_t *dest,
                                       const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_v_src1_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_hv_src11_16x16_msa(uint8_t *dest,
                                           const uint8_t *src,
                                           ptrdiff_t stride)
{
    hv_mc_qpel_aver_hv_src11_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_aver_hv_src11_8x8_msa(uint8_t *dest,
                                         const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_aver_hv_src11_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa(uint8_t *dest,
                                                   const uint8_t *src,
                                                   ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa(uint8_t *dest,
                                                 const uint8_t *src,
                                                 ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa(uint8_t *dest,
                                                 const uint8_t *src,
                                                 ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa(uint8_t *dest,
                                               const uint8_t *src,
                                               ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa(uint8_t *dest,
                                                   const uint8_t *src,
                                                   ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa(uint8_t *dest,
                                                 const uint8_t *src,
                                                 ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa(uint8_t *dest,
                                                 const uint8_t *src,
                                                 ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa(uint8_t *dest,
                                               const uint8_t *src,
                                               ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_16x16_msa(uint8_t *dest,
                                     const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_8x8_msa(uint8_t *dest,
                                   const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa(uint8_t *dest,
                                                 const uint8_t *src,
                                                 ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa(uint8_t *dest,
                                               const uint8_t *src,
                                               ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa(uint8_t *dest,
                                                   const uint8_t *src,
                                                   ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa(uint8_t *dest,
                                                 const uint8_t *src,
                                                 ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa(uint8_t *dest,
                                                 const uint8_t *src,
                                                 ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa(uint8_t *dest,
                                               const uint8_t *src,
                                               ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa(uint8_t *dest,
                                                   const uint8_t *src,
                                                   ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa(uint8_t *dest,
                                                 const uint8_t *src,
                                                 ptrdiff_t stride)
{
    hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa(uint8_t *dest,
                                                  const uint8_t *src,
                                                  ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa(uint8_t *dest,
                                                const uint8_t *src,
                                                ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa(uint8_t *dest,
                                                const uint8_t *src,
                                                ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa(uint8_t *dest,
                                              const uint8_t *src,
                                              ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa(uint8_t *dest,
                                                  const uint8_t *src,
                                                  ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa(uint8_t *dest,
                                                const uint8_t *src,
                                                ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa(uint8_t *dest,
                                                const uint8_t *src,
                                                ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa(uint8_t *dest,
                                              const uint8_t *src,
                                              ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_16x16_msa(uint8_t *dest,
                                    const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_8x8_msa(uint8_t *dest,
                                  const uint8_t *src, ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa(uint8_t *dest,
                                                const uint8_t *src,
                                                ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa(uint8_t *dest,
                                              const uint8_t *src,
                                              ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa(uint8_t *dest,
                                                  const uint8_t *src,
                                                  ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa(uint8_t *dest,
                                                const uint8_t *src,
                                                ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa(uint8_t *dest,
                                                const uint8_t *src,
                                                ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa(uint8_t *dest,
                                              const uint8_t *src,
                                              ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa(uint8_t *dest,
                                                  const uint8_t *src,
                                                  ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa(src, stride, dest, stride);
}

void ff_hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa(uint8_t *dest,
                                                const uint8_t *src,
                                                ptrdiff_t stride)
{
    hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa(src, stride, dest, stride);
}

/* [<][>][^][v][top][bottom][index][help] */