h264_qpel.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /*
  2. * Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt
  3. * Copyright (c) 2011 Daniel Kang
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "libavutil/attributes.h"
  22. #include "libavutil/cpu.h"
  23. #include "libavutil/x86/asm.h"
  24. #include "libavutil/x86/cpu.h"
  25. #include "libavcodec/h264dec.h"
  26. #include "libavcodec/h264qpel.h"
  27. #include "libavcodec/pixels.h"
  28. #include "fpel.h"
  29. #if HAVE_X86ASM
  30. void ff_put_pixels4_l2_mmxext(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
  31. int dstStride, int src1Stride, int h);
  32. void ff_avg_pixels4_l2_mmxext(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
  33. int dstStride, int src1Stride, int h);
  34. void ff_put_pixels8_l2_mmxext(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
  35. int dstStride, int src1Stride, int h);
  36. void ff_avg_pixels8_l2_mmxext(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
  37. int dstStride, int src1Stride, int h);
  38. void ff_put_pixels16_l2_mmxext(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
  39. int dstStride, int src1Stride, int h);
  40. void ff_avg_pixels16_l2_mmxext(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
  41. int dstStride, int src1Stride, int h);
  42. #define ff_put_pixels8_l2_sse2 ff_put_pixels8_l2_mmxext
  43. #define ff_avg_pixels8_l2_sse2 ff_avg_pixels8_l2_mmxext
  44. #define ff_put_pixels16_l2_sse2 ff_put_pixels16_l2_mmxext
  45. #define ff_avg_pixels16_l2_sse2 ff_avg_pixels16_l2_mmxext
  46. #define ff_put_pixels16_mmxext ff_put_pixels16_mmx
  47. #define ff_put_pixels8_mmxext ff_put_pixels8_mmx
  48. #define ff_put_pixels4_mmxext ff_put_pixels4_mmx
  49. #define DEF_QPEL(OPNAME)\
  50. void ff_ ## OPNAME ## _h264_qpel4_h_lowpass_mmxext(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride);\
  51. void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_mmxext(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride);\
  52. void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_ssse3(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride);\
  53. void ff_ ## OPNAME ## _h264_qpel4_h_lowpass_l2_mmxext(uint8_t *dst, const uint8_t *src, const uint8_t *src2, int dstStride, int src2Stride);\
  54. void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_l2_mmxext(uint8_t *dst, const uint8_t *src, const uint8_t *src2, int dstStride, int src2Stride);\
  55. void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_l2_ssse3(uint8_t *dst, const uint8_t *src, const uint8_t *src2, int dstStride, int src2Stride);\
  56. void ff_ ## OPNAME ## _h264_qpel4_v_lowpass_mmxext(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride);\
  57. void ff_ ## OPNAME ## _h264_qpel8or16_v_lowpass_op_mmxext(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h);\
  58. void ff_ ## OPNAME ## _h264_qpel8or16_v_lowpass_sse2(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h);\
  59. void ff_ ## OPNAME ## _h264_qpel4_hv_lowpass_v_mmxext(const uint8_t *src, int16_t *tmp, int srcStride);\
  60. void ff_ ## OPNAME ## _h264_qpel4_hv_lowpass_h_mmxext(int16_t *tmp, uint8_t *dst, int dstStride);\
  61. void ff_ ## OPNAME ## _h264_qpel8or16_hv1_lowpass_op_mmxext(const uint8_t *src, int16_t *tmp, int srcStride, int size);\
  62. void ff_ ## OPNAME ## _h264_qpel8or16_hv1_lowpass_op_sse2(const uint8_t *src, int16_t *tmp, int srcStride, int size);\
  63. void ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_op_mmxext(uint8_t *dst, int16_t *tmp, int dstStride, int unused, int h);\
  64. void ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_ssse3(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size);\
  65. void ff_ ## OPNAME ## _pixels4_l2_shift5_mmxext(uint8_t *dst, const int16_t *src16, const uint8_t *src8, int dstStride, int src8Stride, int h);\
  66. void ff_ ## OPNAME ## _pixels8_l2_shift5_mmxext(uint8_t *dst, const int16_t *src16, const uint8_t *src8, int dstStride, int src8Stride, int h);
  67. DEF_QPEL(avg)
  68. DEF_QPEL(put)
  69. static av_always_inline void ff_put_h264_qpel8or16_hv1_lowpass_mmxext(int16_t *tmp, const uint8_t *src, int tmpStride, int srcStride, int size)
  70. {
  71. int w = (size + 8) >> 2;
  72. src -= 2 * srcStride + 2;
  73. while (w--) {
  74. ff_put_h264_qpel8or16_hv1_lowpass_op_mmxext(src, tmp, srcStride, size);
  75. tmp += 4;
  76. src += 4;
  77. }
  78. }
  79. #define QPEL_H264(OPNAME, OP, MMX)\
  80. static av_always_inline void ff_ ## OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, int dstStride, int tmpStride, int srcStride){\
  81. int w=3;\
  82. src -= 2*srcStride+2;\
  83. while(w--){\
  84. ff_ ## OPNAME ## h264_qpel4_hv_lowpass_v_mmxext(src, tmp, srcStride);\
  85. tmp += 4;\
  86. src += 4;\
  87. }\
  88. tmp -= 3*4;\
  89. ff_ ## OPNAME ## h264_qpel4_hv_lowpass_h_mmxext(tmp, dst, dstStride);\
  90. }\
  91. \
  92. static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h){\
  93. src -= 2*srcStride;\
  94. ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_op_mmxext(dst, src, dstStride, srcStride, h);\
  95. src += 4;\
  96. dst += 4;\
  97. ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_op_mmxext(dst, src, dstStride, srcStride, h);\
  98. }\
  99. static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size){\
  100. int w = size>>4;\
  101. do{\
  102. ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_op_mmxext(dst, tmp, dstStride, 0, size);\
  103. tmp += 8;\
  104. dst += 8;\
  105. }while(w--);\
  106. }\
  107. \
  108. static av_always_inline void ff_ ## OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
  109. ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
  110. }\
  111. static av_always_inline void ff_ ## OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
  112. ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
  113. ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
  114. }\
  115. \
  116. static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
  117. ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
  118. ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
  119. src += 8*srcStride;\
  120. dst += 8*dstStride;\
  121. ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
  122. ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
  123. }\
  124. \
  125. static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, const uint8_t *src, const uint8_t *src2, int dstStride, int src2Stride){\
  126. ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
  127. ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
  128. src += 8*dstStride;\
  129. dst += 8*dstStride;\
  130. src2 += 8*src2Stride;\
  131. ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
  132. ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
  133. }\
  134. \
  135. static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
  136. ff_put_h264_qpel8or16_hv1_lowpass_ ## MMX(tmp, src, tmpStride, srcStride, size);\
  137. ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\
  138. }\
  139. static av_always_inline void ff_ ## OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, int dstStride, int tmpStride, int srcStride){\
  140. ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 8);\
  141. }\
  142. \
  143. static av_always_inline void ff_ ## OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, int dstStride, int tmpStride, int srcStride){\
  144. ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 16);\
  145. }\
  146. \
  147. static av_always_inline void ff_ ## OPNAME ## pixels16_l2_shift5_ ## MMX(uint8_t *dst, const int16_t *src16, const uint8_t *src8, int dstStride, int src8Stride, int h)\
  148. {\
  149. ff_ ## OPNAME ## pixels8_l2_shift5_ ## MMX(dst , src16 , src8 , dstStride, src8Stride, h);\
  150. ff_ ## OPNAME ## pixels8_l2_shift5_ ## MMX(dst+8, src16+8, src8+8, dstStride, src8Stride, h);\
  151. }\
  152. #if ARCH_X86_64
  153. #define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
  154. void ff_avg_h264_qpel16_h_lowpass_l2_ssse3(uint8_t *dst, const uint8_t *src, const uint8_t *src2, int dstStride, int src2Stride);
  155. void ff_put_h264_qpel16_h_lowpass_l2_ssse3(uint8_t *dst, const uint8_t *src, const uint8_t *src2, int dstStride, int src2Stride);
  156. #else // ARCH_X86_64
  157. #define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
  158. static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, const uint8_t *src, const uint8_t *src2, int dstStride, int src2Stride){\
  159. ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
  160. ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
  161. src += 8*dstStride;\
  162. dst += 8*dstStride;\
  163. src2 += 8*src2Stride;\
  164. ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
  165. ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
  166. }
  167. #endif // ARCH_X86_64
  168. #define QPEL_H264_H_XMM(OPNAME, OP, MMX)\
  169. QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
  170. static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
  171. ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
  172. ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
  173. src += 8*srcStride;\
  174. dst += 8*dstStride;\
  175. ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
  176. ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
  177. }\
  178. #define QPEL_H264_V_XMM(OPNAME, OP, MMX)\
  179. static av_always_inline void ff_ ## OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
  180. ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
  181. }\
  182. static av_always_inline void ff_ ## OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride){\
  183. ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
  184. ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
  185. }
  186. static av_always_inline void put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp,
  187. const uint8_t *src,
  188. int tmpStride,
  189. int srcStride,
  190. int size)
  191. {
  192. int w = (size+8)>>3;
  193. src -= 2*srcStride+2;
  194. while(w--){
  195. ff_put_h264_qpel8or16_hv1_lowpass_op_sse2(src, tmp, srcStride, size);
  196. tmp += 8;
  197. src += 8;
  198. }
  199. }
  200. #define QPEL_H264_HV_XMM(OPNAME, OP, MMX)\
  201. static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
  202. put_h264_qpel8or16_hv1_lowpass_sse2(tmp, src, tmpStride, srcStride, size);\
  203. ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\
  204. }\
  205. static av_always_inline void ff_ ## OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, int dstStride, int tmpStride, int srcStride){\
  206. ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 8);\
  207. }\
  208. static av_always_inline void ff_ ## OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, const uint8_t *src, int dstStride, int tmpStride, int srcStride){\
  209. ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 16);\
  210. }\
  211. #define ff_put_h264_qpel8_h_lowpass_l2_sse2 ff_put_h264_qpel8_h_lowpass_l2_mmxext
  212. #define ff_avg_h264_qpel8_h_lowpass_l2_sse2 ff_avg_h264_qpel8_h_lowpass_l2_mmxext
  213. #define ff_put_h264_qpel16_h_lowpass_l2_sse2 ff_put_h264_qpel16_h_lowpass_l2_mmxext
  214. #define ff_avg_h264_qpel16_h_lowpass_l2_sse2 ff_avg_h264_qpel16_h_lowpass_l2_mmxext
  215. #define ff_put_h264_qpel8_v_lowpass_ssse3 ff_put_h264_qpel8_v_lowpass_sse2
  216. #define ff_avg_h264_qpel8_v_lowpass_ssse3 ff_avg_h264_qpel8_v_lowpass_sse2
  217. #define ff_put_h264_qpel16_v_lowpass_ssse3 ff_put_h264_qpel16_v_lowpass_sse2
  218. #define ff_avg_h264_qpel16_v_lowpass_ssse3 ff_avg_h264_qpel16_v_lowpass_sse2
  219. #define ff_put_h264_qpel8or16_hv2_lowpass_sse2 ff_put_h264_qpel8or16_hv2_lowpass_mmxext
  220. #define ff_avg_h264_qpel8or16_hv2_lowpass_sse2 ff_avg_h264_qpel8or16_hv2_lowpass_mmxext
  221. #define H264_MC(OPNAME, SIZE, MMX, ALIGN) \
  222. H264_MC_C(OPNAME, SIZE, MMX, ALIGN)\
  223. H264_MC_V(OPNAME, SIZE, MMX, ALIGN)\
  224. H264_MC_H(OPNAME, SIZE, MMX, ALIGN)\
  225. H264_MC_HV(OPNAME, SIZE, MMX, ALIGN)\
  226. static void put_h264_qpel16_mc00_sse2 (uint8_t *dst, const uint8_t *src,
  227. ptrdiff_t stride)
  228. {
  229. ff_put_pixels16_sse2(dst, src, stride, 16);
  230. }
  231. static void avg_h264_qpel16_mc00_sse2 (uint8_t *dst, const uint8_t *src,
  232. ptrdiff_t stride)
  233. {
  234. ff_avg_pixels16_sse2(dst, src, stride, 16);
  235. }
  236. #define put_h264_qpel8_mc00_sse2 put_h264_qpel8_mc00_mmxext
  237. #define avg_h264_qpel8_mc00_sse2 avg_h264_qpel8_mc00_mmxext
  238. #define H264_MC_C(OPNAME, SIZE, MMX, ALIGN) \
  239. static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## MMX (uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  240. {\
  241. ff_ ## OPNAME ## pixels ## SIZE ## _ ## MMX(dst, src, stride, SIZE);\
  242. }\
  243. #define H264_MC_H(OPNAME, SIZE, MMX, ALIGN) \
  244. static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  245. {\
  246. ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src, stride, stride);\
  247. }\
  248. \
  249. static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  250. {\
  251. ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## MMX(dst, src, stride, stride);\
  252. }\
  253. \
  254. static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  255. {\
  256. ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src+1, stride, stride);\
  257. }\
  258. #define H264_MC_V(OPNAME, SIZE, MMX, ALIGN) \
  259. static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  260. {\
  261. LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*SIZE]);\
  262. ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
  263. ff_ ## OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, temp, stride, stride, SIZE);\
  264. }\
  265. \
  266. static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  267. {\
  268. ff_ ## OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## MMX(dst, src, stride, stride);\
  269. }\
  270. \
  271. static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  272. {\
  273. LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*SIZE]);\
  274. ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
  275. ff_ ## OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, temp, stride, stride, SIZE);\
  276. }\
  277. #define H264_MC_HV(OPNAME, SIZE, MMX, ALIGN) \
  278. static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  279. {\
  280. LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*SIZE]);\
  281. ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
  282. ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\
  283. }\
  284. \
  285. static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  286. {\
  287. LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*SIZE]);\
  288. ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\
  289. ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\
  290. }\
  291. \
  292. static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  293. {\
  294. LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*SIZE]);\
  295. ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
  296. ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\
  297. }\
  298. \
  299. static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  300. {\
  301. LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*SIZE]);\
  302. ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\
  303. ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\
  304. }\
  305. \
  306. static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  307. {\
  308. LOCAL_ALIGNED(ALIGN, uint16_t, temp, [SIZE*(SIZE<8?12:24)]);\
  309. ff_ ## OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(dst, temp, src, stride, SIZE, stride);\
  310. }\
  311. \
  312. static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  313. {\
  314. LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE]);\
  315. uint8_t * const halfHV= temp;\
  316. int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
  317. av_assert2(((int)temp & 7) == 0);\
  318. ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
  319. ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfHV, stride, SIZE);\
  320. }\
  321. \
  322. static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  323. {\
  324. LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE]);\
  325. uint8_t * const halfHV= temp;\
  326. int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
  327. av_assert2(((int)temp & 7) == 0);\
  328. ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
  329. ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfHV, stride, SIZE);\
  330. }\
  331. \
  332. static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  333. {\
  334. LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE]);\
  335. uint8_t * const halfHV= temp;\
  336. int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
  337. av_assert2(((int)temp & 7) == 0);\
  338. ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
  339. ff_ ## OPNAME ## pixels ## SIZE ## _l2_shift5_mmxext(dst, halfV+2, halfHV, stride, SIZE, SIZE);\
  340. }\
  341. \
  342. static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
  343. {\
  344. LOCAL_ALIGNED(ALIGN, uint8_t, temp, [SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE]);\
  345. uint8_t * const halfHV= temp;\
  346. int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
  347. av_assert2(((int)temp & 7) == 0);\
  348. ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
  349. ff_ ## OPNAME ## pixels ## SIZE ## _l2_shift5_mmxext(dst, halfV+3, halfHV, stride, SIZE, SIZE);\
  350. }\
  351. #define H264_MC_4816(MMX)\
  352. H264_MC(put_, 4, MMX, 8)\
  353. H264_MC(put_, 8, MMX, 8)\
  354. H264_MC(put_, 16,MMX, 8)\
  355. H264_MC(avg_, 4, MMX, 8)\
  356. H264_MC(avg_, 8, MMX, 8)\
  357. H264_MC(avg_, 16,MMX, 8)\
  358. #define H264_MC_816(QPEL, XMM)\
  359. QPEL(put_, 8, XMM, 16)\
  360. QPEL(put_, 16,XMM, 16)\
  361. QPEL(avg_, 8, XMM, 16)\
  362. QPEL(avg_, 16,XMM, 16)\
  363. QPEL_H264(put_, PUT_OP, mmxext)
  364. QPEL_H264(avg_, AVG_MMXEXT_OP, mmxext)
  365. QPEL_H264_V_XMM(put_, PUT_OP, sse2)
  366. QPEL_H264_V_XMM(avg_,AVG_MMXEXT_OP, sse2)
  367. QPEL_H264_HV_XMM(put_, PUT_OP, sse2)
  368. QPEL_H264_HV_XMM(avg_,AVG_MMXEXT_OP, sse2)
  369. QPEL_H264_H_XMM(put_, PUT_OP, ssse3)
  370. QPEL_H264_H_XMM(avg_,AVG_MMXEXT_OP, ssse3)
  371. QPEL_H264_HV_XMM(put_, PUT_OP, ssse3)
  372. QPEL_H264_HV_XMM(avg_,AVG_MMXEXT_OP, ssse3)
  373. H264_MC_4816(mmxext)
  374. H264_MC_816(H264_MC_V, sse2)
  375. H264_MC_816(H264_MC_HV, sse2)
  376. H264_MC_816(H264_MC_H, ssse3)
  377. H264_MC_816(H264_MC_HV, ssse3)
  378. //10bit
  379. #define LUMA_MC_OP(OP, NUM, DEPTH, TYPE, OPT) \
  380. void ff_ ## OP ## _h264_qpel ## NUM ## _ ## TYPE ## _ ## DEPTH ## _ ## OPT \
  381. (uint8_t *dst, const uint8_t *src, ptrdiff_t stride);
  382. #define LUMA_MC_ALL(DEPTH, TYPE, OPT) \
  383. LUMA_MC_OP(put, 4, DEPTH, TYPE, OPT) \
  384. LUMA_MC_OP(avg, 4, DEPTH, TYPE, OPT) \
  385. LUMA_MC_OP(put, 8, DEPTH, TYPE, OPT) \
  386. LUMA_MC_OP(avg, 8, DEPTH, TYPE, OPT) \
  387. LUMA_MC_OP(put, 16, DEPTH, TYPE, OPT) \
  388. LUMA_MC_OP(avg, 16, DEPTH, TYPE, OPT)
  389. #define LUMA_MC_816(DEPTH, TYPE, OPT) \
  390. LUMA_MC_OP(put, 8, DEPTH, TYPE, OPT) \
  391. LUMA_MC_OP(avg, 8, DEPTH, TYPE, OPT) \
  392. LUMA_MC_OP(put, 16, DEPTH, TYPE, OPT) \
  393. LUMA_MC_OP(avg, 16, DEPTH, TYPE, OPT)
  394. LUMA_MC_ALL(10, mc00, mmxext)
  395. LUMA_MC_ALL(10, mc10, mmxext)
  396. LUMA_MC_ALL(10, mc20, mmxext)
  397. LUMA_MC_ALL(10, mc30, mmxext)
  398. LUMA_MC_ALL(10, mc01, mmxext)
  399. LUMA_MC_ALL(10, mc11, mmxext)
  400. LUMA_MC_ALL(10, mc21, mmxext)
  401. LUMA_MC_ALL(10, mc31, mmxext)
  402. LUMA_MC_ALL(10, mc02, mmxext)
  403. LUMA_MC_ALL(10, mc12, mmxext)
  404. LUMA_MC_ALL(10, mc22, mmxext)
  405. LUMA_MC_ALL(10, mc32, mmxext)
  406. LUMA_MC_ALL(10, mc03, mmxext)
  407. LUMA_MC_ALL(10, mc13, mmxext)
  408. LUMA_MC_ALL(10, mc23, mmxext)
  409. LUMA_MC_ALL(10, mc33, mmxext)
  410. LUMA_MC_816(10, mc00, sse2)
  411. LUMA_MC_816(10, mc10, sse2)
  412. LUMA_MC_816(10, mc10, sse2_cache64)
  413. LUMA_MC_816(10, mc10, ssse3_cache64)
  414. LUMA_MC_816(10, mc20, sse2)
  415. LUMA_MC_816(10, mc20, sse2_cache64)
  416. LUMA_MC_816(10, mc20, ssse3_cache64)
  417. LUMA_MC_816(10, mc30, sse2)
  418. LUMA_MC_816(10, mc30, sse2_cache64)
  419. LUMA_MC_816(10, mc30, ssse3_cache64)
  420. LUMA_MC_816(10, mc01, sse2)
  421. LUMA_MC_816(10, mc11, sse2)
  422. LUMA_MC_816(10, mc21, sse2)
  423. LUMA_MC_816(10, mc31, sse2)
  424. LUMA_MC_816(10, mc02, sse2)
  425. LUMA_MC_816(10, mc12, sse2)
  426. LUMA_MC_816(10, mc22, sse2)
  427. LUMA_MC_816(10, mc32, sse2)
  428. LUMA_MC_816(10, mc03, sse2)
  429. LUMA_MC_816(10, mc13, sse2)
  430. LUMA_MC_816(10, mc23, sse2)
  431. LUMA_MC_816(10, mc33, sse2)
  432. #define QPEL16_OPMC(OP, MC, MMX)\
  433. void ff_ ## OP ## _h264_qpel16_ ## MC ## _10_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride){\
  434. ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst , src , stride);\
  435. ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst+16, src+16, stride);\
  436. src += 8*stride;\
  437. dst += 8*stride;\
  438. ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst , src , stride);\
  439. ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst+16, src+16, stride);\
  440. }
  441. #define QPEL16_OP(MC, MMX)\
  442. QPEL16_OPMC(put, MC, MMX)\
  443. QPEL16_OPMC(avg, MC, MMX)
  444. #define QPEL16(MMX)\
  445. QPEL16_OP(mc00, MMX)\
  446. QPEL16_OP(mc01, MMX)\
  447. QPEL16_OP(mc02, MMX)\
  448. QPEL16_OP(mc03, MMX)\
  449. QPEL16_OP(mc10, MMX)\
  450. QPEL16_OP(mc11, MMX)\
  451. QPEL16_OP(mc12, MMX)\
  452. QPEL16_OP(mc13, MMX)\
  453. QPEL16_OP(mc20, MMX)\
  454. QPEL16_OP(mc21, MMX)\
  455. QPEL16_OP(mc22, MMX)\
  456. QPEL16_OP(mc23, MMX)\
  457. QPEL16_OP(mc30, MMX)\
  458. QPEL16_OP(mc31, MMX)\
  459. QPEL16_OP(mc32, MMX)\
  460. QPEL16_OP(mc33, MMX)
  461. #if ARCH_X86_32 // ARCH_X86_64 implies SSE2+
  462. QPEL16(mmxext)
  463. #endif
  464. #endif /* HAVE_X86ASM */
  465. #define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU, PREFIX) \
  466. do { \
  467. c->PFX ## _pixels_tab[IDX][ 0] = PREFIX ## PFX ## SIZE ## _mc00_ ## CPU; \
  468. c->PFX ## _pixels_tab[IDX][ 1] = PREFIX ## PFX ## SIZE ## _mc10_ ## CPU; \
  469. c->PFX ## _pixels_tab[IDX][ 2] = PREFIX ## PFX ## SIZE ## _mc20_ ## CPU; \
  470. c->PFX ## _pixels_tab[IDX][ 3] = PREFIX ## PFX ## SIZE ## _mc30_ ## CPU; \
  471. c->PFX ## _pixels_tab[IDX][ 4] = PREFIX ## PFX ## SIZE ## _mc01_ ## CPU; \
  472. c->PFX ## _pixels_tab[IDX][ 5] = PREFIX ## PFX ## SIZE ## _mc11_ ## CPU; \
  473. c->PFX ## _pixels_tab[IDX][ 6] = PREFIX ## PFX ## SIZE ## _mc21_ ## CPU; \
  474. c->PFX ## _pixels_tab[IDX][ 7] = PREFIX ## PFX ## SIZE ## _mc31_ ## CPU; \
  475. c->PFX ## _pixels_tab[IDX][ 8] = PREFIX ## PFX ## SIZE ## _mc02_ ## CPU; \
  476. c->PFX ## _pixels_tab[IDX][ 9] = PREFIX ## PFX ## SIZE ## _mc12_ ## CPU; \
  477. c->PFX ## _pixels_tab[IDX][10] = PREFIX ## PFX ## SIZE ## _mc22_ ## CPU; \
  478. c->PFX ## _pixels_tab[IDX][11] = PREFIX ## PFX ## SIZE ## _mc32_ ## CPU; \
  479. c->PFX ## _pixels_tab[IDX][12] = PREFIX ## PFX ## SIZE ## _mc03_ ## CPU; \
  480. c->PFX ## _pixels_tab[IDX][13] = PREFIX ## PFX ## SIZE ## _mc13_ ## CPU; \
  481. c->PFX ## _pixels_tab[IDX][14] = PREFIX ## PFX ## SIZE ## _mc23_ ## CPU; \
  482. c->PFX ## _pixels_tab[IDX][15] = PREFIX ## PFX ## SIZE ## _mc33_ ## CPU; \
  483. } while (0)
  484. #define H264_QPEL_FUNCS(x, y, CPU) \
  485. do { \
  486. c->put_h264_qpel_pixels_tab[0][x + y * 4] = put_h264_qpel16_mc ## x ## y ## _ ## CPU; \
  487. c->put_h264_qpel_pixels_tab[1][x + y * 4] = put_h264_qpel8_mc ## x ## y ## _ ## CPU; \
  488. c->avg_h264_qpel_pixels_tab[0][x + y * 4] = avg_h264_qpel16_mc ## x ## y ## _ ## CPU; \
  489. c->avg_h264_qpel_pixels_tab[1][x + y * 4] = avg_h264_qpel8_mc ## x ## y ## _ ## CPU; \
  490. } while (0)
  491. #define H264_QPEL_FUNCS_10(x, y, CPU) \
  492. do { \
  493. c->put_h264_qpel_pixels_tab[0][x + y * 4] = ff_put_h264_qpel16_mc ## x ## y ## _10_ ## CPU; \
  494. c->put_h264_qpel_pixels_tab[1][x + y * 4] = ff_put_h264_qpel8_mc ## x ## y ## _10_ ## CPU; \
  495. c->avg_h264_qpel_pixels_tab[0][x + y * 4] = ff_avg_h264_qpel16_mc ## x ## y ## _10_ ## CPU; \
  496. c->avg_h264_qpel_pixels_tab[1][x + y * 4] = ff_avg_h264_qpel8_mc ## x ## y ## _10_ ## CPU; \
  497. } while (0)
  498. av_cold void ff_h264qpel_init_x86(H264QpelContext *c, int bit_depth)
  499. {
  500. #if HAVE_X86ASM
  501. int high_bit_depth = bit_depth > 8;
  502. int cpu_flags = av_get_cpu_flags();
  503. if (EXTERNAL_MMXEXT(cpu_flags)) {
  504. if (!high_bit_depth) {
  505. SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmxext, );
  506. SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmxext, );
  507. SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmxext, );
  508. SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmxext, );
  509. SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmxext, );
  510. SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmxext, );
  511. } else if (bit_depth == 10) {
  512. #if ARCH_X86_32
  513. SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 10_mmxext, ff_);
  514. SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_mmxext, ff_);
  515. SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 10_mmxext, ff_);
  516. SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 10_mmxext, ff_);
  517. #endif
  518. SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 10_mmxext, ff_);
  519. SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 10_mmxext, ff_);
  520. }
  521. }
  522. if (EXTERNAL_SSE2(cpu_flags)) {
  523. if (!high_bit_depth) {
  524. H264_QPEL_FUNCS(0, 1, sse2);
  525. H264_QPEL_FUNCS(0, 2, sse2);
  526. H264_QPEL_FUNCS(0, 3, sse2);
  527. H264_QPEL_FUNCS(1, 1, sse2);
  528. H264_QPEL_FUNCS(1, 2, sse2);
  529. H264_QPEL_FUNCS(1, 3, sse2);
  530. H264_QPEL_FUNCS(2, 1, sse2);
  531. H264_QPEL_FUNCS(2, 2, sse2);
  532. H264_QPEL_FUNCS(2, 3, sse2);
  533. H264_QPEL_FUNCS(3, 1, sse2);
  534. H264_QPEL_FUNCS(3, 2, sse2);
  535. H264_QPEL_FUNCS(3, 3, sse2);
  536. }
  537. if (bit_depth == 10) {
  538. SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_sse2, ff_);
  539. SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 10_sse2, ff_);
  540. SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 10_sse2, ff_);
  541. SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 10_sse2, ff_);
  542. H264_QPEL_FUNCS_10(1, 0, sse2_cache64);
  543. H264_QPEL_FUNCS_10(2, 0, sse2_cache64);
  544. H264_QPEL_FUNCS_10(3, 0, sse2_cache64);
  545. }
  546. }
  547. if (EXTERNAL_SSE2_FAST(cpu_flags)) {
  548. if (!high_bit_depth) {
  549. H264_QPEL_FUNCS(0, 0, sse2);
  550. }
  551. }
  552. if (EXTERNAL_SSSE3(cpu_flags)) {
  553. if (!high_bit_depth) {
  554. H264_QPEL_FUNCS(1, 0, ssse3);
  555. H264_QPEL_FUNCS(1, 1, ssse3);
  556. H264_QPEL_FUNCS(1, 2, ssse3);
  557. H264_QPEL_FUNCS(1, 3, ssse3);
  558. H264_QPEL_FUNCS(2, 0, ssse3);
  559. H264_QPEL_FUNCS(2, 1, ssse3);
  560. H264_QPEL_FUNCS(2, 2, ssse3);
  561. H264_QPEL_FUNCS(2, 3, ssse3);
  562. H264_QPEL_FUNCS(3, 0, ssse3);
  563. H264_QPEL_FUNCS(3, 1, ssse3);
  564. H264_QPEL_FUNCS(3, 2, ssse3);
  565. H264_QPEL_FUNCS(3, 3, ssse3);
  566. }
  567. if (bit_depth == 10) {
  568. H264_QPEL_FUNCS_10(1, 0, ssse3_cache64);
  569. H264_QPEL_FUNCS_10(2, 0, ssse3_cache64);
  570. H264_QPEL_FUNCS_10(3, 0, ssse3_cache64);
  571. }
  572. }
  573. if (EXTERNAL_AVX(cpu_flags)) {
  574. /* AVX implies 64 byte cache lines without the need to avoid unaligned
  575. * memory accesses that cross the boundary between two cache lines.
  576. * TODO: Port X264_CPU_CACHELINE_32/64 detection from x264 to avoid
  577. * having to treat SSE2 functions with such properties as AVX. */
  578. if (bit_depth == 10) {
  579. H264_QPEL_FUNCS_10(1, 0, sse2);
  580. H264_QPEL_FUNCS_10(2, 0, sse2);
  581. H264_QPEL_FUNCS_10(3, 0, sse2);
  582. }
  583. }
  584. #endif
  585. }