mpegvideo.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. /*
  2. * Optimized for ia32 CPUs by Nick Kurshev <nickols_k@mail.ru>
  3. * H.263, MPEG-1, MPEG-2 dequantizer & draw_edges by Michael Niedermayer <michaelni@gmx.at>
  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/avcodec.h"
  26. #include "libavcodec/mpegvideo.h"
  27. #include "libavcodec/mpegvideodata.h"
  28. #if HAVE_MMX_INLINE
  29. static void dct_unquantize_h263_intra_mmx(MpegEncContext *s,
  30. int16_t *block, int n, int qscale)
  31. {
  32. x86_reg level, qmul, qadd, nCoeffs;
  33. qmul = qscale << 1;
  34. av_assert2(s->block_last_index[n]>=0 || s->h263_aic);
  35. if (!s->h263_aic) {
  36. if (n < 4)
  37. level = block[0] * s->y_dc_scale;
  38. else
  39. level = block[0] * s->c_dc_scale;
  40. qadd = (qscale - 1) | 1;
  41. }else{
  42. qadd = 0;
  43. level= block[0];
  44. }
  45. if(s->ac_pred)
  46. nCoeffs=63;
  47. else
  48. nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
  49. __asm__ volatile(
  50. "movd %1, %%mm6 \n\t" //qmul
  51. "packssdw %%mm6, %%mm6 \n\t"
  52. "packssdw %%mm6, %%mm6 \n\t"
  53. "movd %2, %%mm5 \n\t" //qadd
  54. "pxor %%mm7, %%mm7 \n\t"
  55. "packssdw %%mm5, %%mm5 \n\t"
  56. "packssdw %%mm5, %%mm5 \n\t"
  57. "psubw %%mm5, %%mm7 \n\t"
  58. "pxor %%mm4, %%mm4 \n\t"
  59. ".p2align 4 \n\t"
  60. "1: \n\t"
  61. "movq (%0, %3), %%mm0 \n\t"
  62. "movq 8(%0, %3), %%mm1 \n\t"
  63. "pmullw %%mm6, %%mm0 \n\t"
  64. "pmullw %%mm6, %%mm1 \n\t"
  65. "movq (%0, %3), %%mm2 \n\t"
  66. "movq 8(%0, %3), %%mm3 \n\t"
  67. "pcmpgtw %%mm4, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
  68. "pcmpgtw %%mm4, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
  69. "pxor %%mm2, %%mm0 \n\t"
  70. "pxor %%mm3, %%mm1 \n\t"
  71. "paddw %%mm7, %%mm0 \n\t"
  72. "paddw %%mm7, %%mm1 \n\t"
  73. "pxor %%mm0, %%mm2 \n\t"
  74. "pxor %%mm1, %%mm3 \n\t"
  75. "pcmpeqw %%mm7, %%mm0 \n\t" // block[i] == 0 ? -1 : 0
  76. "pcmpeqw %%mm7, %%mm1 \n\t" // block[i] == 0 ? -1 : 0
  77. "pandn %%mm2, %%mm0 \n\t"
  78. "pandn %%mm3, %%mm1 \n\t"
  79. "movq %%mm0, (%0, %3) \n\t"
  80. "movq %%mm1, 8(%0, %3) \n\t"
  81. "add $16, %3 \n\t"
  82. "jng 1b \n\t"
  83. ::"r" (block+nCoeffs), "rm"(qmul), "rm" (qadd), "r" (2*(-nCoeffs))
  84. : "memory"
  85. );
  86. block[0]= level;
  87. }
  88. static void dct_unquantize_h263_inter_mmx(MpegEncContext *s,
  89. int16_t *block, int n, int qscale)
  90. {
  91. x86_reg qmul, qadd, nCoeffs;
  92. qmul = qscale << 1;
  93. qadd = (qscale - 1) | 1;
  94. av_assert2(s->block_last_index[n]>=0 || s->h263_aic);
  95. nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
  96. __asm__ volatile(
  97. "movd %1, %%mm6 \n\t" //qmul
  98. "packssdw %%mm6, %%mm6 \n\t"
  99. "packssdw %%mm6, %%mm6 \n\t"
  100. "movd %2, %%mm5 \n\t" //qadd
  101. "pxor %%mm7, %%mm7 \n\t"
  102. "packssdw %%mm5, %%mm5 \n\t"
  103. "packssdw %%mm5, %%mm5 \n\t"
  104. "psubw %%mm5, %%mm7 \n\t"
  105. "pxor %%mm4, %%mm4 \n\t"
  106. ".p2align 4 \n\t"
  107. "1: \n\t"
  108. "movq (%0, %3), %%mm0 \n\t"
  109. "movq 8(%0, %3), %%mm1 \n\t"
  110. "pmullw %%mm6, %%mm0 \n\t"
  111. "pmullw %%mm6, %%mm1 \n\t"
  112. "movq (%0, %3), %%mm2 \n\t"
  113. "movq 8(%0, %3), %%mm3 \n\t"
  114. "pcmpgtw %%mm4, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
  115. "pcmpgtw %%mm4, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
  116. "pxor %%mm2, %%mm0 \n\t"
  117. "pxor %%mm3, %%mm1 \n\t"
  118. "paddw %%mm7, %%mm0 \n\t"
  119. "paddw %%mm7, %%mm1 \n\t"
  120. "pxor %%mm0, %%mm2 \n\t"
  121. "pxor %%mm1, %%mm3 \n\t"
  122. "pcmpeqw %%mm7, %%mm0 \n\t" // block[i] == 0 ? -1 : 0
  123. "pcmpeqw %%mm7, %%mm1 \n\t" // block[i] == 0 ? -1 : 0
  124. "pandn %%mm2, %%mm0 \n\t"
  125. "pandn %%mm3, %%mm1 \n\t"
  126. "movq %%mm0, (%0, %3) \n\t"
  127. "movq %%mm1, 8(%0, %3) \n\t"
  128. "add $16, %3 \n\t"
  129. "jng 1b \n\t"
  130. ::"r" (block+nCoeffs), "rm"(qmul), "rm" (qadd), "r" (2*(-nCoeffs))
  131. : "memory"
  132. );
  133. }
  134. static void dct_unquantize_mpeg1_intra_mmx(MpegEncContext *s,
  135. int16_t *block, int n, int qscale)
  136. {
  137. x86_reg nCoeffs;
  138. const uint16_t *quant_matrix;
  139. int block0;
  140. av_assert2(s->block_last_index[n]>=0);
  141. nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]+1;
  142. if (n < 4)
  143. block0 = block[0] * s->y_dc_scale;
  144. else
  145. block0 = block[0] * s->c_dc_scale;
  146. /* XXX: only MPEG-1 */
  147. quant_matrix = s->intra_matrix;
  148. __asm__ volatile(
  149. "pcmpeqw %%mm7, %%mm7 \n\t"
  150. "psrlw $15, %%mm7 \n\t"
  151. "movd %2, %%mm6 \n\t"
  152. "packssdw %%mm6, %%mm6 \n\t"
  153. "packssdw %%mm6, %%mm6 \n\t"
  154. "mov %3, %%"FF_REG_a" \n\t"
  155. ".p2align 4 \n\t"
  156. "1: \n\t"
  157. "movq (%0, %%"FF_REG_a"), %%mm0 \n\t"
  158. "movq 8(%0, %%"FF_REG_a"), %%mm1\n\t"
  159. "movq (%1, %%"FF_REG_a"), %%mm4 \n\t"
  160. "movq 8(%1, %%"FF_REG_a"), %%mm5\n\t"
  161. "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
  162. "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
  163. "pxor %%mm2, %%mm2 \n\t"
  164. "pxor %%mm3, %%mm3 \n\t"
  165. "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
  166. "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
  167. "pxor %%mm2, %%mm0 \n\t"
  168. "pxor %%mm3, %%mm1 \n\t"
  169. "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
  170. "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
  171. "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q
  172. "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q
  173. "pxor %%mm4, %%mm4 \n\t"
  174. "pxor %%mm5, %%mm5 \n\t" // FIXME slow
  175. "pcmpeqw (%0, %%"FF_REG_a"), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
  176. "pcmpeqw 8(%0, %%"FF_REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
  177. "psraw $3, %%mm0 \n\t"
  178. "psraw $3, %%mm1 \n\t"
  179. "psubw %%mm7, %%mm0 \n\t"
  180. "psubw %%mm7, %%mm1 \n\t"
  181. "por %%mm7, %%mm0 \n\t"
  182. "por %%mm7, %%mm1 \n\t"
  183. "pxor %%mm2, %%mm0 \n\t"
  184. "pxor %%mm3, %%mm1 \n\t"
  185. "psubw %%mm2, %%mm0 \n\t"
  186. "psubw %%mm3, %%mm1 \n\t"
  187. "pandn %%mm0, %%mm4 \n\t"
  188. "pandn %%mm1, %%mm5 \n\t"
  189. "movq %%mm4, (%0, %%"FF_REG_a") \n\t"
  190. "movq %%mm5, 8(%0, %%"FF_REG_a")\n\t"
  191. "add $16, %%"FF_REG_a" \n\t"
  192. "js 1b \n\t"
  193. ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "rm" (qscale), "g" (-2*nCoeffs)
  194. : "%"FF_REG_a, "memory"
  195. );
  196. block[0]= block0;
  197. }
  198. static void dct_unquantize_mpeg1_inter_mmx(MpegEncContext *s,
  199. int16_t *block, int n, int qscale)
  200. {
  201. x86_reg nCoeffs;
  202. const uint16_t *quant_matrix;
  203. av_assert2(s->block_last_index[n]>=0);
  204. nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]+1;
  205. quant_matrix = s->inter_matrix;
  206. __asm__ volatile(
  207. "pcmpeqw %%mm7, %%mm7 \n\t"
  208. "psrlw $15, %%mm7 \n\t"
  209. "movd %2, %%mm6 \n\t"
  210. "packssdw %%mm6, %%mm6 \n\t"
  211. "packssdw %%mm6, %%mm6 \n\t"
  212. "mov %3, %%"FF_REG_a" \n\t"
  213. ".p2align 4 \n\t"
  214. "1: \n\t"
  215. "movq (%0, %%"FF_REG_a"), %%mm0 \n\t"
  216. "movq 8(%0, %%"FF_REG_a"), %%mm1\n\t"
  217. "movq (%1, %%"FF_REG_a"), %%mm4 \n\t"
  218. "movq 8(%1, %%"FF_REG_a"), %%mm5\n\t"
  219. "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
  220. "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
  221. "pxor %%mm2, %%mm2 \n\t"
  222. "pxor %%mm3, %%mm3 \n\t"
  223. "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
  224. "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
  225. "pxor %%mm2, %%mm0 \n\t"
  226. "pxor %%mm3, %%mm1 \n\t"
  227. "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
  228. "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
  229. "paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2
  230. "paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2
  231. "paddw %%mm7, %%mm0 \n\t" // abs(block[i])*2 + 1
  232. "paddw %%mm7, %%mm1 \n\t" // abs(block[i])*2 + 1
  233. "pmullw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q
  234. "pmullw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q
  235. "pxor %%mm4, %%mm4 \n\t"
  236. "pxor %%mm5, %%mm5 \n\t" // FIXME slow
  237. "pcmpeqw (%0, %%"FF_REG_a"), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
  238. "pcmpeqw 8(%0, %%"FF_REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
  239. "psraw $4, %%mm0 \n\t"
  240. "psraw $4, %%mm1 \n\t"
  241. "psubw %%mm7, %%mm0 \n\t"
  242. "psubw %%mm7, %%mm1 \n\t"
  243. "por %%mm7, %%mm0 \n\t"
  244. "por %%mm7, %%mm1 \n\t"
  245. "pxor %%mm2, %%mm0 \n\t"
  246. "pxor %%mm3, %%mm1 \n\t"
  247. "psubw %%mm2, %%mm0 \n\t"
  248. "psubw %%mm3, %%mm1 \n\t"
  249. "pandn %%mm0, %%mm4 \n\t"
  250. "pandn %%mm1, %%mm5 \n\t"
  251. "movq %%mm4, (%0, %%"FF_REG_a") \n\t"
  252. "movq %%mm5, 8(%0, %%"FF_REG_a")\n\t"
  253. "add $16, %%"FF_REG_a" \n\t"
  254. "js 1b \n\t"
  255. ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "rm" (qscale), "g" (-2*nCoeffs)
  256. : "%"FF_REG_a, "memory"
  257. );
  258. }
  259. static void dct_unquantize_mpeg2_intra_mmx(MpegEncContext *s,
  260. int16_t *block, int n, int qscale)
  261. {
  262. x86_reg nCoeffs;
  263. const uint16_t *quant_matrix;
  264. int block0;
  265. av_assert2(s->block_last_index[n]>=0);
  266. if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale];
  267. else qscale <<= 1;
  268. if(s->alternate_scan) nCoeffs= 63; //FIXME
  269. else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
  270. if (n < 4)
  271. block0 = block[0] * s->y_dc_scale;
  272. else
  273. block0 = block[0] * s->c_dc_scale;
  274. quant_matrix = s->intra_matrix;
  275. __asm__ volatile(
  276. "pcmpeqw %%mm7, %%mm7 \n\t"
  277. "psrlw $15, %%mm7 \n\t"
  278. "movd %2, %%mm6 \n\t"
  279. "packssdw %%mm6, %%mm6 \n\t"
  280. "packssdw %%mm6, %%mm6 \n\t"
  281. "mov %3, %%"FF_REG_a" \n\t"
  282. ".p2align 4 \n\t"
  283. "1: \n\t"
  284. "movq (%0, %%"FF_REG_a"), %%mm0 \n\t"
  285. "movq 8(%0, %%"FF_REG_a"), %%mm1\n\t"
  286. "movq (%1, %%"FF_REG_a"), %%mm4 \n\t"
  287. "movq 8(%1, %%"FF_REG_a"), %%mm5\n\t"
  288. "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
  289. "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
  290. "pxor %%mm2, %%mm2 \n\t"
  291. "pxor %%mm3, %%mm3 \n\t"
  292. "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
  293. "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
  294. "pxor %%mm2, %%mm0 \n\t"
  295. "pxor %%mm3, %%mm1 \n\t"
  296. "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
  297. "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
  298. "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q
  299. "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q
  300. "pxor %%mm4, %%mm4 \n\t"
  301. "pxor %%mm5, %%mm5 \n\t" // FIXME slow
  302. "pcmpeqw (%0, %%"FF_REG_a"), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
  303. "pcmpeqw 8(%0, %%"FF_REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
  304. "psraw $4, %%mm0 \n\t"
  305. "psraw $4, %%mm1 \n\t"
  306. "pxor %%mm2, %%mm0 \n\t"
  307. "pxor %%mm3, %%mm1 \n\t"
  308. "psubw %%mm2, %%mm0 \n\t"
  309. "psubw %%mm3, %%mm1 \n\t"
  310. "pandn %%mm0, %%mm4 \n\t"
  311. "pandn %%mm1, %%mm5 \n\t"
  312. "movq %%mm4, (%0, %%"FF_REG_a") \n\t"
  313. "movq %%mm5, 8(%0, %%"FF_REG_a")\n\t"
  314. "add $16, %%"FF_REG_a" \n\t"
  315. "jng 1b \n\t"
  316. ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "rm" (qscale), "g" (-2*nCoeffs)
  317. : "%"FF_REG_a, "memory"
  318. );
  319. block[0]= block0;
  320. //Note, we do not do mismatch control for intra as errors cannot accumulate
  321. }
  322. static void dct_unquantize_mpeg2_inter_mmx(MpegEncContext *s,
  323. int16_t *block, int n, int qscale)
  324. {
  325. x86_reg nCoeffs;
  326. const uint16_t *quant_matrix;
  327. av_assert2(s->block_last_index[n]>=0);
  328. if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale];
  329. else qscale <<= 1;
  330. if(s->alternate_scan) nCoeffs= 63; //FIXME
  331. else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
  332. quant_matrix = s->inter_matrix;
  333. __asm__ volatile(
  334. "pcmpeqw %%mm7, %%mm7 \n\t"
  335. "psrlq $48, %%mm7 \n\t"
  336. "movd %2, %%mm6 \n\t"
  337. "packssdw %%mm6, %%mm6 \n\t"
  338. "packssdw %%mm6, %%mm6 \n\t"
  339. "mov %3, %%"FF_REG_a" \n\t"
  340. ".p2align 4 \n\t"
  341. "1: \n\t"
  342. "movq (%0, %%"FF_REG_a"), %%mm0 \n\t"
  343. "movq 8(%0, %%"FF_REG_a"), %%mm1\n\t"
  344. "movq (%1, %%"FF_REG_a"), %%mm4 \n\t"
  345. "movq 8(%1, %%"FF_REG_a"), %%mm5\n\t"
  346. "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
  347. "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
  348. "pxor %%mm2, %%mm2 \n\t"
  349. "pxor %%mm3, %%mm3 \n\t"
  350. "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
  351. "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
  352. "pxor %%mm2, %%mm0 \n\t"
  353. "pxor %%mm3, %%mm1 \n\t"
  354. "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
  355. "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
  356. "paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2
  357. "paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2
  358. "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*2*q
  359. "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*2*q
  360. "paddw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q
  361. "paddw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q
  362. "pxor %%mm4, %%mm4 \n\t"
  363. "pxor %%mm5, %%mm5 \n\t" // FIXME slow
  364. "pcmpeqw (%0, %%"FF_REG_a"), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
  365. "pcmpeqw 8(%0, %%"FF_REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
  366. "psrlw $5, %%mm0 \n\t"
  367. "psrlw $5, %%mm1 \n\t"
  368. "pxor %%mm2, %%mm0 \n\t"
  369. "pxor %%mm3, %%mm1 \n\t"
  370. "psubw %%mm2, %%mm0 \n\t"
  371. "psubw %%mm3, %%mm1 \n\t"
  372. "pandn %%mm0, %%mm4 \n\t"
  373. "pandn %%mm1, %%mm5 \n\t"
  374. "pxor %%mm4, %%mm7 \n\t"
  375. "pxor %%mm5, %%mm7 \n\t"
  376. "movq %%mm4, (%0, %%"FF_REG_a") \n\t"
  377. "movq %%mm5, 8(%0, %%"FF_REG_a")\n\t"
  378. "add $16, %%"FF_REG_a" \n\t"
  379. "jng 1b \n\t"
  380. "movd 124(%0, %3), %%mm0 \n\t"
  381. "movq %%mm7, %%mm6 \n\t"
  382. "psrlq $32, %%mm7 \n\t"
  383. "pxor %%mm6, %%mm7 \n\t"
  384. "movq %%mm7, %%mm6 \n\t"
  385. "psrlq $16, %%mm7 \n\t"
  386. "pxor %%mm6, %%mm7 \n\t"
  387. "pslld $31, %%mm7 \n\t"
  388. "psrlq $15, %%mm7 \n\t"
  389. "pxor %%mm7, %%mm0 \n\t"
  390. "movd %%mm0, 124(%0, %3) \n\t"
  391. ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "rm" (qscale), "r" (-2*nCoeffs)
  392. : "%"FF_REG_a, "memory"
  393. );
  394. }
  395. #endif /* HAVE_MMX_INLINE */
  396. av_cold void ff_mpv_common_init_x86(MpegEncContext *s)
  397. {
  398. #if HAVE_MMX_INLINE
  399. int cpu_flags = av_get_cpu_flags();
  400. if (INLINE_MMX(cpu_flags)) {
  401. s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_mmx;
  402. s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_mmx;
  403. s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_mmx;
  404. s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_mmx;
  405. if (!(s->avctx->flags & AV_CODEC_FLAG_BITEXACT))
  406. s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_mmx;
  407. s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_mmx;
  408. }
  409. #endif /* HAVE_MMX_INLINE */
  410. }