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

1101 lines
34KB

  1. /*
  2. * MMX optimized DSP utils
  3. * Copyright (c) 2000, 2001 Fabrice Bellard
  4. * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  5. *
  6. * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
  7. *
  8. * This file is part of Libav.
  9. *
  10. * Libav is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * Libav is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with Libav; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #include "libavutil/attributes.h"
  25. #include "libavutil/cpu.h"
  26. #include "libavutil/x86/asm.h"
  27. #include "libavutil/x86/cpu.h"
  28. #include "libavcodec/dct.h"
  29. #include "libavcodec/dsputil.h"
  30. #include "libavcodec/mpegvideo.h"
  31. #include "libavcodec/mathops.h"
  32. #include "dsputil_x86.h"
  33. void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size);
  34. void ff_get_pixels_sse2(int16_t *block, const uint8_t *pixels, int line_size);
  35. void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2,
  36. int stride);
  37. int ff_pix_sum16_mmx(uint8_t *pix, int line_size);
  38. int ff_pix_norm1_mmx(uint8_t *pix, int line_size);
  39. #if HAVE_INLINE_ASM
  40. static int sse8_mmx(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
  41. {
  42. int tmp;
  43. __asm__ volatile (
  44. "movl %4, %%ecx \n"
  45. "shr $1, %%ecx \n"
  46. "pxor %%mm0, %%mm0 \n" /* mm0 = 0 */
  47. "pxor %%mm7, %%mm7 \n" /* mm7 holds the sum */
  48. "1: \n"
  49. "movq (%0), %%mm1 \n" /* mm1 = pix1[0][0 - 7] */
  50. "movq (%1), %%mm2 \n" /* mm2 = pix2[0][0 - 7] */
  51. "movq (%0, %3), %%mm3 \n" /* mm3 = pix1[1][0 - 7] */
  52. "movq (%1, %3), %%mm4 \n" /* mm4 = pix2[1][0 - 7] */
  53. /* todo: mm1-mm2, mm3-mm4 */
  54. /* algo: subtract mm1 from mm2 with saturation and vice versa */
  55. /* OR the results to get absolute difference */
  56. "movq %%mm1, %%mm5 \n"
  57. "movq %%mm3, %%mm6 \n"
  58. "psubusb %%mm2, %%mm1 \n"
  59. "psubusb %%mm4, %%mm3 \n"
  60. "psubusb %%mm5, %%mm2 \n"
  61. "psubusb %%mm6, %%mm4 \n"
  62. "por %%mm1, %%mm2 \n"
  63. "por %%mm3, %%mm4 \n"
  64. /* now convert to 16-bit vectors so we can square them */
  65. "movq %%mm2, %%mm1 \n"
  66. "movq %%mm4, %%mm3 \n"
  67. "punpckhbw %%mm0, %%mm2 \n"
  68. "punpckhbw %%mm0, %%mm4 \n"
  69. "punpcklbw %%mm0, %%mm1 \n" /* mm1 now spread over (mm1, mm2) */
  70. "punpcklbw %%mm0, %%mm3 \n" /* mm4 now spread over (mm3, mm4) */
  71. "pmaddwd %%mm2, %%mm2 \n"
  72. "pmaddwd %%mm4, %%mm4 \n"
  73. "pmaddwd %%mm1, %%mm1 \n"
  74. "pmaddwd %%mm3, %%mm3 \n"
  75. "lea (%0, %3, 2), %0 \n" /* pix1 += 2 * line_size */
  76. "lea (%1, %3, 2), %1 \n" /* pix2 += 2 * line_size */
  77. "paddd %%mm2, %%mm1 \n"
  78. "paddd %%mm4, %%mm3 \n"
  79. "paddd %%mm1, %%mm7 \n"
  80. "paddd %%mm3, %%mm7 \n"
  81. "decl %%ecx \n"
  82. "jnz 1b \n"
  83. "movq %%mm7, %%mm1 \n"
  84. "psrlq $32, %%mm7 \n" /* shift hi dword to lo */
  85. "paddd %%mm7, %%mm1 \n"
  86. "movd %%mm1, %2 \n"
  87. : "+r" (pix1), "+r" (pix2), "=r" (tmp)
  88. : "r" ((x86_reg) line_size), "m" (h)
  89. : "%ecx");
  90. return tmp;
  91. }
  92. static int sse16_mmx(void *v, uint8_t *pix1, uint8_t *pix2,
  93. int line_size, int h)
  94. {
  95. int tmp;
  96. __asm__ volatile (
  97. "movl %4, %%ecx\n"
  98. "pxor %%mm0, %%mm0\n" /* mm0 = 0 */
  99. "pxor %%mm7, %%mm7\n" /* mm7 holds the sum */
  100. "1:\n"
  101. "movq (%0), %%mm1\n" /* mm1 = pix1[0 - 7] */
  102. "movq (%1), %%mm2\n" /* mm2 = pix2[0 - 7] */
  103. "movq 8(%0), %%mm3\n" /* mm3 = pix1[8 - 15] */
  104. "movq 8(%1), %%mm4\n" /* mm4 = pix2[8 - 15] */
  105. /* todo: mm1-mm2, mm3-mm4 */
  106. /* algo: subtract mm1 from mm2 with saturation and vice versa */
  107. /* OR the results to get absolute difference */
  108. "movq %%mm1, %%mm5\n"
  109. "movq %%mm3, %%mm6\n"
  110. "psubusb %%mm2, %%mm1\n"
  111. "psubusb %%mm4, %%mm3\n"
  112. "psubusb %%mm5, %%mm2\n"
  113. "psubusb %%mm6, %%mm4\n"
  114. "por %%mm1, %%mm2\n"
  115. "por %%mm3, %%mm4\n"
  116. /* now convert to 16-bit vectors so we can square them */
  117. "movq %%mm2, %%mm1\n"
  118. "movq %%mm4, %%mm3\n"
  119. "punpckhbw %%mm0, %%mm2\n"
  120. "punpckhbw %%mm0, %%mm4\n"
  121. "punpcklbw %%mm0, %%mm1\n" /* mm1 now spread over (mm1, mm2) */
  122. "punpcklbw %%mm0, %%mm3\n" /* mm4 now spread over (mm3, mm4) */
  123. "pmaddwd %%mm2, %%mm2\n"
  124. "pmaddwd %%mm4, %%mm4\n"
  125. "pmaddwd %%mm1, %%mm1\n"
  126. "pmaddwd %%mm3, %%mm3\n"
  127. "add %3, %0\n"
  128. "add %3, %1\n"
  129. "paddd %%mm2, %%mm1\n"
  130. "paddd %%mm4, %%mm3\n"
  131. "paddd %%mm1, %%mm7\n"
  132. "paddd %%mm3, %%mm7\n"
  133. "decl %%ecx\n"
  134. "jnz 1b\n"
  135. "movq %%mm7, %%mm1\n"
  136. "psrlq $32, %%mm7\n" /* shift hi dword to lo */
  137. "paddd %%mm7, %%mm1\n"
  138. "movd %%mm1, %2\n"
  139. : "+r" (pix1), "+r" (pix2), "=r" (tmp)
  140. : "r" ((x86_reg) line_size), "m" (h)
  141. : "%ecx");
  142. return tmp;
  143. }
  144. static int hf_noise8_mmx(uint8_t *pix1, int line_size, int h)
  145. {
  146. int tmp;
  147. __asm__ volatile (
  148. "movl %3, %%ecx\n"
  149. "pxor %%mm7, %%mm7\n"
  150. "pxor %%mm6, %%mm6\n"
  151. "movq (%0), %%mm0\n"
  152. "movq %%mm0, %%mm1\n"
  153. "psllq $8, %%mm0\n"
  154. "psrlq $8, %%mm1\n"
  155. "psrlq $8, %%mm0\n"
  156. "movq %%mm0, %%mm2\n"
  157. "movq %%mm1, %%mm3\n"
  158. "punpcklbw %%mm7, %%mm0\n"
  159. "punpcklbw %%mm7, %%mm1\n"
  160. "punpckhbw %%mm7, %%mm2\n"
  161. "punpckhbw %%mm7, %%mm3\n"
  162. "psubw %%mm1, %%mm0\n"
  163. "psubw %%mm3, %%mm2\n"
  164. "add %2, %0\n"
  165. "movq (%0), %%mm4\n"
  166. "movq %%mm4, %%mm1\n"
  167. "psllq $8, %%mm4\n"
  168. "psrlq $8, %%mm1\n"
  169. "psrlq $8, %%mm4\n"
  170. "movq %%mm4, %%mm5\n"
  171. "movq %%mm1, %%mm3\n"
  172. "punpcklbw %%mm7, %%mm4\n"
  173. "punpcklbw %%mm7, %%mm1\n"
  174. "punpckhbw %%mm7, %%mm5\n"
  175. "punpckhbw %%mm7, %%mm3\n"
  176. "psubw %%mm1, %%mm4\n"
  177. "psubw %%mm3, %%mm5\n"
  178. "psubw %%mm4, %%mm0\n"
  179. "psubw %%mm5, %%mm2\n"
  180. "pxor %%mm3, %%mm3\n"
  181. "pxor %%mm1, %%mm1\n"
  182. "pcmpgtw %%mm0, %%mm3\n\t"
  183. "pcmpgtw %%mm2, %%mm1\n\t"
  184. "pxor %%mm3, %%mm0\n"
  185. "pxor %%mm1, %%mm2\n"
  186. "psubw %%mm3, %%mm0\n"
  187. "psubw %%mm1, %%mm2\n"
  188. "paddw %%mm0, %%mm2\n"
  189. "paddw %%mm2, %%mm6\n"
  190. "add %2, %0\n"
  191. "1:\n"
  192. "movq (%0), %%mm0\n"
  193. "movq %%mm0, %%mm1\n"
  194. "psllq $8, %%mm0\n"
  195. "psrlq $8, %%mm1\n"
  196. "psrlq $8, %%mm0\n"
  197. "movq %%mm0, %%mm2\n"
  198. "movq %%mm1, %%mm3\n"
  199. "punpcklbw %%mm7, %%mm0\n"
  200. "punpcklbw %%mm7, %%mm1\n"
  201. "punpckhbw %%mm7, %%mm2\n"
  202. "punpckhbw %%mm7, %%mm3\n"
  203. "psubw %%mm1, %%mm0\n"
  204. "psubw %%mm3, %%mm2\n"
  205. "psubw %%mm0, %%mm4\n"
  206. "psubw %%mm2, %%mm5\n"
  207. "pxor %%mm3, %%mm3\n"
  208. "pxor %%mm1, %%mm1\n"
  209. "pcmpgtw %%mm4, %%mm3\n\t"
  210. "pcmpgtw %%mm5, %%mm1\n\t"
  211. "pxor %%mm3, %%mm4\n"
  212. "pxor %%mm1, %%mm5\n"
  213. "psubw %%mm3, %%mm4\n"
  214. "psubw %%mm1, %%mm5\n"
  215. "paddw %%mm4, %%mm5\n"
  216. "paddw %%mm5, %%mm6\n"
  217. "add %2, %0\n"
  218. "movq (%0), %%mm4\n"
  219. "movq %%mm4, %%mm1\n"
  220. "psllq $8, %%mm4\n"
  221. "psrlq $8, %%mm1\n"
  222. "psrlq $8, %%mm4\n"
  223. "movq %%mm4, %%mm5\n"
  224. "movq %%mm1, %%mm3\n"
  225. "punpcklbw %%mm7, %%mm4\n"
  226. "punpcklbw %%mm7, %%mm1\n"
  227. "punpckhbw %%mm7, %%mm5\n"
  228. "punpckhbw %%mm7, %%mm3\n"
  229. "psubw %%mm1, %%mm4\n"
  230. "psubw %%mm3, %%mm5\n"
  231. "psubw %%mm4, %%mm0\n"
  232. "psubw %%mm5, %%mm2\n"
  233. "pxor %%mm3, %%mm3\n"
  234. "pxor %%mm1, %%mm1\n"
  235. "pcmpgtw %%mm0, %%mm3\n\t"
  236. "pcmpgtw %%mm2, %%mm1\n\t"
  237. "pxor %%mm3, %%mm0\n"
  238. "pxor %%mm1, %%mm2\n"
  239. "psubw %%mm3, %%mm0\n"
  240. "psubw %%mm1, %%mm2\n"
  241. "paddw %%mm0, %%mm2\n"
  242. "paddw %%mm2, %%mm6\n"
  243. "add %2, %0\n"
  244. "subl $2, %%ecx\n"
  245. " jnz 1b\n"
  246. "movq %%mm6, %%mm0\n"
  247. "punpcklwd %%mm7, %%mm0\n"
  248. "punpckhwd %%mm7, %%mm6\n"
  249. "paddd %%mm0, %%mm6\n"
  250. "movq %%mm6, %%mm0\n"
  251. "psrlq $32, %%mm6\n"
  252. "paddd %%mm6, %%mm0\n"
  253. "movd %%mm0, %1\n"
  254. : "+r" (pix1), "=r" (tmp)
  255. : "r" ((x86_reg) line_size), "g" (h - 2)
  256. : "%ecx");
  257. return tmp;
  258. }
  259. static int hf_noise16_mmx(uint8_t *pix1, int line_size, int h)
  260. {
  261. int tmp;
  262. uint8_t *pix = pix1;
  263. __asm__ volatile (
  264. "movl %3, %%ecx\n"
  265. "pxor %%mm7, %%mm7\n"
  266. "pxor %%mm6, %%mm6\n"
  267. "movq (%0), %%mm0\n"
  268. "movq 1(%0), %%mm1\n"
  269. "movq %%mm0, %%mm2\n"
  270. "movq %%mm1, %%mm3\n"
  271. "punpcklbw %%mm7, %%mm0\n"
  272. "punpcklbw %%mm7, %%mm1\n"
  273. "punpckhbw %%mm7, %%mm2\n"
  274. "punpckhbw %%mm7, %%mm3\n"
  275. "psubw %%mm1, %%mm0\n"
  276. "psubw %%mm3, %%mm2\n"
  277. "add %2, %0\n"
  278. "movq (%0), %%mm4\n"
  279. "movq 1(%0), %%mm1\n"
  280. "movq %%mm4, %%mm5\n"
  281. "movq %%mm1, %%mm3\n"
  282. "punpcklbw %%mm7, %%mm4\n"
  283. "punpcklbw %%mm7, %%mm1\n"
  284. "punpckhbw %%mm7, %%mm5\n"
  285. "punpckhbw %%mm7, %%mm3\n"
  286. "psubw %%mm1, %%mm4\n"
  287. "psubw %%mm3, %%mm5\n"
  288. "psubw %%mm4, %%mm0\n"
  289. "psubw %%mm5, %%mm2\n"
  290. "pxor %%mm3, %%mm3\n"
  291. "pxor %%mm1, %%mm1\n"
  292. "pcmpgtw %%mm0, %%mm3\n\t"
  293. "pcmpgtw %%mm2, %%mm1\n\t"
  294. "pxor %%mm3, %%mm0\n"
  295. "pxor %%mm1, %%mm2\n"
  296. "psubw %%mm3, %%mm0\n"
  297. "psubw %%mm1, %%mm2\n"
  298. "paddw %%mm0, %%mm2\n"
  299. "paddw %%mm2, %%mm6\n"
  300. "add %2, %0\n"
  301. "1:\n"
  302. "movq (%0), %%mm0\n"
  303. "movq 1(%0), %%mm1\n"
  304. "movq %%mm0, %%mm2\n"
  305. "movq %%mm1, %%mm3\n"
  306. "punpcklbw %%mm7, %%mm0\n"
  307. "punpcklbw %%mm7, %%mm1\n"
  308. "punpckhbw %%mm7, %%mm2\n"
  309. "punpckhbw %%mm7, %%mm3\n"
  310. "psubw %%mm1, %%mm0\n"
  311. "psubw %%mm3, %%mm2\n"
  312. "psubw %%mm0, %%mm4\n"
  313. "psubw %%mm2, %%mm5\n"
  314. "pxor %%mm3, %%mm3\n"
  315. "pxor %%mm1, %%mm1\n"
  316. "pcmpgtw %%mm4, %%mm3\n\t"
  317. "pcmpgtw %%mm5, %%mm1\n\t"
  318. "pxor %%mm3, %%mm4\n"
  319. "pxor %%mm1, %%mm5\n"
  320. "psubw %%mm3, %%mm4\n"
  321. "psubw %%mm1, %%mm5\n"
  322. "paddw %%mm4, %%mm5\n"
  323. "paddw %%mm5, %%mm6\n"
  324. "add %2, %0\n"
  325. "movq (%0), %%mm4\n"
  326. "movq 1(%0), %%mm1\n"
  327. "movq %%mm4, %%mm5\n"
  328. "movq %%mm1, %%mm3\n"
  329. "punpcklbw %%mm7, %%mm4\n"
  330. "punpcklbw %%mm7, %%mm1\n"
  331. "punpckhbw %%mm7, %%mm5\n"
  332. "punpckhbw %%mm7, %%mm3\n"
  333. "psubw %%mm1, %%mm4\n"
  334. "psubw %%mm3, %%mm5\n"
  335. "psubw %%mm4, %%mm0\n"
  336. "psubw %%mm5, %%mm2\n"
  337. "pxor %%mm3, %%mm3\n"
  338. "pxor %%mm1, %%mm1\n"
  339. "pcmpgtw %%mm0, %%mm3\n\t"
  340. "pcmpgtw %%mm2, %%mm1\n\t"
  341. "pxor %%mm3, %%mm0\n"
  342. "pxor %%mm1, %%mm2\n"
  343. "psubw %%mm3, %%mm0\n"
  344. "psubw %%mm1, %%mm2\n"
  345. "paddw %%mm0, %%mm2\n"
  346. "paddw %%mm2, %%mm6\n"
  347. "add %2, %0\n"
  348. "subl $2, %%ecx\n"
  349. " jnz 1b\n"
  350. "movq %%mm6, %%mm0\n"
  351. "punpcklwd %%mm7, %%mm0\n"
  352. "punpckhwd %%mm7, %%mm6\n"
  353. "paddd %%mm0, %%mm6\n"
  354. "movq %%mm6, %%mm0\n"
  355. "psrlq $32, %%mm6\n"
  356. "paddd %%mm6, %%mm0\n"
  357. "movd %%mm0, %1\n"
  358. : "+r" (pix1), "=r" (tmp)
  359. : "r" ((x86_reg) line_size), "g" (h - 2)
  360. : "%ecx");
  361. return tmp + hf_noise8_mmx(pix + 8, line_size, h);
  362. }
  363. static int nsse16_mmx(void *p, uint8_t *pix1, uint8_t *pix2,
  364. int line_size, int h)
  365. {
  366. MpegEncContext *c = p;
  367. int score1, score2;
  368. if (c)
  369. score1 = c->dsp.sse[0](c, pix1, pix2, line_size, h);
  370. else
  371. score1 = sse16_mmx(c, pix1, pix2, line_size, h);
  372. score2 = hf_noise16_mmx(pix1, line_size, h) -
  373. hf_noise16_mmx(pix2, line_size, h);
  374. if (c)
  375. return score1 + FFABS(score2) * c->avctx->nsse_weight;
  376. else
  377. return score1 + FFABS(score2) * 8;
  378. }
  379. static int nsse8_mmx(void *p, uint8_t *pix1, uint8_t *pix2,
  380. int line_size, int h)
  381. {
  382. MpegEncContext *c = p;
  383. int score1 = sse8_mmx(c, pix1, pix2, line_size, h);
  384. int score2 = hf_noise8_mmx(pix1, line_size, h) -
  385. hf_noise8_mmx(pix2, line_size, h);
  386. if (c)
  387. return score1 + FFABS(score2) * c->avctx->nsse_weight;
  388. else
  389. return score1 + FFABS(score2) * 8;
  390. }
  391. static int vsad_intra16_mmx(void *v, uint8_t *pix, uint8_t *dummy,
  392. int line_size, int h)
  393. {
  394. int tmp;
  395. assert((((int) pix) & 7) == 0);
  396. assert((line_size & 7) == 0);
  397. #define SUM(in0, in1, out0, out1) \
  398. "movq (%0), %%mm2\n" \
  399. "movq 8(%0), %%mm3\n" \
  400. "add %2,%0\n" \
  401. "movq %%mm2, " #out0 "\n" \
  402. "movq %%mm3, " #out1 "\n" \
  403. "psubusb " #in0 ", %%mm2\n" \
  404. "psubusb " #in1 ", %%mm3\n" \
  405. "psubusb " #out0 ", " #in0 "\n" \
  406. "psubusb " #out1 ", " #in1 "\n" \
  407. "por %%mm2, " #in0 "\n" \
  408. "por %%mm3, " #in1 "\n" \
  409. "movq " #in0 ", %%mm2\n" \
  410. "movq " #in1 ", %%mm3\n" \
  411. "punpcklbw %%mm7, " #in0 "\n" \
  412. "punpcklbw %%mm7, " #in1 "\n" \
  413. "punpckhbw %%mm7, %%mm2\n" \
  414. "punpckhbw %%mm7, %%mm3\n" \
  415. "paddw " #in1 ", " #in0 "\n" \
  416. "paddw %%mm3, %%mm2\n" \
  417. "paddw %%mm2, " #in0 "\n" \
  418. "paddw " #in0 ", %%mm6\n"
  419. __asm__ volatile (
  420. "movl %3, %%ecx\n"
  421. "pxor %%mm6, %%mm6\n"
  422. "pxor %%mm7, %%mm7\n"
  423. "movq (%0), %%mm0\n"
  424. "movq 8(%0), %%mm1\n"
  425. "add %2, %0\n"
  426. "jmp 2f\n"
  427. "1:\n"
  428. SUM(%%mm4, %%mm5, %%mm0, %%mm1)
  429. "2:\n"
  430. SUM(%%mm0, %%mm1, %%mm4, %%mm5)
  431. "subl $2, %%ecx\n"
  432. "jnz 1b\n"
  433. "movq %%mm6, %%mm0\n"
  434. "psrlq $32, %%mm6\n"
  435. "paddw %%mm6, %%mm0\n"
  436. "movq %%mm0, %%mm6\n"
  437. "psrlq $16, %%mm0\n"
  438. "paddw %%mm6, %%mm0\n"
  439. "movd %%mm0, %1\n"
  440. : "+r" (pix), "=r" (tmp)
  441. : "r" ((x86_reg) line_size), "m" (h)
  442. : "%ecx");
  443. return tmp & 0xFFFF;
  444. }
  445. #undef SUM
  446. static int vsad_intra16_mmxext(void *v, uint8_t *pix, uint8_t *dummy,
  447. int line_size, int h)
  448. {
  449. int tmp;
  450. assert((((int) pix) & 7) == 0);
  451. assert((line_size & 7) == 0);
  452. #define SUM(in0, in1, out0, out1) \
  453. "movq (%0), " #out0 "\n" \
  454. "movq 8(%0), " #out1 "\n" \
  455. "add %2, %0\n" \
  456. "psadbw " #out0 ", " #in0 "\n" \
  457. "psadbw " #out1 ", " #in1 "\n" \
  458. "paddw " #in1 ", " #in0 "\n" \
  459. "paddw " #in0 ", %%mm6\n"
  460. __asm__ volatile (
  461. "movl %3, %%ecx\n"
  462. "pxor %%mm6, %%mm6\n"
  463. "pxor %%mm7, %%mm7\n"
  464. "movq (%0), %%mm0\n"
  465. "movq 8(%0), %%mm1\n"
  466. "add %2, %0\n"
  467. "jmp 2f\n"
  468. "1:\n"
  469. SUM(%%mm4, %%mm5, %%mm0, %%mm1)
  470. "2:\n"
  471. SUM(%%mm0, %%mm1, %%mm4, %%mm5)
  472. "subl $2, %%ecx\n"
  473. "jnz 1b\n"
  474. "movd %%mm6, %1\n"
  475. : "+r" (pix), "=r" (tmp)
  476. : "r" ((x86_reg) line_size), "m" (h)
  477. : "%ecx");
  478. return tmp;
  479. }
  480. #undef SUM
  481. static int vsad16_mmx(void *v, uint8_t *pix1, uint8_t *pix2,
  482. int line_size, int h)
  483. {
  484. int tmp;
  485. assert((((int) pix1) & 7) == 0);
  486. assert((((int) pix2) & 7) == 0);
  487. assert((line_size & 7) == 0);
  488. #define SUM(in0, in1, out0, out1) \
  489. "movq (%0), %%mm2\n" \
  490. "movq (%1), " #out0 "\n" \
  491. "movq 8(%0), %%mm3\n" \
  492. "movq 8(%1), " #out1 "\n" \
  493. "add %3, %0\n" \
  494. "add %3, %1\n" \
  495. "psubb " #out0 ", %%mm2\n" \
  496. "psubb " #out1 ", %%mm3\n" \
  497. "pxor %%mm7, %%mm2\n" \
  498. "pxor %%mm7, %%mm3\n" \
  499. "movq %%mm2, " #out0 "\n" \
  500. "movq %%mm3, " #out1 "\n" \
  501. "psubusb " #in0 ", %%mm2\n" \
  502. "psubusb " #in1 ", %%mm3\n" \
  503. "psubusb " #out0 ", " #in0 "\n" \
  504. "psubusb " #out1 ", " #in1 "\n" \
  505. "por %%mm2, " #in0 "\n" \
  506. "por %%mm3, " #in1 "\n" \
  507. "movq " #in0 ", %%mm2\n" \
  508. "movq " #in1 ", %%mm3\n" \
  509. "punpcklbw %%mm7, " #in0 "\n" \
  510. "punpcklbw %%mm7, " #in1 "\n" \
  511. "punpckhbw %%mm7, %%mm2\n" \
  512. "punpckhbw %%mm7, %%mm3\n" \
  513. "paddw " #in1 ", " #in0 "\n" \
  514. "paddw %%mm3, %%mm2\n" \
  515. "paddw %%mm2, " #in0 "\n" \
  516. "paddw " #in0 ", %%mm6\n"
  517. __asm__ volatile (
  518. "movl %4, %%ecx\n"
  519. "pxor %%mm6, %%mm6\n"
  520. "pcmpeqw %%mm7, %%mm7\n"
  521. "psllw $15, %%mm7\n"
  522. "packsswb %%mm7, %%mm7\n"
  523. "movq (%0), %%mm0\n"
  524. "movq (%1), %%mm2\n"
  525. "movq 8(%0), %%mm1\n"
  526. "movq 8(%1), %%mm3\n"
  527. "add %3, %0\n"
  528. "add %3, %1\n"
  529. "psubb %%mm2, %%mm0\n"
  530. "psubb %%mm3, %%mm1\n"
  531. "pxor %%mm7, %%mm0\n"
  532. "pxor %%mm7, %%mm1\n"
  533. "jmp 2f\n"
  534. "1:\n"
  535. SUM(%%mm4, %%mm5, %%mm0, %%mm1)
  536. "2:\n"
  537. SUM(%%mm0, %%mm1, %%mm4, %%mm5)
  538. "subl $2, %%ecx\n"
  539. "jnz 1b\n"
  540. "movq %%mm6, %%mm0\n"
  541. "psrlq $32, %%mm6\n"
  542. "paddw %%mm6, %%mm0\n"
  543. "movq %%mm0, %%mm6\n"
  544. "psrlq $16, %%mm0\n"
  545. "paddw %%mm6, %%mm0\n"
  546. "movd %%mm0, %2\n"
  547. : "+r" (pix1), "+r" (pix2), "=r" (tmp)
  548. : "r" ((x86_reg) line_size), "m" (h)
  549. : "%ecx");
  550. return tmp & 0x7FFF;
  551. }
  552. #undef SUM
  553. static int vsad16_mmxext(void *v, uint8_t *pix1, uint8_t *pix2,
  554. int line_size, int h)
  555. {
  556. int tmp;
  557. assert((((int) pix1) & 7) == 0);
  558. assert((((int) pix2) & 7) == 0);
  559. assert((line_size & 7) == 0);
  560. #define SUM(in0, in1, out0, out1) \
  561. "movq (%0), " #out0 "\n" \
  562. "movq (%1), %%mm2\n" \
  563. "movq 8(%0), " #out1 "\n" \
  564. "movq 8(%1), %%mm3\n" \
  565. "add %3, %0\n" \
  566. "add %3, %1\n" \
  567. "psubb %%mm2, " #out0 "\n" \
  568. "psubb %%mm3, " #out1 "\n" \
  569. "pxor %%mm7, " #out0 "\n" \
  570. "pxor %%mm7, " #out1 "\n" \
  571. "psadbw " #out0 ", " #in0 "\n" \
  572. "psadbw " #out1 ", " #in1 "\n" \
  573. "paddw " #in1 ", " #in0 "\n" \
  574. "paddw " #in0 ", %%mm6\n "
  575. __asm__ volatile (
  576. "movl %4, %%ecx\n"
  577. "pxor %%mm6, %%mm6\n"
  578. "pcmpeqw %%mm7, %%mm7\n"
  579. "psllw $15, %%mm7\n"
  580. "packsswb %%mm7, %%mm7\n"
  581. "movq (%0), %%mm0\n"
  582. "movq (%1), %%mm2\n"
  583. "movq 8(%0), %%mm1\n"
  584. "movq 8(%1), %%mm3\n"
  585. "add %3, %0\n"
  586. "add %3, %1\n"
  587. "psubb %%mm2, %%mm0\n"
  588. "psubb %%mm3, %%mm1\n"
  589. "pxor %%mm7, %%mm0\n"
  590. "pxor %%mm7, %%mm1\n"
  591. "jmp 2f\n"
  592. "1:\n"
  593. SUM(%%mm4, %%mm5, %%mm0, %%mm1)
  594. "2:\n"
  595. SUM(%%mm0, %%mm1, %%mm4, %%mm5)
  596. "subl $2, %%ecx\n"
  597. "jnz 1b\n"
  598. "movd %%mm6, %2\n"
  599. : "+r" (pix1), "+r" (pix2), "=r" (tmp)
  600. : "r" ((x86_reg) line_size), "m" (h)
  601. : "%ecx");
  602. return tmp;
  603. }
  604. #undef SUM
  605. static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
  606. {
  607. x86_reg i = 0;
  608. __asm__ volatile (
  609. "1: \n\t"
  610. "movq (%2, %0), %%mm0 \n\t"
  611. "movq (%1, %0), %%mm1 \n\t"
  612. "psubb %%mm0, %%mm1 \n\t"
  613. "movq %%mm1, (%3, %0) \n\t"
  614. "movq 8(%2, %0), %%mm0 \n\t"
  615. "movq 8(%1, %0), %%mm1 \n\t"
  616. "psubb %%mm0, %%mm1 \n\t"
  617. "movq %%mm1, 8(%3, %0) \n\t"
  618. "add $16, %0 \n\t"
  619. "cmp %4, %0 \n\t"
  620. " jb 1b \n\t"
  621. : "+r" (i)
  622. : "r" (src1), "r" (src2), "r" (dst), "r" ((x86_reg) w - 15));
  623. for (; i < w; i++)
  624. dst[i + 0] = src1[i + 0] - src2[i + 0];
  625. }
  626. static void sub_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *src1,
  627. const uint8_t *src2, int w,
  628. int *left, int *left_top)
  629. {
  630. x86_reg i = 0;
  631. uint8_t l, lt;
  632. __asm__ volatile (
  633. "movq (%1, %0), %%mm0 \n\t" // LT
  634. "psllq $8, %%mm0 \n\t"
  635. "1: \n\t"
  636. "movq (%1, %0), %%mm1 \n\t" // T
  637. "movq -1(%2, %0), %%mm2 \n\t" // L
  638. "movq (%2, %0), %%mm3 \n\t" // X
  639. "movq %%mm2, %%mm4 \n\t" // L
  640. "psubb %%mm0, %%mm2 \n\t"
  641. "paddb %%mm1, %%mm2 \n\t" // L + T - LT
  642. "movq %%mm4, %%mm5 \n\t" // L
  643. "pmaxub %%mm1, %%mm4 \n\t" // max(T, L)
  644. "pminub %%mm5, %%mm1 \n\t" // min(T, L)
  645. "pminub %%mm2, %%mm4 \n\t"
  646. "pmaxub %%mm1, %%mm4 \n\t"
  647. "psubb %%mm4, %%mm3 \n\t" // dst - pred
  648. "movq %%mm3, (%3, %0) \n\t"
  649. "add $8, %0 \n\t"
  650. "movq -1(%1, %0), %%mm0 \n\t" // LT
  651. "cmp %4, %0 \n\t"
  652. " jb 1b \n\t"
  653. : "+r" (i)
  654. : "r" (src1), "r" (src2), "r" (dst), "r" ((x86_reg) w));
  655. l = *left;
  656. lt = *left_top;
  657. dst[0] = src2[0] - mid_pred(l, src1[0], (l + src1[0] - lt) & 0xFF);
  658. *left_top = src1[w - 1];
  659. *left = src2[w - 1];
  660. }
  661. #define MMABS_MMX(a,z) \
  662. "pxor " #z ", " #z " \n\t" \
  663. "pcmpgtw " #a ", " #z " \n\t" \
  664. "pxor " #z ", " #a " \n\t" \
  665. "psubw " #z ", " #a " \n\t"
  666. #define MMABS_MMXEXT(a, z) \
  667. "pxor " #z ", " #z " \n\t" \
  668. "psubw " #a ", " #z " \n\t" \
  669. "pmaxsw " #z ", " #a " \n\t"
  670. #define MMABS_SSSE3(a,z) \
  671. "pabsw " #a ", " #a " \n\t"
  672. #define MMABS_SUM(a,z, sum) \
  673. MMABS(a,z) \
  674. "paddusw " #a ", " #sum " \n\t"
  675. /* FIXME: HSUM_* saturates at 64k, while an 8x8 hadamard or dct block can get
  676. * up to about 100k on extreme inputs. But that's very unlikely to occur in
  677. * natural video, and it's even more unlikely to not have any alternative
  678. * mvs/modes with lower cost. */
  679. #define HSUM_MMX(a, t, dst) \
  680. "movq " #a ", " #t " \n\t" \
  681. "psrlq $32, " #a " \n\t" \
  682. "paddusw " #t ", " #a " \n\t" \
  683. "movq " #a ", " #t " \n\t" \
  684. "psrlq $16, " #a " \n\t" \
  685. "paddusw " #t ", " #a " \n\t" \
  686. "movd " #a ", " #dst " \n\t" \
  687. #define HSUM_MMXEXT(a, t, dst) \
  688. "pshufw $0x0E, " #a ", " #t " \n\t" \
  689. "paddusw " #t ", " #a " \n\t" \
  690. "pshufw $0x01, " #a ", " #t " \n\t" \
  691. "paddusw " #t ", " #a " \n\t" \
  692. "movd " #a ", " #dst " \n\t" \
  693. #define HSUM_SSE2(a, t, dst) \
  694. "movhlps " #a ", " #t " \n\t" \
  695. "paddusw " #t ", " #a " \n\t" \
  696. "pshuflw $0x0E, " #a ", " #t " \n\t" \
  697. "paddusw " #t ", " #a " \n\t" \
  698. "pshuflw $0x01, " #a ", " #t " \n\t" \
  699. "paddusw " #t ", " #a " \n\t" \
  700. "movd " #a ", " #dst " \n\t" \
  701. #define DCT_SAD4(m, mm, o) \
  702. "mov"#m" "#o" + 0(%1), " #mm "2 \n\t" \
  703. "mov"#m" "#o" + 16(%1), " #mm "3 \n\t" \
  704. "mov"#m" "#o" + 32(%1), " #mm "4 \n\t" \
  705. "mov"#m" "#o" + 48(%1), " #mm "5 \n\t" \
  706. MMABS_SUM(mm ## 2, mm ## 6, mm ## 0) \
  707. MMABS_SUM(mm ## 3, mm ## 7, mm ## 1) \
  708. MMABS_SUM(mm ## 4, mm ## 6, mm ## 0) \
  709. MMABS_SUM(mm ## 5, mm ## 7, mm ## 1) \
  710. #define DCT_SAD_MMX \
  711. "pxor %%mm0, %%mm0 \n\t" \
  712. "pxor %%mm1, %%mm1 \n\t" \
  713. DCT_SAD4(q, %%mm, 0) \
  714. DCT_SAD4(q, %%mm, 8) \
  715. DCT_SAD4(q, %%mm, 64) \
  716. DCT_SAD4(q, %%mm, 72) \
  717. "paddusw %%mm1, %%mm0 \n\t" \
  718. HSUM(%%mm0, %%mm1, %0)
  719. #define DCT_SAD_SSE2 \
  720. "pxor %%xmm0, %%xmm0 \n\t" \
  721. "pxor %%xmm1, %%xmm1 \n\t" \
  722. DCT_SAD4(dqa, %%xmm, 0) \
  723. DCT_SAD4(dqa, %%xmm, 64) \
  724. "paddusw %%xmm1, %%xmm0 \n\t" \
  725. HSUM(%%xmm0, %%xmm1, %0)
  726. #define DCT_SAD_FUNC(cpu) \
  727. static int sum_abs_dctelem_ ## cpu(int16_t *block) \
  728. { \
  729. int sum; \
  730. __asm__ volatile ( \
  731. DCT_SAD \
  732. :"=r"(sum) \
  733. :"r"(block)); \
  734. return sum & 0xFFFF; \
  735. }
  736. #define DCT_SAD DCT_SAD_MMX
  737. #define HSUM(a, t, dst) HSUM_MMX(a, t, dst)
  738. #define MMABS(a, z) MMABS_MMX(a, z)
  739. DCT_SAD_FUNC(mmx)
  740. #undef MMABS
  741. #undef HSUM
  742. #define HSUM(a, t, dst) HSUM_MMXEXT(a, t, dst)
  743. #define MMABS(a, z) MMABS_MMXEXT(a, z)
  744. DCT_SAD_FUNC(mmxext)
  745. #undef HSUM
  746. #undef DCT_SAD
  747. #define DCT_SAD DCT_SAD_SSE2
  748. #define HSUM(a, t, dst) HSUM_SSE2(a, t, dst)
  749. DCT_SAD_FUNC(sse2)
  750. #undef MMABS
  751. #if HAVE_SSSE3_INLINE
  752. #define MMABS(a, z) MMABS_SSSE3(a, z)
  753. DCT_SAD_FUNC(ssse3)
  754. #undef MMABS
  755. #endif
  756. #undef HSUM
  757. #undef DCT_SAD
  758. static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2,
  759. int size)
  760. {
  761. int sum;
  762. x86_reg i = size;
  763. __asm__ volatile (
  764. "pxor %%mm4, %%mm4 \n"
  765. "1: \n"
  766. "sub $8, %0 \n"
  767. "movq (%2, %0), %%mm2 \n"
  768. "movq (%3, %0, 2), %%mm0 \n"
  769. "movq 8(%3, %0, 2), %%mm1 \n"
  770. "punpckhbw %%mm2, %%mm3 \n"
  771. "punpcklbw %%mm2, %%mm2 \n"
  772. "psraw $8, %%mm3 \n"
  773. "psraw $8, %%mm2 \n"
  774. "psubw %%mm3, %%mm1 \n"
  775. "psubw %%mm2, %%mm0 \n"
  776. "pmaddwd %%mm1, %%mm1 \n"
  777. "pmaddwd %%mm0, %%mm0 \n"
  778. "paddd %%mm1, %%mm4 \n"
  779. "paddd %%mm0, %%mm4 \n"
  780. "jg 1b \n"
  781. "movq %%mm4, %%mm3 \n"
  782. "psrlq $32, %%mm3 \n"
  783. "paddd %%mm3, %%mm4 \n"
  784. "movd %%mm4, %1 \n"
  785. : "+r" (i), "=r" (sum)
  786. : "r" (pix1), "r" (pix2));
  787. return sum;
  788. }
  789. #define PHADDD(a, t) \
  790. "movq " #a ", " #t " \n\t" \
  791. "psrlq $32, " #a " \n\t" \
  792. "paddd " #t ", " #a " \n\t"
  793. /*
  794. * pmulhw: dst[0 - 15] = (src[0 - 15] * dst[0 - 15])[16 - 31]
  795. * pmulhrw: dst[0 - 15] = (src[0 - 15] * dst[0 - 15] + 0x8000)[16 - 31]
  796. * pmulhrsw: dst[0 - 15] = (src[0 - 15] * dst[0 - 15] + 0x4000)[15 - 30]
  797. */
  798. #define PMULHRW(x, y, s, o) \
  799. "pmulhw " #s ", " #x " \n\t" \
  800. "pmulhw " #s ", " #y " \n\t" \
  801. "paddw " #o ", " #x " \n\t" \
  802. "paddw " #o ", " #y " \n\t" \
  803. "psraw $1, " #x " \n\t" \
  804. "psraw $1, " #y " \n\t"
  805. #define DEF(x) x ## _mmx
  806. #define SET_RND MOVQ_WONE
  807. #define SCALE_OFFSET 1
  808. #include "dsputil_qns_template.c"
  809. #undef DEF
  810. #undef SET_RND
  811. #undef SCALE_OFFSET
  812. #undef PMULHRW
  813. #define DEF(x) x ## _3dnow
  814. #define SET_RND(x)
  815. #define SCALE_OFFSET 0
  816. #define PMULHRW(x, y, s, o) \
  817. "pmulhrw " #s ", " #x " \n\t" \
  818. "pmulhrw " #s ", " #y " \n\t"
  819. #include "dsputil_qns_template.c"
  820. #undef DEF
  821. #undef SET_RND
  822. #undef SCALE_OFFSET
  823. #undef PMULHRW
  824. #if HAVE_SSSE3_INLINE
  825. #undef PHADDD
  826. #define DEF(x) x ## _ssse3
  827. #define SET_RND(x)
  828. #define SCALE_OFFSET -1
  829. #define PHADDD(a, t) \
  830. "pshufw $0x0E, " #a ", " #t " \n\t" \
  831. /* faster than phaddd on core2 */ \
  832. "paddd " #t ", " #a " \n\t"
  833. #define PMULHRW(x, y, s, o) \
  834. "pmulhrsw " #s ", " #x " \n\t" \
  835. "pmulhrsw " #s ", " #y " \n\t"
  836. #include "dsputil_qns_template.c"
  837. #undef DEF
  838. #undef SET_RND
  839. #undef SCALE_OFFSET
  840. #undef PMULHRW
  841. #undef PHADDD
  842. #endif /* HAVE_SSSE3_INLINE */
  843. #endif /* HAVE_INLINE_ASM */
  844. int ff_sse16_sse2(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
  845. #define hadamard_func(cpu) \
  846. int ff_hadamard8_diff_ ## cpu(void *s, uint8_t *src1, uint8_t *src2, \
  847. int stride, int h); \
  848. int ff_hadamard8_diff16_ ## cpu(void *s, uint8_t *src1, uint8_t *src2, \
  849. int stride, int h);
  850. hadamard_func(mmx)
  851. hadamard_func(mmxext)
  852. hadamard_func(sse2)
  853. hadamard_func(ssse3)
  854. av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
  855. {
  856. int cpu_flags = av_get_cpu_flags();
  857. const int dct_algo = avctx->dct_algo;
  858. #if HAVE_YASM
  859. int bit_depth = avctx->bits_per_raw_sample;
  860. if (EXTERNAL_MMX(cpu_flags)) {
  861. if (bit_depth <= 8)
  862. c->get_pixels = ff_get_pixels_mmx;
  863. c->diff_pixels = ff_diff_pixels_mmx;
  864. c->pix_sum = ff_pix_sum16_mmx;
  865. c->pix_norm1 = ff_pix_norm1_mmx;
  866. }
  867. if (EXTERNAL_SSE2(cpu_flags))
  868. if (bit_depth <= 8)
  869. c->get_pixels = ff_get_pixels_sse2;
  870. #endif /* HAVE_YASM */
  871. #if HAVE_INLINE_ASM
  872. if (INLINE_MMX(cpu_flags)) {
  873. if (avctx->bits_per_raw_sample <= 8 &&
  874. (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
  875. c->fdct = ff_fdct_mmx;
  876. c->diff_bytes = diff_bytes_mmx;
  877. c->sum_abs_dctelem = sum_abs_dctelem_mmx;
  878. c->sse[0] = sse16_mmx;
  879. c->sse[1] = sse8_mmx;
  880. c->vsad[4] = vsad_intra16_mmx;
  881. c->nsse[0] = nsse16_mmx;
  882. c->nsse[1] = nsse8_mmx;
  883. if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
  884. c->vsad[0] = vsad16_mmx;
  885. c->try_8x8basis = try_8x8basis_mmx;
  886. }
  887. c->add_8x8basis = add_8x8basis_mmx;
  888. c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;
  889. }
  890. if (INLINE_AMD3DNOW(cpu_flags)) {
  891. if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
  892. c->try_8x8basis = try_8x8basis_3dnow;
  893. }
  894. c->add_8x8basis = add_8x8basis_3dnow;
  895. }
  896. if (INLINE_MMXEXT(cpu_flags)) {
  897. if (avctx->bits_per_raw_sample <= 8 &&
  898. (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
  899. c->fdct = ff_fdct_mmxext;
  900. c->sum_abs_dctelem = sum_abs_dctelem_mmxext;
  901. c->vsad[4] = vsad_intra16_mmxext;
  902. if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
  903. c->vsad[0] = vsad16_mmxext;
  904. }
  905. c->sub_hfyu_median_prediction = sub_hfyu_median_prediction_mmxext;
  906. }
  907. if (INLINE_SSE2(cpu_flags)) {
  908. if (avctx->bits_per_raw_sample <= 8 &&
  909. (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
  910. c->fdct = ff_fdct_sse2;
  911. c->sum_abs_dctelem = sum_abs_dctelem_sse2;
  912. }
  913. #if HAVE_SSSE3_INLINE
  914. if (INLINE_SSSE3(cpu_flags)) {
  915. if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
  916. c->try_8x8basis = try_8x8basis_ssse3;
  917. }
  918. c->add_8x8basis = add_8x8basis_ssse3;
  919. c->sum_abs_dctelem = sum_abs_dctelem_ssse3;
  920. }
  921. #endif
  922. #endif /* HAVE_INLINE_ASM */
  923. if (EXTERNAL_MMX(cpu_flags)) {
  924. c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx;
  925. c->hadamard8_diff[1] = ff_hadamard8_diff_mmx;
  926. }
  927. if (EXTERNAL_MMXEXT(cpu_flags)) {
  928. c->hadamard8_diff[0] = ff_hadamard8_diff16_mmxext;
  929. c->hadamard8_diff[1] = ff_hadamard8_diff_mmxext;
  930. }
  931. if (EXTERNAL_SSE2(cpu_flags)) {
  932. c->sse[0] = ff_sse16_sse2;
  933. #if HAVE_ALIGNED_STACK
  934. c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2;
  935. c->hadamard8_diff[1] = ff_hadamard8_diff_sse2;
  936. #endif
  937. }
  938. if (EXTERNAL_SSSE3(cpu_flags) && HAVE_ALIGNED_STACK) {
  939. c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3;
  940. c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3;
  941. }
  942. ff_dsputil_init_pix_mmx(c, avctx);
  943. }