snowdsp_mmx.c 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. /*
  2. * MMX and SSE2 optimized snow DSP utils
  3. * Copyright (c) 2005-2006 Robert Edele <yartrebo@earthlink.net>
  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/x86_cpu.h"
  22. #include "libavcodec/avcodec.h"
  23. #include "libavcodec/snow.h"
  24. void ff_snow_horizontal_compose97i_sse2(IDWTELEM *b, int width){
  25. const int w2= (width+1)>>1;
  26. DECLARE_ALIGNED_16(IDWTELEM, temp[width>>1]);
  27. const int w_l= (width>>1);
  28. const int w_r= w2 - 1;
  29. int i;
  30. { // Lift 0
  31. IDWTELEM * const ref = b + w2 - 1;
  32. IDWTELEM b_0 = b[0]; //By allowing the first entry in b[0] to be calculated twice
  33. // (the first time erroneously), we allow the SSE2 code to run an extra pass.
  34. // The savings in code and time are well worth having to store this value and
  35. // calculate b[0] correctly afterwards.
  36. i = 0;
  37. __asm__ volatile(
  38. "pcmpeqd %%xmm7, %%xmm7 \n\t"
  39. "pcmpeqd %%xmm3, %%xmm3 \n\t"
  40. "psllw $1, %%xmm3 \n\t"
  41. "paddw %%xmm7, %%xmm3 \n\t"
  42. "psllw $13, %%xmm3 \n\t"
  43. ::);
  44. for(; i<w_l-15; i+=16){
  45. __asm__ volatile(
  46. "movdqu (%1), %%xmm1 \n\t"
  47. "movdqu 16(%1), %%xmm5 \n\t"
  48. "movdqu 2(%1), %%xmm2 \n\t"
  49. "movdqu 18(%1), %%xmm6 \n\t"
  50. "paddw %%xmm1, %%xmm2 \n\t"
  51. "paddw %%xmm5, %%xmm6 \n\t"
  52. "paddw %%xmm7, %%xmm2 \n\t"
  53. "paddw %%xmm7, %%xmm6 \n\t"
  54. "pmulhw %%xmm3, %%xmm2 \n\t"
  55. "pmulhw %%xmm3, %%xmm6 \n\t"
  56. "paddw (%0), %%xmm2 \n\t"
  57. "paddw 16(%0), %%xmm6 \n\t"
  58. "movdqa %%xmm2, (%0) \n\t"
  59. "movdqa %%xmm6, 16(%0) \n\t"
  60. :: "r"(&b[i]), "r"(&ref[i])
  61. : "memory"
  62. );
  63. }
  64. snow_horizontal_compose_lift_lead_out(i, b, b, ref, width, w_l, 0, W_DM, W_DO, W_DS);
  65. b[0] = b_0 - ((W_DM * 2 * ref[1]+W_DO)>>W_DS);
  66. }
  67. { // Lift 1
  68. IDWTELEM * const dst = b+w2;
  69. i = 0;
  70. for(; (((x86_reg)&dst[i]) & 0x1F) && i<w_r; i++){
  71. dst[i] = dst[i] - (b[i] + b[i + 1]);
  72. }
  73. for(; i<w_r-15; i+=16){
  74. __asm__ volatile(
  75. "movdqu (%1), %%xmm1 \n\t"
  76. "movdqu 16(%1), %%xmm5 \n\t"
  77. "movdqu 2(%1), %%xmm2 \n\t"
  78. "movdqu 18(%1), %%xmm6 \n\t"
  79. "paddw %%xmm1, %%xmm2 \n\t"
  80. "paddw %%xmm5, %%xmm6 \n\t"
  81. "movdqa (%0), %%xmm0 \n\t"
  82. "movdqa 16(%0), %%xmm4 \n\t"
  83. "psubw %%xmm2, %%xmm0 \n\t"
  84. "psubw %%xmm6, %%xmm4 \n\t"
  85. "movdqa %%xmm0, (%0) \n\t"
  86. "movdqa %%xmm4, 16(%0) \n\t"
  87. :: "r"(&dst[i]), "r"(&b[i])
  88. : "memory"
  89. );
  90. }
  91. snow_horizontal_compose_lift_lead_out(i, dst, dst, b, width, w_r, 1, W_CM, W_CO, W_CS);
  92. }
  93. { // Lift 2
  94. IDWTELEM * const ref = b+w2 - 1;
  95. IDWTELEM b_0 = b[0];
  96. i = 0;
  97. __asm__ volatile(
  98. "psllw $15, %%xmm7 \n\t"
  99. "pcmpeqw %%xmm6, %%xmm6 \n\t"
  100. "psrlw $13, %%xmm6 \n\t"
  101. "paddw %%xmm7, %%xmm6 \n\t"
  102. ::);
  103. for(; i<w_l-15; i+=16){
  104. __asm__ volatile(
  105. "movdqu (%1), %%xmm0 \n\t"
  106. "movdqu 16(%1), %%xmm4 \n\t"
  107. "movdqu 2(%1), %%xmm1 \n\t"
  108. "movdqu 18(%1), %%xmm5 \n\t" //FIXME try aligned reads and shifts
  109. "paddw %%xmm6, %%xmm0 \n\t"
  110. "paddw %%xmm6, %%xmm4 \n\t"
  111. "paddw %%xmm7, %%xmm1 \n\t"
  112. "paddw %%xmm7, %%xmm5 \n\t"
  113. "pavgw %%xmm1, %%xmm0 \n\t"
  114. "pavgw %%xmm5, %%xmm4 \n\t"
  115. "psubw %%xmm7, %%xmm0 \n\t"
  116. "psubw %%xmm7, %%xmm4 \n\t"
  117. "psraw $1, %%xmm0 \n\t"
  118. "psraw $1, %%xmm4 \n\t"
  119. "movdqa (%0), %%xmm1 \n\t"
  120. "movdqa 16(%0), %%xmm5 \n\t"
  121. "paddw %%xmm1, %%xmm0 \n\t"
  122. "paddw %%xmm5, %%xmm4 \n\t"
  123. "psraw $2, %%xmm0 \n\t"
  124. "psraw $2, %%xmm4 \n\t"
  125. "paddw %%xmm1, %%xmm0 \n\t"
  126. "paddw %%xmm5, %%xmm4 \n\t"
  127. "movdqa %%xmm0, (%0) \n\t"
  128. "movdqa %%xmm4, 16(%0) \n\t"
  129. :: "r"(&b[i]), "r"(&ref[i])
  130. : "memory"
  131. );
  132. }
  133. snow_horizontal_compose_liftS_lead_out(i, b, b, ref, width, w_l);
  134. b[0] = b_0 + ((2 * ref[1] + W_BO-1 + 4 * b_0) >> W_BS);
  135. }
  136. { // Lift 3
  137. IDWTELEM * const src = b+w2;
  138. i = 0;
  139. for(; (((x86_reg)&temp[i]) & 0x1F) && i<w_r; i++){
  140. temp[i] = src[i] - ((-W_AM*(b[i] + b[i+1]))>>W_AS);
  141. }
  142. for(; i<w_r-7; i+=8){
  143. __asm__ volatile(
  144. "movdqu 2(%1), %%xmm2 \n\t"
  145. "movdqu 18(%1), %%xmm6 \n\t"
  146. "paddw (%1), %%xmm2 \n\t"
  147. "paddw 16(%1), %%xmm6 \n\t"
  148. "movdqu (%0), %%xmm0 \n\t"
  149. "movdqu 16(%0), %%xmm4 \n\t"
  150. "paddw %%xmm2, %%xmm0 \n\t"
  151. "paddw %%xmm6, %%xmm4 \n\t"
  152. "psraw $1, %%xmm2 \n\t"
  153. "psraw $1, %%xmm6 \n\t"
  154. "paddw %%xmm0, %%xmm2 \n\t"
  155. "paddw %%xmm4, %%xmm6 \n\t"
  156. "movdqa %%xmm2, (%2) \n\t"
  157. "movdqa %%xmm6, 16(%2) \n\t"
  158. :: "r"(&src[i]), "r"(&b[i]), "r"(&temp[i])
  159. : "memory"
  160. );
  161. }
  162. snow_horizontal_compose_lift_lead_out(i, temp, src, b, width, w_r, 1, -W_AM, W_AO+1, W_AS);
  163. }
  164. {
  165. snow_interleave_line_header(&i, width, b, temp);
  166. for (; (i & 0x3E) != 0x3E; i-=2){
  167. b[i+1] = temp[i>>1];
  168. b[i] = b[i>>1];
  169. }
  170. for (i-=62; i>=0; i-=64){
  171. __asm__ volatile(
  172. "movdqa (%1), %%xmm0 \n\t"
  173. "movdqa 16(%1), %%xmm2 \n\t"
  174. "movdqa 32(%1), %%xmm4 \n\t"
  175. "movdqa 48(%1), %%xmm6 \n\t"
  176. "movdqa (%1), %%xmm1 \n\t"
  177. "movdqa 16(%1), %%xmm3 \n\t"
  178. "movdqa 32(%1), %%xmm5 \n\t"
  179. "movdqa 48(%1), %%xmm7 \n\t"
  180. "punpcklwd (%2), %%xmm0 \n\t"
  181. "punpcklwd 16(%2), %%xmm2 \n\t"
  182. "punpcklwd 32(%2), %%xmm4 \n\t"
  183. "punpcklwd 48(%2), %%xmm6 \n\t"
  184. "movdqa %%xmm0, (%0) \n\t"
  185. "movdqa %%xmm2, 32(%0) \n\t"
  186. "movdqa %%xmm4, 64(%0) \n\t"
  187. "movdqa %%xmm6, 96(%0) \n\t"
  188. "punpckhwd (%2), %%xmm1 \n\t"
  189. "punpckhwd 16(%2), %%xmm3 \n\t"
  190. "punpckhwd 32(%2), %%xmm5 \n\t"
  191. "punpckhwd 48(%2), %%xmm7 \n\t"
  192. "movdqa %%xmm1, 16(%0) \n\t"
  193. "movdqa %%xmm3, 48(%0) \n\t"
  194. "movdqa %%xmm5, 80(%0) \n\t"
  195. "movdqa %%xmm7, 112(%0) \n\t"
  196. :: "r"(&(b)[i]), "r"(&(b)[i>>1]), "r"(&(temp)[i>>1])
  197. : "memory"
  198. );
  199. }
  200. }
  201. }
  202. void ff_snow_horizontal_compose97i_mmx(IDWTELEM *b, int width){
  203. const int w2= (width+1)>>1;
  204. IDWTELEM temp[width >> 1];
  205. const int w_l= (width>>1);
  206. const int w_r= w2 - 1;
  207. int i;
  208. { // Lift 0
  209. IDWTELEM * const ref = b + w2 - 1;
  210. i = 1;
  211. b[0] = b[0] - ((W_DM * 2 * ref[1]+W_DO)>>W_DS);
  212. __asm__ volatile(
  213. "pcmpeqw %%mm7, %%mm7 \n\t"
  214. "pcmpeqw %%mm3, %%mm3 \n\t"
  215. "psllw $1, %%mm3 \n\t"
  216. "paddw %%mm7, %%mm3 \n\t"
  217. "psllw $13, %%mm3 \n\t"
  218. ::);
  219. for(; i<w_l-7; i+=8){
  220. __asm__ volatile(
  221. "movq (%1), %%mm2 \n\t"
  222. "movq 8(%1), %%mm6 \n\t"
  223. "paddw 2(%1), %%mm2 \n\t"
  224. "paddw 10(%1), %%mm6 \n\t"
  225. "paddw %%mm7, %%mm2 \n\t"
  226. "paddw %%mm7, %%mm6 \n\t"
  227. "pmulhw %%mm3, %%mm2 \n\t"
  228. "pmulhw %%mm3, %%mm6 \n\t"
  229. "paddw (%0), %%mm2 \n\t"
  230. "paddw 8(%0), %%mm6 \n\t"
  231. "movq %%mm2, (%0) \n\t"
  232. "movq %%mm6, 8(%0) \n\t"
  233. :: "r"(&b[i]), "r"(&ref[i])
  234. : "memory"
  235. );
  236. }
  237. snow_horizontal_compose_lift_lead_out(i, b, b, ref, width, w_l, 0, W_DM, W_DO, W_DS);
  238. }
  239. { // Lift 1
  240. IDWTELEM * const dst = b+w2;
  241. i = 0;
  242. for(; i<w_r-7; i+=8){
  243. __asm__ volatile(
  244. "movq (%1), %%mm2 \n\t"
  245. "movq 8(%1), %%mm6 \n\t"
  246. "paddw 2(%1), %%mm2 \n\t"
  247. "paddw 10(%1), %%mm6 \n\t"
  248. "movq (%0), %%mm0 \n\t"
  249. "movq 8(%0), %%mm4 \n\t"
  250. "psubw %%mm2, %%mm0 \n\t"
  251. "psubw %%mm6, %%mm4 \n\t"
  252. "movq %%mm0, (%0) \n\t"
  253. "movq %%mm4, 8(%0) \n\t"
  254. :: "r"(&dst[i]), "r"(&b[i])
  255. : "memory"
  256. );
  257. }
  258. snow_horizontal_compose_lift_lead_out(i, dst, dst, b, width, w_r, 1, W_CM, W_CO, W_CS);
  259. }
  260. { // Lift 2
  261. IDWTELEM * const ref = b+w2 - 1;
  262. i = 1;
  263. b[0] = b[0] + (((2 * ref[1] + W_BO) + 4 * b[0]) >> W_BS);
  264. __asm__ volatile(
  265. "psllw $15, %%mm7 \n\t"
  266. "pcmpeqw %%mm6, %%mm6 \n\t"
  267. "psrlw $13, %%mm6 \n\t"
  268. "paddw %%mm7, %%mm6 \n\t"
  269. ::);
  270. for(; i<w_l-7; i+=8){
  271. __asm__ volatile(
  272. "movq (%1), %%mm0 \n\t"
  273. "movq 8(%1), %%mm4 \n\t"
  274. "movq 2(%1), %%mm1 \n\t"
  275. "movq 10(%1), %%mm5 \n\t"
  276. "paddw %%mm6, %%mm0 \n\t"
  277. "paddw %%mm6, %%mm4 \n\t"
  278. "paddw %%mm7, %%mm1 \n\t"
  279. "paddw %%mm7, %%mm5 \n\t"
  280. "pavgw %%mm1, %%mm0 \n\t"
  281. "pavgw %%mm5, %%mm4 \n\t"
  282. "psubw %%mm7, %%mm0 \n\t"
  283. "psubw %%mm7, %%mm4 \n\t"
  284. "psraw $1, %%mm0 \n\t"
  285. "psraw $1, %%mm4 \n\t"
  286. "movq (%0), %%mm1 \n\t"
  287. "movq 8(%0), %%mm5 \n\t"
  288. "paddw %%mm1, %%mm0 \n\t"
  289. "paddw %%mm5, %%mm4 \n\t"
  290. "psraw $2, %%mm0 \n\t"
  291. "psraw $2, %%mm4 \n\t"
  292. "paddw %%mm1, %%mm0 \n\t"
  293. "paddw %%mm5, %%mm4 \n\t"
  294. "movq %%mm0, (%0) \n\t"
  295. "movq %%mm4, 8(%0) \n\t"
  296. :: "r"(&b[i]), "r"(&ref[i])
  297. : "memory"
  298. );
  299. }
  300. snow_horizontal_compose_liftS_lead_out(i, b, b, ref, width, w_l);
  301. }
  302. { // Lift 3
  303. IDWTELEM * const src = b+w2;
  304. i = 0;
  305. for(; i<w_r-7; i+=8){
  306. __asm__ volatile(
  307. "movq 2(%1), %%mm2 \n\t"
  308. "movq 10(%1), %%mm6 \n\t"
  309. "paddw (%1), %%mm2 \n\t"
  310. "paddw 8(%1), %%mm6 \n\t"
  311. "movq (%0), %%mm0 \n\t"
  312. "movq 8(%0), %%mm4 \n\t"
  313. "paddw %%mm2, %%mm0 \n\t"
  314. "paddw %%mm6, %%mm4 \n\t"
  315. "psraw $1, %%mm2 \n\t"
  316. "psraw $1, %%mm6 \n\t"
  317. "paddw %%mm0, %%mm2 \n\t"
  318. "paddw %%mm4, %%mm6 \n\t"
  319. "movq %%mm2, (%2) \n\t"
  320. "movq %%mm6, 8(%2) \n\t"
  321. :: "r"(&src[i]), "r"(&b[i]), "r"(&temp[i])
  322. : "memory"
  323. );
  324. }
  325. snow_horizontal_compose_lift_lead_out(i, temp, src, b, width, w_r, 1, -W_AM, W_AO+1, W_AS);
  326. }
  327. {
  328. snow_interleave_line_header(&i, width, b, temp);
  329. for (; (i & 0x1E) != 0x1E; i-=2){
  330. b[i+1] = temp[i>>1];
  331. b[i] = b[i>>1];
  332. }
  333. for (i-=30; i>=0; i-=32){
  334. __asm__ volatile(
  335. "movq (%1), %%mm0 \n\t"
  336. "movq 8(%1), %%mm2 \n\t"
  337. "movq 16(%1), %%mm4 \n\t"
  338. "movq 24(%1), %%mm6 \n\t"
  339. "movq (%1), %%mm1 \n\t"
  340. "movq 8(%1), %%mm3 \n\t"
  341. "movq 16(%1), %%mm5 \n\t"
  342. "movq 24(%1), %%mm7 \n\t"
  343. "punpcklwd (%2), %%mm0 \n\t"
  344. "punpcklwd 8(%2), %%mm2 \n\t"
  345. "punpcklwd 16(%2), %%mm4 \n\t"
  346. "punpcklwd 24(%2), %%mm6 \n\t"
  347. "movq %%mm0, (%0) \n\t"
  348. "movq %%mm2, 16(%0) \n\t"
  349. "movq %%mm4, 32(%0) \n\t"
  350. "movq %%mm6, 48(%0) \n\t"
  351. "punpckhwd (%2), %%mm1 \n\t"
  352. "punpckhwd 8(%2), %%mm3 \n\t"
  353. "punpckhwd 16(%2), %%mm5 \n\t"
  354. "punpckhwd 24(%2), %%mm7 \n\t"
  355. "movq %%mm1, 8(%0) \n\t"
  356. "movq %%mm3, 24(%0) \n\t"
  357. "movq %%mm5, 40(%0) \n\t"
  358. "movq %%mm7, 56(%0) \n\t"
  359. :: "r"(&b[i]), "r"(&b[i>>1]), "r"(&temp[i>>1])
  360. : "memory"
  361. );
  362. }
  363. }
  364. }
  365. #if HAVE_7REGS
  366. #define snow_vertical_compose_sse2_load_add(op,r,t0,t1,t2,t3)\
  367. ""op" ("r",%%"REG_d"), %%"t0" \n\t"\
  368. ""op" 16("r",%%"REG_d"), %%"t1" \n\t"\
  369. ""op" 32("r",%%"REG_d"), %%"t2" \n\t"\
  370. ""op" 48("r",%%"REG_d"), %%"t3" \n\t"
  371. #define snow_vertical_compose_sse2_load(r,t0,t1,t2,t3)\
  372. snow_vertical_compose_sse2_load_add("movdqa",r,t0,t1,t2,t3)
  373. #define snow_vertical_compose_sse2_add(r,t0,t1,t2,t3)\
  374. snow_vertical_compose_sse2_load_add("paddw",r,t0,t1,t2,t3)
  375. #define snow_vertical_compose_r2r_sub(s0,s1,s2,s3,t0,t1,t2,t3)\
  376. "psubw %%"s0", %%"t0" \n\t"\
  377. "psubw %%"s1", %%"t1" \n\t"\
  378. "psubw %%"s2", %%"t2" \n\t"\
  379. "psubw %%"s3", %%"t3" \n\t"
  380. #define snow_vertical_compose_sse2_store(w,s0,s1,s2,s3)\
  381. "movdqa %%"s0", ("w",%%"REG_d") \n\t"\
  382. "movdqa %%"s1", 16("w",%%"REG_d") \n\t"\
  383. "movdqa %%"s2", 32("w",%%"REG_d") \n\t"\
  384. "movdqa %%"s3", 48("w",%%"REG_d") \n\t"
  385. #define snow_vertical_compose_sra(n,t0,t1,t2,t3)\
  386. "psraw $"n", %%"t0" \n\t"\
  387. "psraw $"n", %%"t1" \n\t"\
  388. "psraw $"n", %%"t2" \n\t"\
  389. "psraw $"n", %%"t3" \n\t"
  390. #define snow_vertical_compose_r2r_add(s0,s1,s2,s3,t0,t1,t2,t3)\
  391. "paddw %%"s0", %%"t0" \n\t"\
  392. "paddw %%"s1", %%"t1" \n\t"\
  393. "paddw %%"s2", %%"t2" \n\t"\
  394. "paddw %%"s3", %%"t3" \n\t"
  395. #define snow_vertical_compose_r2r_pmulhw(s0,s1,s2,s3,t0,t1,t2,t3)\
  396. "pmulhw %%"s0", %%"t0" \n\t"\
  397. "pmulhw %%"s1", %%"t1" \n\t"\
  398. "pmulhw %%"s2", %%"t2" \n\t"\
  399. "pmulhw %%"s3", %%"t3" \n\t"
  400. #define snow_vertical_compose_sse2_move(s0,s1,s2,s3,t0,t1,t2,t3)\
  401. "movdqa %%"s0", %%"t0" \n\t"\
  402. "movdqa %%"s1", %%"t1" \n\t"\
  403. "movdqa %%"s2", %%"t2" \n\t"\
  404. "movdqa %%"s3", %%"t3" \n\t"
  405. void ff_snow_vertical_compose97i_sse2(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width){
  406. x86_reg i = width;
  407. while(i & 0x1F)
  408. {
  409. i--;
  410. b4[i] -= (W_DM*(b3[i] + b5[i])+W_DO)>>W_DS;
  411. b3[i] -= (W_CM*(b2[i] + b4[i])+W_CO)>>W_CS;
  412. b2[i] += (W_BM*(b1[i] + b3[i])+4*b2[i]+W_BO)>>W_BS;
  413. b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
  414. }
  415. i+=i;
  416. __asm__ volatile (
  417. "jmp 2f \n\t"
  418. "1: \n\t"
  419. snow_vertical_compose_sse2_load("%4","xmm0","xmm2","xmm4","xmm6")
  420. snow_vertical_compose_sse2_add("%6","xmm0","xmm2","xmm4","xmm6")
  421. "pcmpeqw %%xmm0, %%xmm0 \n\t"
  422. "pcmpeqw %%xmm2, %%xmm2 \n\t"
  423. "paddw %%xmm2, %%xmm2 \n\t"
  424. "paddw %%xmm0, %%xmm2 \n\t"
  425. "psllw $13, %%xmm2 \n\t"
  426. snow_vertical_compose_r2r_add("xmm0","xmm0","xmm0","xmm0","xmm1","xmm3","xmm5","xmm7")
  427. snow_vertical_compose_r2r_pmulhw("xmm2","xmm2","xmm2","xmm2","xmm1","xmm3","xmm5","xmm7")
  428. snow_vertical_compose_sse2_add("%5","xmm1","xmm3","xmm5","xmm7")
  429. snow_vertical_compose_sse2_store("%5","xmm1","xmm3","xmm5","xmm7")
  430. snow_vertical_compose_sse2_load("%4","xmm0","xmm2","xmm4","xmm6")
  431. snow_vertical_compose_sse2_add("%3","xmm1","xmm3","xmm5","xmm7")
  432. snow_vertical_compose_r2r_sub("xmm1","xmm3","xmm5","xmm7","xmm0","xmm2","xmm4","xmm6")
  433. snow_vertical_compose_sse2_store("%4","xmm0","xmm2","xmm4","xmm6")
  434. "pcmpeqw %%xmm7, %%xmm7 \n\t"
  435. "pcmpeqw %%xmm5, %%xmm5 \n\t"
  436. "psllw $15, %%xmm7 \n\t"
  437. "psrlw $13, %%xmm5 \n\t"
  438. "paddw %%xmm7, %%xmm5 \n\t"
  439. snow_vertical_compose_r2r_add("xmm5","xmm5","xmm5","xmm5","xmm0","xmm2","xmm4","xmm6")
  440. "movq (%2,%%"REG_d"), %%xmm1 \n\t"
  441. "movq 8(%2,%%"REG_d"), %%xmm3 \n\t"
  442. "paddw %%xmm7, %%xmm1 \n\t"
  443. "paddw %%xmm7, %%xmm3 \n\t"
  444. "pavgw %%xmm1, %%xmm0 \n\t"
  445. "pavgw %%xmm3, %%xmm2 \n\t"
  446. "movq 16(%2,%%"REG_d"), %%xmm1 \n\t"
  447. "movq 24(%2,%%"REG_d"), %%xmm3 \n\t"
  448. "paddw %%xmm7, %%xmm1 \n\t"
  449. "paddw %%xmm7, %%xmm3 \n\t"
  450. "pavgw %%xmm1, %%xmm4 \n\t"
  451. "pavgw %%xmm3, %%xmm6 \n\t"
  452. snow_vertical_compose_r2r_sub("xmm7","xmm7","xmm7","xmm7","xmm0","xmm2","xmm4","xmm6")
  453. snow_vertical_compose_sra("1","xmm0","xmm2","xmm4","xmm6")
  454. snow_vertical_compose_sse2_add("%3","xmm0","xmm2","xmm4","xmm6")
  455. snow_vertical_compose_sra("2","xmm0","xmm2","xmm4","xmm6")
  456. snow_vertical_compose_sse2_add("%3","xmm0","xmm2","xmm4","xmm6")
  457. snow_vertical_compose_sse2_store("%3","xmm0","xmm2","xmm4","xmm6")
  458. snow_vertical_compose_sse2_add("%1","xmm0","xmm2","xmm4","xmm6")
  459. snow_vertical_compose_sse2_move("xmm0","xmm2","xmm4","xmm6","xmm1","xmm3","xmm5","xmm7")
  460. snow_vertical_compose_sra("1","xmm0","xmm2","xmm4","xmm6")
  461. snow_vertical_compose_r2r_add("xmm1","xmm3","xmm5","xmm7","xmm0","xmm2","xmm4","xmm6")
  462. snow_vertical_compose_sse2_add("%2","xmm0","xmm2","xmm4","xmm6")
  463. snow_vertical_compose_sse2_store("%2","xmm0","xmm2","xmm4","xmm6")
  464. "2: \n\t"
  465. "sub $64, %%"REG_d" \n\t"
  466. "jge 1b \n\t"
  467. :"+d"(i)
  468. :"r"(b0),"r"(b1),"r"(b2),"r"(b3),"r"(b4),"r"(b5));
  469. }
  470. #define snow_vertical_compose_mmx_load_add(op,r,t0,t1,t2,t3)\
  471. ""op" ("r",%%"REG_d"), %%"t0" \n\t"\
  472. ""op" 8("r",%%"REG_d"), %%"t1" \n\t"\
  473. ""op" 16("r",%%"REG_d"), %%"t2" \n\t"\
  474. ""op" 24("r",%%"REG_d"), %%"t3" \n\t"
  475. #define snow_vertical_compose_mmx_load(r,t0,t1,t2,t3)\
  476. snow_vertical_compose_mmx_load_add("movq",r,t0,t1,t2,t3)
  477. #define snow_vertical_compose_mmx_add(r,t0,t1,t2,t3)\
  478. snow_vertical_compose_mmx_load_add("paddw",r,t0,t1,t2,t3)
  479. #define snow_vertical_compose_mmx_store(w,s0,s1,s2,s3)\
  480. "movq %%"s0", ("w",%%"REG_d") \n\t"\
  481. "movq %%"s1", 8("w",%%"REG_d") \n\t"\
  482. "movq %%"s2", 16("w",%%"REG_d") \n\t"\
  483. "movq %%"s3", 24("w",%%"REG_d") \n\t"
  484. #define snow_vertical_compose_mmx_move(s0,s1,s2,s3,t0,t1,t2,t3)\
  485. "movq %%"s0", %%"t0" \n\t"\
  486. "movq %%"s1", %%"t1" \n\t"\
  487. "movq %%"s2", %%"t2" \n\t"\
  488. "movq %%"s3", %%"t3" \n\t"
  489. void ff_snow_vertical_compose97i_mmx(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width){
  490. x86_reg i = width;
  491. while(i & 15)
  492. {
  493. i--;
  494. b4[i] -= (W_DM*(b3[i] + b5[i])+W_DO)>>W_DS;
  495. b3[i] -= (W_CM*(b2[i] + b4[i])+W_CO)>>W_CS;
  496. b2[i] += (W_BM*(b1[i] + b3[i])+4*b2[i]+W_BO)>>W_BS;
  497. b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
  498. }
  499. i+=i;
  500. __asm__ volatile(
  501. "jmp 2f \n\t"
  502. "1: \n\t"
  503. snow_vertical_compose_mmx_load("%4","mm1","mm3","mm5","mm7")
  504. snow_vertical_compose_mmx_add("%6","mm1","mm3","mm5","mm7")
  505. "pcmpeqw %%mm0, %%mm0 \n\t"
  506. "pcmpeqw %%mm2, %%mm2 \n\t"
  507. "paddw %%mm2, %%mm2 \n\t"
  508. "paddw %%mm0, %%mm2 \n\t"
  509. "psllw $13, %%mm2 \n\t"
  510. snow_vertical_compose_r2r_add("mm0","mm0","mm0","mm0","mm1","mm3","mm5","mm7")
  511. snow_vertical_compose_r2r_pmulhw("mm2","mm2","mm2","mm2","mm1","mm3","mm5","mm7")
  512. snow_vertical_compose_mmx_add("%5","mm1","mm3","mm5","mm7")
  513. snow_vertical_compose_mmx_store("%5","mm1","mm3","mm5","mm7")
  514. snow_vertical_compose_mmx_load("%4","mm0","mm2","mm4","mm6")
  515. snow_vertical_compose_mmx_add("%3","mm1","mm3","mm5","mm7")
  516. snow_vertical_compose_r2r_sub("mm1","mm3","mm5","mm7","mm0","mm2","mm4","mm6")
  517. snow_vertical_compose_mmx_store("%4","mm0","mm2","mm4","mm6")
  518. "pcmpeqw %%mm7, %%mm7 \n\t"
  519. "pcmpeqw %%mm5, %%mm5 \n\t"
  520. "psllw $15, %%mm7 \n\t"
  521. "psrlw $13, %%mm5 \n\t"
  522. "paddw %%mm7, %%mm5 \n\t"
  523. snow_vertical_compose_r2r_add("mm5","mm5","mm5","mm5","mm0","mm2","mm4","mm6")
  524. "movq (%2,%%"REG_d"), %%mm1 \n\t"
  525. "movq 8(%2,%%"REG_d"), %%mm3 \n\t"
  526. "paddw %%mm7, %%mm1 \n\t"
  527. "paddw %%mm7, %%mm3 \n\t"
  528. "pavgw %%mm1, %%mm0 \n\t"
  529. "pavgw %%mm3, %%mm2 \n\t"
  530. "movq 16(%2,%%"REG_d"), %%mm1 \n\t"
  531. "movq 24(%2,%%"REG_d"), %%mm3 \n\t"
  532. "paddw %%mm7, %%mm1 \n\t"
  533. "paddw %%mm7, %%mm3 \n\t"
  534. "pavgw %%mm1, %%mm4 \n\t"
  535. "pavgw %%mm3, %%mm6 \n\t"
  536. snow_vertical_compose_r2r_sub("mm7","mm7","mm7","mm7","mm0","mm2","mm4","mm6")
  537. snow_vertical_compose_sra("1","mm0","mm2","mm4","mm6")
  538. snow_vertical_compose_mmx_add("%3","mm0","mm2","mm4","mm6")
  539. snow_vertical_compose_sra("2","mm0","mm2","mm4","mm6")
  540. snow_vertical_compose_mmx_add("%3","mm0","mm2","mm4","mm6")
  541. snow_vertical_compose_mmx_store("%3","mm0","mm2","mm4","mm6")
  542. snow_vertical_compose_mmx_add("%1","mm0","mm2","mm4","mm6")
  543. snow_vertical_compose_mmx_move("mm0","mm2","mm4","mm6","mm1","mm3","mm5","mm7")
  544. snow_vertical_compose_sra("1","mm0","mm2","mm4","mm6")
  545. snow_vertical_compose_r2r_add("mm1","mm3","mm5","mm7","mm0","mm2","mm4","mm6")
  546. snow_vertical_compose_mmx_add("%2","mm0","mm2","mm4","mm6")
  547. snow_vertical_compose_mmx_store("%2","mm0","mm2","mm4","mm6")
  548. "2: \n\t"
  549. "sub $32, %%"REG_d" \n\t"
  550. "jge 1b \n\t"
  551. :"+d"(i)
  552. :"r"(b0),"r"(b1),"r"(b2),"r"(b3),"r"(b4),"r"(b5));
  553. }
  554. #endif //HAVE_7REGS
  555. #define snow_inner_add_yblock_sse2_header \
  556. IDWTELEM * * dst_array = sb->line + src_y;\
  557. x86_reg tmp;\
  558. __asm__ volatile(\
  559. "mov %7, %%"REG_c" \n\t"\
  560. "mov %6, %2 \n\t"\
  561. "mov %4, %%"REG_S" \n\t"\
  562. "pxor %%xmm7, %%xmm7 \n\t" /* 0 */\
  563. "pcmpeqd %%xmm3, %%xmm3 \n\t"\
  564. "psllw $15, %%xmm3 \n\t"\
  565. "psrlw $12, %%xmm3 \n\t" /* FRAC_BITS >> 1 */\
  566. "1: \n\t"\
  567. "mov %1, %%"REG_D" \n\t"\
  568. "mov (%%"REG_D"), %%"REG_D" \n\t"\
  569. "add %3, %%"REG_D" \n\t"
  570. #define snow_inner_add_yblock_sse2_start_8(out_reg1, out_reg2, ptr_offset, s_offset)\
  571. "mov "PTR_SIZE"*"ptr_offset"(%%"REG_a"), %%"REG_d"; \n\t"\
  572. "movq (%%"REG_d"), %%"out_reg1" \n\t"\
  573. "movq (%%"REG_d", %%"REG_c"), %%"out_reg2" \n\t"\
  574. "punpcklbw %%xmm7, %%"out_reg1" \n\t"\
  575. "punpcklbw %%xmm7, %%"out_reg2" \n\t"\
  576. "movq "s_offset"(%%"REG_S"), %%xmm0 \n\t"\
  577. "movq "s_offset"+16(%%"REG_S"), %%xmm4 \n\t"\
  578. "punpcklbw %%xmm7, %%xmm0 \n\t"\
  579. "punpcklbw %%xmm7, %%xmm4 \n\t"\
  580. "pmullw %%xmm0, %%"out_reg1" \n\t"\
  581. "pmullw %%xmm4, %%"out_reg2" \n\t"
  582. #define snow_inner_add_yblock_sse2_start_16(out_reg1, out_reg2, ptr_offset, s_offset)\
  583. "mov "PTR_SIZE"*"ptr_offset"(%%"REG_a"), %%"REG_d"; \n\t"\
  584. "movq (%%"REG_d"), %%"out_reg1" \n\t"\
  585. "movq 8(%%"REG_d"), %%"out_reg2" \n\t"\
  586. "punpcklbw %%xmm7, %%"out_reg1" \n\t"\
  587. "punpcklbw %%xmm7, %%"out_reg2" \n\t"\
  588. "movq "s_offset"(%%"REG_S"), %%xmm0 \n\t"\
  589. "movq "s_offset"+8(%%"REG_S"), %%xmm4 \n\t"\
  590. "punpcklbw %%xmm7, %%xmm0 \n\t"\
  591. "punpcklbw %%xmm7, %%xmm4 \n\t"\
  592. "pmullw %%xmm0, %%"out_reg1" \n\t"\
  593. "pmullw %%xmm4, %%"out_reg2" \n\t"
  594. #define snow_inner_add_yblock_sse2_accum_8(ptr_offset, s_offset) \
  595. snow_inner_add_yblock_sse2_start_8("xmm2", "xmm6", ptr_offset, s_offset)\
  596. "paddusw %%xmm2, %%xmm1 \n\t"\
  597. "paddusw %%xmm6, %%xmm5 \n\t"
  598. #define snow_inner_add_yblock_sse2_accum_16(ptr_offset, s_offset) \
  599. snow_inner_add_yblock_sse2_start_16("xmm2", "xmm6", ptr_offset, s_offset)\
  600. "paddusw %%xmm2, %%xmm1 \n\t"\
  601. "paddusw %%xmm6, %%xmm5 \n\t"
  602. #define snow_inner_add_yblock_sse2_end_common1\
  603. "add $32, %%"REG_S" \n\t"\
  604. "add %%"REG_c", %0 \n\t"\
  605. "add %%"REG_c", "PTR_SIZE"*3(%%"REG_a");\n\t"\
  606. "add %%"REG_c", "PTR_SIZE"*2(%%"REG_a");\n\t"\
  607. "add %%"REG_c", "PTR_SIZE"*1(%%"REG_a");\n\t"\
  608. "add %%"REG_c", (%%"REG_a") \n\t"
  609. #define snow_inner_add_yblock_sse2_end_common2\
  610. "jnz 1b \n\t"\
  611. :"+m"(dst8),"+m"(dst_array),"=&r"(tmp)\
  612. :\
  613. "rm"((x86_reg)(src_x<<1)),"m"(obmc),"a"(block),"m"((x86_reg)b_h),"m"((x86_reg)src_stride):\
  614. "%"REG_c"","%"REG_S"","%"REG_D"","%"REG_d"");
  615. #define snow_inner_add_yblock_sse2_end_8\
  616. "sal $1, %%"REG_c" \n\t"\
  617. "add $"PTR_SIZE"*2, %1 \n\t"\
  618. snow_inner_add_yblock_sse2_end_common1\
  619. "sar $1, %%"REG_c" \n\t"\
  620. "sub $2, %2 \n\t"\
  621. snow_inner_add_yblock_sse2_end_common2
  622. #define snow_inner_add_yblock_sse2_end_16\
  623. "add $"PTR_SIZE"*1, %1 \n\t"\
  624. snow_inner_add_yblock_sse2_end_common1\
  625. "dec %2 \n\t"\
  626. snow_inner_add_yblock_sse2_end_common2
  627. static void inner_add_yblock_bw_8_obmc_16_bh_even_sse2(const uint8_t *obmc, const x86_reg obmc_stride, uint8_t * * block, int b_w, x86_reg b_h,
  628. int src_x, int src_y, x86_reg src_stride, slice_buffer * sb, int add, uint8_t * dst8){
  629. snow_inner_add_yblock_sse2_header
  630. snow_inner_add_yblock_sse2_start_8("xmm1", "xmm5", "3", "0")
  631. snow_inner_add_yblock_sse2_accum_8("2", "8")
  632. snow_inner_add_yblock_sse2_accum_8("1", "128")
  633. snow_inner_add_yblock_sse2_accum_8("0", "136")
  634. "mov %0, %%"REG_d" \n\t"
  635. "movdqa (%%"REG_D"), %%xmm0 \n\t"
  636. "movdqa %%xmm1, %%xmm2 \n\t"
  637. "punpckhwd %%xmm7, %%xmm1 \n\t"
  638. "punpcklwd %%xmm7, %%xmm2 \n\t"
  639. "paddd %%xmm2, %%xmm0 \n\t"
  640. "movdqa 16(%%"REG_D"), %%xmm2 \n\t"
  641. "paddd %%xmm1, %%xmm2 \n\t"
  642. "paddd %%xmm3, %%xmm0 \n\t"
  643. "paddd %%xmm3, %%xmm2 \n\t"
  644. "mov %1, %%"REG_D" \n\t"
  645. "mov "PTR_SIZE"(%%"REG_D"), %%"REG_D";\n\t"
  646. "add %3, %%"REG_D" \n\t"
  647. "movdqa (%%"REG_D"), %%xmm4 \n\t"
  648. "movdqa %%xmm5, %%xmm6 \n\t"
  649. "punpckhwd %%xmm7, %%xmm5 \n\t"
  650. "punpcklwd %%xmm7, %%xmm6 \n\t"
  651. "paddd %%xmm6, %%xmm4 \n\t"
  652. "movdqa 16(%%"REG_D"), %%xmm6 \n\t"
  653. "paddd %%xmm5, %%xmm6 \n\t"
  654. "paddd %%xmm3, %%xmm4 \n\t"
  655. "paddd %%xmm3, %%xmm6 \n\t"
  656. "psrad $8, %%xmm0 \n\t" /* FRAC_BITS. */
  657. "psrad $8, %%xmm2 \n\t" /* FRAC_BITS. */
  658. "packssdw %%xmm2, %%xmm0 \n\t"
  659. "packuswb %%xmm7, %%xmm0 \n\t"
  660. "movq %%xmm0, (%%"REG_d") \n\t"
  661. "psrad $8, %%xmm4 \n\t" /* FRAC_BITS. */
  662. "psrad $8, %%xmm6 \n\t" /* FRAC_BITS. */
  663. "packssdw %%xmm6, %%xmm4 \n\t"
  664. "packuswb %%xmm7, %%xmm4 \n\t"
  665. "movq %%xmm4, (%%"REG_d",%%"REG_c");\n\t"
  666. snow_inner_add_yblock_sse2_end_8
  667. }
  668. static void inner_add_yblock_bw_16_obmc_32_sse2(const uint8_t *obmc, const x86_reg obmc_stride, uint8_t * * block, int b_w, x86_reg b_h,
  669. int src_x, int src_y, x86_reg src_stride, slice_buffer * sb, int add, uint8_t * dst8){
  670. snow_inner_add_yblock_sse2_header
  671. snow_inner_add_yblock_sse2_start_16("xmm1", "xmm5", "3", "0")
  672. snow_inner_add_yblock_sse2_accum_16("2", "16")
  673. snow_inner_add_yblock_sse2_accum_16("1", "512")
  674. snow_inner_add_yblock_sse2_accum_16("0", "528")
  675. "mov %0, %%"REG_d" \n\t"
  676. "psrlw $4, %%xmm1 \n\t"
  677. "psrlw $4, %%xmm5 \n\t"
  678. "paddw (%%"REG_D"), %%xmm1 \n\t"
  679. "paddw 16(%%"REG_D"), %%xmm5 \n\t"
  680. "paddw %%xmm3, %%xmm1 \n\t"
  681. "paddw %%xmm3, %%xmm5 \n\t"
  682. "psraw $4, %%xmm1 \n\t" /* FRAC_BITS. */
  683. "psraw $4, %%xmm5 \n\t" /* FRAC_BITS. */
  684. "packuswb %%xmm5, %%xmm1 \n\t"
  685. "movdqu %%xmm1, (%%"REG_d") \n\t"
  686. snow_inner_add_yblock_sse2_end_16
  687. }
  688. #define snow_inner_add_yblock_mmx_header \
  689. IDWTELEM * * dst_array = sb->line + src_y;\
  690. x86_reg tmp;\
  691. __asm__ volatile(\
  692. "mov %7, %%"REG_c" \n\t"\
  693. "mov %6, %2 \n\t"\
  694. "mov %4, %%"REG_S" \n\t"\
  695. "pxor %%mm7, %%mm7 \n\t" /* 0 */\
  696. "pcmpeqd %%mm3, %%mm3 \n\t"\
  697. "psllw $15, %%mm3 \n\t"\
  698. "psrlw $12, %%mm3 \n\t" /* FRAC_BITS >> 1 */\
  699. "1: \n\t"\
  700. "mov %1, %%"REG_D" \n\t"\
  701. "mov (%%"REG_D"), %%"REG_D" \n\t"\
  702. "add %3, %%"REG_D" \n\t"
  703. #define snow_inner_add_yblock_mmx_start(out_reg1, out_reg2, ptr_offset, s_offset, d_offset)\
  704. "mov "PTR_SIZE"*"ptr_offset"(%%"REG_a"), %%"REG_d"; \n\t"\
  705. "movd "d_offset"(%%"REG_d"), %%"out_reg1" \n\t"\
  706. "movd "d_offset"+4(%%"REG_d"), %%"out_reg2" \n\t"\
  707. "punpcklbw %%mm7, %%"out_reg1" \n\t"\
  708. "punpcklbw %%mm7, %%"out_reg2" \n\t"\
  709. "movd "s_offset"(%%"REG_S"), %%mm0 \n\t"\
  710. "movd "s_offset"+4(%%"REG_S"), %%mm4 \n\t"\
  711. "punpcklbw %%mm7, %%mm0 \n\t"\
  712. "punpcklbw %%mm7, %%mm4 \n\t"\
  713. "pmullw %%mm0, %%"out_reg1" \n\t"\
  714. "pmullw %%mm4, %%"out_reg2" \n\t"
  715. #define snow_inner_add_yblock_mmx_accum(ptr_offset, s_offset, d_offset) \
  716. snow_inner_add_yblock_mmx_start("mm2", "mm6", ptr_offset, s_offset, d_offset)\
  717. "paddusw %%mm2, %%mm1 \n\t"\
  718. "paddusw %%mm6, %%mm5 \n\t"
  719. #define snow_inner_add_yblock_mmx_mix(read_offset, write_offset)\
  720. "mov %0, %%"REG_d" \n\t"\
  721. "psrlw $4, %%mm1 \n\t"\
  722. "psrlw $4, %%mm5 \n\t"\
  723. "paddw "read_offset"(%%"REG_D"), %%mm1 \n\t"\
  724. "paddw "read_offset"+8(%%"REG_D"), %%mm5 \n\t"\
  725. "paddw %%mm3, %%mm1 \n\t"\
  726. "paddw %%mm3, %%mm5 \n\t"\
  727. "psraw $4, %%mm1 \n\t"\
  728. "psraw $4, %%mm5 \n\t"\
  729. "packuswb %%mm5, %%mm1 \n\t"\
  730. "movq %%mm1, "write_offset"(%%"REG_d") \n\t"
  731. #define snow_inner_add_yblock_mmx_end(s_step)\
  732. "add $"s_step", %%"REG_S" \n\t"\
  733. "add %%"REG_c", "PTR_SIZE"*3(%%"REG_a");\n\t"\
  734. "add %%"REG_c", "PTR_SIZE"*2(%%"REG_a");\n\t"\
  735. "add %%"REG_c", "PTR_SIZE"*1(%%"REG_a");\n\t"\
  736. "add %%"REG_c", (%%"REG_a") \n\t"\
  737. "add $"PTR_SIZE"*1, %1 \n\t"\
  738. "add %%"REG_c", %0 \n\t"\
  739. "dec %2 \n\t"\
  740. "jnz 1b \n\t"\
  741. :"+m"(dst8),"+m"(dst_array),"=&r"(tmp)\
  742. :\
  743. "rm"((x86_reg)(src_x<<1)),"m"(obmc),"a"(block),"m"((x86_reg)b_h),"m"((x86_reg)src_stride):\
  744. "%"REG_c"","%"REG_S"","%"REG_D"","%"REG_d"");
  745. static void inner_add_yblock_bw_8_obmc_16_mmx(const uint8_t *obmc, const x86_reg obmc_stride, uint8_t * * block, int b_w, x86_reg b_h,
  746. int src_x, int src_y, x86_reg src_stride, slice_buffer * sb, int add, uint8_t * dst8){
  747. snow_inner_add_yblock_mmx_header
  748. snow_inner_add_yblock_mmx_start("mm1", "mm5", "3", "0", "0")
  749. snow_inner_add_yblock_mmx_accum("2", "8", "0")
  750. snow_inner_add_yblock_mmx_accum("1", "128", "0")
  751. snow_inner_add_yblock_mmx_accum("0", "136", "0")
  752. snow_inner_add_yblock_mmx_mix("0", "0")
  753. snow_inner_add_yblock_mmx_end("16")
  754. }
  755. static void inner_add_yblock_bw_16_obmc_32_mmx(const uint8_t *obmc, const x86_reg obmc_stride, uint8_t * * block, int b_w, x86_reg b_h,
  756. int src_x, int src_y, x86_reg src_stride, slice_buffer * sb, int add, uint8_t * dst8){
  757. snow_inner_add_yblock_mmx_header
  758. snow_inner_add_yblock_mmx_start("mm1", "mm5", "3", "0", "0")
  759. snow_inner_add_yblock_mmx_accum("2", "16", "0")
  760. snow_inner_add_yblock_mmx_accum("1", "512", "0")
  761. snow_inner_add_yblock_mmx_accum("0", "528", "0")
  762. snow_inner_add_yblock_mmx_mix("0", "0")
  763. snow_inner_add_yblock_mmx_start("mm1", "mm5", "3", "8", "8")
  764. snow_inner_add_yblock_mmx_accum("2", "24", "8")
  765. snow_inner_add_yblock_mmx_accum("1", "520", "8")
  766. snow_inner_add_yblock_mmx_accum("0", "536", "8")
  767. snow_inner_add_yblock_mmx_mix("16", "8")
  768. snow_inner_add_yblock_mmx_end("32")
  769. }
  770. void ff_snow_inner_add_yblock_sse2(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
  771. int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){
  772. if (b_w == 16)
  773. inner_add_yblock_bw_16_obmc_32_sse2(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
  774. else if (b_w == 8 && obmc_stride == 16) {
  775. if (!(b_h & 1))
  776. inner_add_yblock_bw_8_obmc_16_bh_even_sse2(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
  777. else
  778. inner_add_yblock_bw_8_obmc_16_mmx(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
  779. } else
  780. ff_snow_inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
  781. }
  782. void ff_snow_inner_add_yblock_mmx(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
  783. int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){
  784. if (b_w == 16)
  785. inner_add_yblock_bw_16_obmc_32_mmx(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
  786. else if (b_w == 8 && obmc_stride == 16)
  787. inner_add_yblock_bw_8_obmc_16_mmx(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
  788. else
  789. ff_snow_inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
  790. }