swscale_template.c 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460
  1. /*
  2. * Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <stdint.h>
  21. #include "libavutil/x86/asm.h"
  22. #include "libswscale/swscale_internal.h"
  23. #undef REAL_MOVNTQ
  24. #undef MOVNTQ
  25. #undef MOVNTQ2
  26. #undef PREFETCH
  27. #define REAL_MOVNTQ(a,b) "movntq " #a ", " #b " \n\t"
  28. #define MOVNTQ2 "movntq "
  29. #define MOVNTQ(a,b) REAL_MOVNTQ(a,b)
  30. #define YSCALEYUV2PACKEDX_UV \
  31. __asm__ volatile(\
  32. "xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
  33. ".p2align 4 \n\t"\
  34. "nop \n\t"\
  35. "1: \n\t"\
  36. "lea "CHR_MMX_FILTER_OFFSET"(%0), %%"FF_REG_d" \n\t"\
  37. "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
  38. "movq "VROUNDER_OFFSET"(%0), %%mm3 \n\t"\
  39. "movq %%mm3, %%mm4 \n\t"\
  40. ".p2align 4 \n\t"\
  41. "2: \n\t"\
  42. "movq 8(%%"FF_REG_d"), %%mm0 \n\t" /* filterCoeff */\
  43. "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm2 \n\t" /* UsrcData */\
  44. "add %6, %%"FF_REG_S" \n\t" \
  45. "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm5 \n\t" /* VsrcData */\
  46. "add $16, %%"FF_REG_d" \n\t"\
  47. "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
  48. "pmulhw %%mm0, %%mm2 \n\t"\
  49. "pmulhw %%mm0, %%mm5 \n\t"\
  50. "paddw %%mm2, %%mm3 \n\t"\
  51. "paddw %%mm5, %%mm4 \n\t"\
  52. "test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
  53. " jnz 2b \n\t"\
  54. #define YSCALEYUV2PACKEDX_YA(offset,coeff,src1,src2,dst1,dst2) \
  55. "lea "offset"(%0), %%"FF_REG_d" \n\t"\
  56. "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
  57. "movq "VROUNDER_OFFSET"(%0), "#dst1" \n\t"\
  58. "movq "#dst1", "#dst2" \n\t"\
  59. ".p2align 4 \n\t"\
  60. "2: \n\t"\
  61. "movq 8(%%"FF_REG_d"), "#coeff" \n\t" /* filterCoeff */\
  62. "movq (%%"FF_REG_S", %%"FF_REG_a", 2), "#src1" \n\t" /* Y1srcData */\
  63. "movq 8(%%"FF_REG_S", %%"FF_REG_a", 2), "#src2" \n\t" /* Y2srcData */\
  64. "add $16, %%"FF_REG_d" \n\t"\
  65. "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
  66. "pmulhw "#coeff", "#src1" \n\t"\
  67. "pmulhw "#coeff", "#src2" \n\t"\
  68. "paddw "#src1", "#dst1" \n\t"\
  69. "paddw "#src2", "#dst2" \n\t"\
  70. "test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
  71. " jnz 2b \n\t"\
  72. #define YSCALEYUV2PACKEDX \
  73. YSCALEYUV2PACKEDX_UV \
  74. YSCALEYUV2PACKEDX_YA(LUM_MMX_FILTER_OFFSET,%%mm0,%%mm2,%%mm5,%%mm1,%%mm7) \
  75. #define YSCALEYUV2PACKEDX_END \
  76. :: "r" (&c->redDither), \
  77. "m" (dummy), "m" (dummy), "m" (dummy),\
  78. "r" (dest), "m" (dstW_reg), "m"(uv_off) \
  79. NAMED_CONSTRAINTS_ADD(bF8,bFC) \
  80. : "%"FF_REG_a, "%"FF_REG_d, "%"FF_REG_S \
  81. );
  82. #define YSCALEYUV2PACKEDX_ACCURATE_UV \
  83. __asm__ volatile(\
  84. "xor %%"FF_REG_a", %%"FF_REG_a" \n\t"\
  85. ".p2align 4 \n\t"\
  86. "nop \n\t"\
  87. "1: \n\t"\
  88. "lea "CHR_MMX_FILTER_OFFSET"(%0), %%"FF_REG_d" \n\t"\
  89. "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
  90. "pxor %%mm4, %%mm4 \n\t"\
  91. "pxor %%mm5, %%mm5 \n\t"\
  92. "pxor %%mm6, %%mm6 \n\t"\
  93. "pxor %%mm7, %%mm7 \n\t"\
  94. ".p2align 4 \n\t"\
  95. "2: \n\t"\
  96. "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm0 \n\t" /* UsrcData */\
  97. "add %6, %%"FF_REG_S" \n\t" \
  98. "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm2 \n\t" /* VsrcData */\
  99. "mov "STR(APCK_PTR2)"(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
  100. "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm1 \n\t" /* UsrcData */\
  101. "movq %%mm0, %%mm3 \n\t"\
  102. "punpcklwd %%mm1, %%mm0 \n\t"\
  103. "punpckhwd %%mm1, %%mm3 \n\t"\
  104. "movq "STR(APCK_COEF)"(%%"FF_REG_d"),%%mm1 \n\t" /* filterCoeff */\
  105. "pmaddwd %%mm1, %%mm0 \n\t"\
  106. "pmaddwd %%mm1, %%mm3 \n\t"\
  107. "paddd %%mm0, %%mm4 \n\t"\
  108. "paddd %%mm3, %%mm5 \n\t"\
  109. "add %6, %%"FF_REG_S" \n\t" \
  110. "movq (%%"FF_REG_S", %%"FF_REG_a"), %%mm3 \n\t" /* VsrcData */\
  111. "mov "STR(APCK_SIZE)"(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
  112. "add $"STR(APCK_SIZE)", %%"FF_REG_d" \n\t"\
  113. "test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
  114. "movq %%mm2, %%mm0 \n\t"\
  115. "punpcklwd %%mm3, %%mm2 \n\t"\
  116. "punpckhwd %%mm3, %%mm0 \n\t"\
  117. "pmaddwd %%mm1, %%mm2 \n\t"\
  118. "pmaddwd %%mm1, %%mm0 \n\t"\
  119. "paddd %%mm2, %%mm6 \n\t"\
  120. "paddd %%mm0, %%mm7 \n\t"\
  121. " jnz 2b \n\t"\
  122. "psrad $16, %%mm4 \n\t"\
  123. "psrad $16, %%mm5 \n\t"\
  124. "psrad $16, %%mm6 \n\t"\
  125. "psrad $16, %%mm7 \n\t"\
  126. "movq "VROUNDER_OFFSET"(%0), %%mm0 \n\t"\
  127. "packssdw %%mm5, %%mm4 \n\t"\
  128. "packssdw %%mm7, %%mm6 \n\t"\
  129. "paddw %%mm0, %%mm4 \n\t"\
  130. "paddw %%mm0, %%mm6 \n\t"\
  131. "movq %%mm4, "U_TEMP"(%0) \n\t"\
  132. "movq %%mm6, "V_TEMP"(%0) \n\t"\
  133. #define YSCALEYUV2PACKEDX_ACCURATE_YA(offset) \
  134. "lea "offset"(%0), %%"FF_REG_d" \n\t"\
  135. "mov (%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
  136. "pxor %%mm1, %%mm1 \n\t"\
  137. "pxor %%mm5, %%mm5 \n\t"\
  138. "pxor %%mm7, %%mm7 \n\t"\
  139. "pxor %%mm6, %%mm6 \n\t"\
  140. ".p2align 4 \n\t"\
  141. "2: \n\t"\
  142. "movq (%%"FF_REG_S", %%"FF_REG_a", 2), %%mm0 \n\t" /* Y1srcData */\
  143. "movq 8(%%"FF_REG_S", %%"FF_REG_a", 2), %%mm2 \n\t" /* Y2srcData */\
  144. "mov "STR(APCK_PTR2)"(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
  145. "movq (%%"FF_REG_S", %%"FF_REG_a", 2), %%mm4 \n\t" /* Y1srcData */\
  146. "movq %%mm0, %%mm3 \n\t"\
  147. "punpcklwd %%mm4, %%mm0 \n\t"\
  148. "punpckhwd %%mm4, %%mm3 \n\t"\
  149. "movq "STR(APCK_COEF)"(%%"FF_REG_d"), %%mm4 \n\t" /* filterCoeff */\
  150. "pmaddwd %%mm4, %%mm0 \n\t"\
  151. "pmaddwd %%mm4, %%mm3 \n\t"\
  152. "paddd %%mm0, %%mm1 \n\t"\
  153. "paddd %%mm3, %%mm5 \n\t"\
  154. "movq 8(%%"FF_REG_S", %%"FF_REG_a", 2), %%mm3 \n\t" /* Y2srcData */\
  155. "mov "STR(APCK_SIZE)"(%%"FF_REG_d"), %%"FF_REG_S" \n\t"\
  156. "add $"STR(APCK_SIZE)", %%"FF_REG_d" \n\t"\
  157. "test %%"FF_REG_S", %%"FF_REG_S" \n\t"\
  158. "movq %%mm2, %%mm0 \n\t"\
  159. "punpcklwd %%mm3, %%mm2 \n\t"\
  160. "punpckhwd %%mm3, %%mm0 \n\t"\
  161. "pmaddwd %%mm4, %%mm2 \n\t"\
  162. "pmaddwd %%mm4, %%mm0 \n\t"\
  163. "paddd %%mm2, %%mm7 \n\t"\
  164. "paddd %%mm0, %%mm6 \n\t"\
  165. " jnz 2b \n\t"\
  166. "psrad $16, %%mm1 \n\t"\
  167. "psrad $16, %%mm5 \n\t"\
  168. "psrad $16, %%mm7 \n\t"\
  169. "psrad $16, %%mm6 \n\t"\
  170. "movq "VROUNDER_OFFSET"(%0), %%mm0 \n\t"\
  171. "packssdw %%mm5, %%mm1 \n\t"\
  172. "packssdw %%mm6, %%mm7 \n\t"\
  173. "paddw %%mm0, %%mm1 \n\t"\
  174. "paddw %%mm0, %%mm7 \n\t"\
  175. "movq "U_TEMP"(%0), %%mm3 \n\t"\
  176. "movq "V_TEMP"(%0), %%mm4 \n\t"\
  177. #define YSCALEYUV2PACKEDX_ACCURATE \
  178. YSCALEYUV2PACKEDX_ACCURATE_UV \
  179. YSCALEYUV2PACKEDX_ACCURATE_YA(LUM_MMX_FILTER_OFFSET)
  180. #define YSCALEYUV2RGBX \
  181. "psubw "U_OFFSET"(%0), %%mm3 \n\t" /* (U-128)8*/\
  182. "psubw "V_OFFSET"(%0), %%mm4 \n\t" /* (V-128)8*/\
  183. "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
  184. "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
  185. "pmulhw "UG_COEFF"(%0), %%mm3 \n\t"\
  186. "pmulhw "VG_COEFF"(%0), %%mm4 \n\t"\
  187. /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
  188. "pmulhw "UB_COEFF"(%0), %%mm2 \n\t"\
  189. "pmulhw "VR_COEFF"(%0), %%mm5 \n\t"\
  190. "psubw "Y_OFFSET"(%0), %%mm1 \n\t" /* 8(Y-16)*/\
  191. "psubw "Y_OFFSET"(%0), %%mm7 \n\t" /* 8(Y-16)*/\
  192. "pmulhw "Y_COEFF"(%0), %%mm1 \n\t"\
  193. "pmulhw "Y_COEFF"(%0), %%mm7 \n\t"\
  194. /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
  195. "paddw %%mm3, %%mm4 \n\t"\
  196. "movq %%mm2, %%mm0 \n\t"\
  197. "movq %%mm5, %%mm6 \n\t"\
  198. "movq %%mm4, %%mm3 \n\t"\
  199. "punpcklwd %%mm2, %%mm2 \n\t"\
  200. "punpcklwd %%mm5, %%mm5 \n\t"\
  201. "punpcklwd %%mm4, %%mm4 \n\t"\
  202. "paddw %%mm1, %%mm2 \n\t"\
  203. "paddw %%mm1, %%mm5 \n\t"\
  204. "paddw %%mm1, %%mm4 \n\t"\
  205. "punpckhwd %%mm0, %%mm0 \n\t"\
  206. "punpckhwd %%mm6, %%mm6 \n\t"\
  207. "punpckhwd %%mm3, %%mm3 \n\t"\
  208. "paddw %%mm7, %%mm0 \n\t"\
  209. "paddw %%mm7, %%mm6 \n\t"\
  210. "paddw %%mm7, %%mm3 \n\t"\
  211. /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
  212. "packuswb %%mm0, %%mm2 \n\t"\
  213. "packuswb %%mm6, %%mm5 \n\t"\
  214. "packuswb %%mm3, %%mm4 \n\t"\
  215. #define REAL_WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t) \
  216. "movq "#b", "#q2" \n\t" /* B */\
  217. "movq "#r", "#t" \n\t" /* R */\
  218. "punpcklbw "#g", "#b" \n\t" /* GBGBGBGB 0 */\
  219. "punpcklbw "#a", "#r" \n\t" /* ARARARAR 0 */\
  220. "punpckhbw "#g", "#q2" \n\t" /* GBGBGBGB 2 */\
  221. "punpckhbw "#a", "#t" \n\t" /* ARARARAR 2 */\
  222. "movq "#b", "#q0" \n\t" /* GBGBGBGB 0 */\
  223. "movq "#q2", "#q3" \n\t" /* GBGBGBGB 2 */\
  224. "punpcklwd "#r", "#q0" \n\t" /* ARGBARGB 0 */\
  225. "punpckhwd "#r", "#b" \n\t" /* ARGBARGB 1 */\
  226. "punpcklwd "#t", "#q2" \n\t" /* ARGBARGB 2 */\
  227. "punpckhwd "#t", "#q3" \n\t" /* ARGBARGB 3 */\
  228. \
  229. MOVNTQ( q0, (dst, index, 4))\
  230. MOVNTQ( b, 8(dst, index, 4))\
  231. MOVNTQ( q2, 16(dst, index, 4))\
  232. MOVNTQ( q3, 24(dst, index, 4))\
  233. \
  234. "add $8, "#index" \n\t"\
  235. "cmp "dstw", "#index" \n\t"\
  236. " jb 1b \n\t"
  237. #define WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t) REAL_WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t)
  238. static void RENAME(yuv2rgb32_X_ar)(SwsContext *c, const int16_t *lumFilter,
  239. const int16_t **lumSrc, int lumFilterSize,
  240. const int16_t *chrFilter, const int16_t **chrUSrc,
  241. const int16_t **chrVSrc,
  242. int chrFilterSize, const int16_t **alpSrc,
  243. uint8_t *dest, int dstW, int dstY)
  244. {
  245. x86_reg dummy=0;
  246. x86_reg dstW_reg = dstW;
  247. x86_reg uv_off = c->uv_offx2;
  248. if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
  249. YSCALEYUV2PACKEDX_ACCURATE
  250. YSCALEYUV2RGBX
  251. "movq %%mm2, "U_TEMP"(%0) \n\t"
  252. "movq %%mm4, "V_TEMP"(%0) \n\t"
  253. "movq %%mm5, "Y_TEMP"(%0) \n\t"
  254. YSCALEYUV2PACKEDX_ACCURATE_YA(ALP_MMX_FILTER_OFFSET)
  255. "movq "Y_TEMP"(%0), %%mm5 \n\t"
  256. "psraw $3, %%mm1 \n\t"
  257. "psraw $3, %%mm7 \n\t"
  258. "packuswb %%mm7, %%mm1 \n\t"
  259. WRITEBGR32(%4, "%5", %%FF_REGa, %%mm3, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm2, %%mm6)
  260. YSCALEYUV2PACKEDX_END
  261. } else {
  262. YSCALEYUV2PACKEDX_ACCURATE
  263. YSCALEYUV2RGBX
  264. "pcmpeqd %%mm7, %%mm7 \n\t"
  265. WRITEBGR32(%4, "%5", %%FF_REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
  266. YSCALEYUV2PACKEDX_END
  267. }
  268. }
  269. static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter,
  270. const int16_t **lumSrc, int lumFilterSize,
  271. const int16_t *chrFilter, const int16_t **chrUSrc,
  272. const int16_t **chrVSrc,
  273. int chrFilterSize, const int16_t **alpSrc,
  274. uint8_t *dest, int dstW, int dstY)
  275. {
  276. x86_reg dummy=0;
  277. x86_reg dstW_reg = dstW;
  278. x86_reg uv_off = c->uv_offx2;
  279. if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
  280. YSCALEYUV2PACKEDX
  281. YSCALEYUV2RGBX
  282. YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7)
  283. "psraw $3, %%mm1 \n\t"
  284. "psraw $3, %%mm7 \n\t"
  285. "packuswb %%mm7, %%mm1 \n\t"
  286. WRITEBGR32(%4, "%5", %%FF_REGa, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
  287. YSCALEYUV2PACKEDX_END
  288. } else {
  289. YSCALEYUV2PACKEDX
  290. YSCALEYUV2RGBX
  291. "pcmpeqd %%mm7, %%mm7 \n\t"
  292. WRITEBGR32(%4, "%5", %%FF_REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
  293. YSCALEYUV2PACKEDX_END
  294. }
  295. }
  296. static void RENAME(yuv2bgr32_X)(SwsContext *c, const int16_t *lumFilter,
  297. const int16_t **lumSrc, int lumFilterSize,
  298. const int16_t *chrFilter, const int16_t **chrUSrc,
  299. const int16_t **chrVSrc,
  300. int chrFilterSize, const int16_t **alpSrc,
  301. uint8_t *dest, int dstW, int dstY)
  302. {
  303. x86_reg dummy=0;
  304. x86_reg dstW_reg = dstW;
  305. x86_reg uv_off = c->uv_offx2;
  306. if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
  307. YSCALEYUV2PACKEDX
  308. YSCALEYUV2RGBX
  309. YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7)
  310. "psraw $3, %%mm1 \n\t"
  311. "psraw $3, %%mm7 \n\t"
  312. "packuswb %%mm7, %%mm1 \n\t"
  313. WRITEBGR32(%4, "%5", %%FF_REGa, %%mm5, %%mm4, %%mm2, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
  314. YSCALEYUV2PACKEDX_END
  315. } else {
  316. YSCALEYUV2PACKEDX
  317. YSCALEYUV2RGBX
  318. "pcmpeqd %%mm7, %%mm7 \n\t"
  319. WRITEBGR32(%4, "%5", %%FF_REGa, %%mm5, %%mm4, %%mm2, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
  320. YSCALEYUV2PACKEDX_END
  321. }
  322. }
  323. #define REAL_WRITERGB16(dst, dstw, index) \
  324. "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\
  325. "pand "MANGLE(bFC)", %%mm4 \n\t" /* G */\
  326. "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\
  327. "psrlq $3, %%mm2 \n\t"\
  328. \
  329. "movq %%mm2, %%mm1 \n\t"\
  330. "movq %%mm4, %%mm3 \n\t"\
  331. \
  332. "punpcklbw %%mm7, %%mm3 \n\t"\
  333. "punpcklbw %%mm5, %%mm2 \n\t"\
  334. "punpckhbw %%mm7, %%mm4 \n\t"\
  335. "punpckhbw %%mm5, %%mm1 \n\t"\
  336. \
  337. "psllq $3, %%mm3 \n\t"\
  338. "psllq $3, %%mm4 \n\t"\
  339. \
  340. "por %%mm3, %%mm2 \n\t"\
  341. "por %%mm4, %%mm1 \n\t"\
  342. \
  343. MOVNTQ(%%mm2, (dst, index, 2))\
  344. MOVNTQ(%%mm1, 8(dst, index, 2))\
  345. \
  346. "add $8, "#index" \n\t"\
  347. "cmp "dstw", "#index" \n\t"\
  348. " jb 1b \n\t"
  349. #define WRITERGB16(dst, dstw, index) REAL_WRITERGB16(dst, dstw, index)
  350. static void RENAME(yuv2rgb565_X_ar)(SwsContext *c, const int16_t *lumFilter,
  351. const int16_t **lumSrc, int lumFilterSize,
  352. const int16_t *chrFilter, const int16_t **chrUSrc,
  353. const int16_t **chrVSrc,
  354. int chrFilterSize, const int16_t **alpSrc,
  355. uint8_t *dest, int dstW, int dstY)
  356. {
  357. x86_reg dummy=0;
  358. x86_reg dstW_reg = dstW;
  359. x86_reg uv_off = c->uv_offx2;
  360. YSCALEYUV2PACKEDX_ACCURATE
  361. YSCALEYUV2RGBX
  362. "pxor %%mm7, %%mm7 \n\t"
  363. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  364. "paddusb "BLUE_DITHER"(%0), %%mm2\n\t"
  365. "paddusb "GREEN_DITHER"(%0), %%mm4\n\t"
  366. "paddusb "RED_DITHER"(%0), %%mm5\n\t"
  367. WRITERGB16(%4, "%5", %%FF_REGa)
  368. YSCALEYUV2PACKEDX_END
  369. }
  370. static void RENAME(yuv2rgb565_X)(SwsContext *c, const int16_t *lumFilter,
  371. const int16_t **lumSrc, int lumFilterSize,
  372. const int16_t *chrFilter, const int16_t **chrUSrc,
  373. const int16_t **chrVSrc,
  374. int chrFilterSize, const int16_t **alpSrc,
  375. uint8_t *dest, int dstW, int dstY)
  376. {
  377. x86_reg dummy=0;
  378. x86_reg dstW_reg = dstW;
  379. x86_reg uv_off = c->uv_offx2;
  380. YSCALEYUV2PACKEDX
  381. YSCALEYUV2RGBX
  382. "pxor %%mm7, %%mm7 \n\t"
  383. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  384. "paddusb "BLUE_DITHER"(%0), %%mm2 \n\t"
  385. "paddusb "GREEN_DITHER"(%0), %%mm4 \n\t"
  386. "paddusb "RED_DITHER"(%0), %%mm5 \n\t"
  387. WRITERGB16(%4, "%5", %%FF_REGa)
  388. YSCALEYUV2PACKEDX_END
  389. }
  390. #define REAL_WRITERGB15(dst, dstw, index) \
  391. "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\
  392. "pand "MANGLE(bF8)", %%mm4 \n\t" /* G */\
  393. "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\
  394. "psrlq $3, %%mm2 \n\t"\
  395. "psrlq $1, %%mm5 \n\t"\
  396. \
  397. "movq %%mm2, %%mm1 \n\t"\
  398. "movq %%mm4, %%mm3 \n\t"\
  399. \
  400. "punpcklbw %%mm7, %%mm3 \n\t"\
  401. "punpcklbw %%mm5, %%mm2 \n\t"\
  402. "punpckhbw %%mm7, %%mm4 \n\t"\
  403. "punpckhbw %%mm5, %%mm1 \n\t"\
  404. \
  405. "psllq $2, %%mm3 \n\t"\
  406. "psllq $2, %%mm4 \n\t"\
  407. \
  408. "por %%mm3, %%mm2 \n\t"\
  409. "por %%mm4, %%mm1 \n\t"\
  410. \
  411. MOVNTQ(%%mm2, (dst, index, 2))\
  412. MOVNTQ(%%mm1, 8(dst, index, 2))\
  413. \
  414. "add $8, "#index" \n\t"\
  415. "cmp "dstw", "#index" \n\t"\
  416. " jb 1b \n\t"
  417. #define WRITERGB15(dst, dstw, index) REAL_WRITERGB15(dst, dstw, index)
  418. static void RENAME(yuv2rgb555_X_ar)(SwsContext *c, const int16_t *lumFilter,
  419. const int16_t **lumSrc, int lumFilterSize,
  420. const int16_t *chrFilter, const int16_t **chrUSrc,
  421. const int16_t **chrVSrc,
  422. int chrFilterSize, const int16_t **alpSrc,
  423. uint8_t *dest, int dstW, int dstY)
  424. {
  425. x86_reg dummy=0;
  426. x86_reg dstW_reg = dstW;
  427. x86_reg uv_off = c->uv_offx2;
  428. YSCALEYUV2PACKEDX_ACCURATE
  429. YSCALEYUV2RGBX
  430. "pxor %%mm7, %%mm7 \n\t"
  431. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  432. "paddusb "BLUE_DITHER"(%0), %%mm2\n\t"
  433. "paddusb "GREEN_DITHER"(%0), %%mm4\n\t"
  434. "paddusb "RED_DITHER"(%0), %%mm5\n\t"
  435. WRITERGB15(%4, "%5", %%FF_REGa)
  436. YSCALEYUV2PACKEDX_END
  437. }
  438. static void RENAME(yuv2rgb555_X)(SwsContext *c, const int16_t *lumFilter,
  439. const int16_t **lumSrc, int lumFilterSize,
  440. const int16_t *chrFilter, const int16_t **chrUSrc,
  441. const int16_t **chrVSrc,
  442. int chrFilterSize, const int16_t **alpSrc,
  443. uint8_t *dest, int dstW, int dstY)
  444. {
  445. x86_reg dummy=0;
  446. x86_reg dstW_reg = dstW;
  447. x86_reg uv_off = c->uv_offx2;
  448. YSCALEYUV2PACKEDX
  449. YSCALEYUV2RGBX
  450. "pxor %%mm7, %%mm7 \n\t"
  451. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  452. "paddusb "BLUE_DITHER"(%0), %%mm2 \n\t"
  453. "paddusb "GREEN_DITHER"(%0), %%mm4 \n\t"
  454. "paddusb "RED_DITHER"(%0), %%mm5 \n\t"
  455. WRITERGB15(%4, "%5", %%FF_REGa)
  456. YSCALEYUV2PACKEDX_END
  457. }
  458. #define WRITEBGR24MMX(dst, dstw, index) \
  459. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
  460. "movq %%mm2, %%mm1 \n\t" /* B */\
  461. "movq %%mm5, %%mm6 \n\t" /* R */\
  462. "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\
  463. "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\
  464. "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\
  465. "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\
  466. "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\
  467. "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\
  468. "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\
  469. "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\
  470. "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\
  471. "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\
  472. \
  473. "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\
  474. "movq %%mm2, %%mm6 \n\t" /* 0RGB0RGB 1 */\
  475. "movq %%mm1, %%mm5 \n\t" /* 0RGB0RGB 2 */\
  476. "movq %%mm3, %%mm7 \n\t" /* 0RGB0RGB 3 */\
  477. \
  478. "psllq $40, %%mm0 \n\t" /* RGB00000 0 */\
  479. "psllq $40, %%mm2 \n\t" /* RGB00000 1 */\
  480. "psllq $40, %%mm1 \n\t" /* RGB00000 2 */\
  481. "psllq $40, %%mm3 \n\t" /* RGB00000 3 */\
  482. \
  483. "punpckhdq %%mm4, %%mm0 \n\t" /* 0RGBRGB0 0 */\
  484. "punpckhdq %%mm6, %%mm2 \n\t" /* 0RGBRGB0 1 */\
  485. "punpckhdq %%mm5, %%mm1 \n\t" /* 0RGBRGB0 2 */\
  486. "punpckhdq %%mm7, %%mm3 \n\t" /* 0RGBRGB0 3 */\
  487. \
  488. "psrlq $8, %%mm0 \n\t" /* 00RGBRGB 0 */\
  489. "movq %%mm2, %%mm6 \n\t" /* 0RGBRGB0 1 */\
  490. "psllq $40, %%mm2 \n\t" /* GB000000 1 */\
  491. "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\
  492. MOVNTQ(%%mm0, (dst))\
  493. \
  494. "psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */\
  495. "movq %%mm1, %%mm5 \n\t" /* 0RGBRGB0 2 */\
  496. "psllq $24, %%mm1 \n\t" /* BRGB0000 2 */\
  497. "por %%mm1, %%mm6 \n\t" /* BRGBRGBR 1 */\
  498. MOVNTQ(%%mm6, 8(dst))\
  499. \
  500. "psrlq $40, %%mm5 \n\t" /* 000000RG 2 */\
  501. "psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */\
  502. "por %%mm3, %%mm5 \n\t" /* RGBRGBRG 2 */\
  503. MOVNTQ(%%mm5, 16(dst))\
  504. \
  505. "add $24, "#dst" \n\t"\
  506. \
  507. "add $8, "#index" \n\t"\
  508. "cmp "dstw", "#index" \n\t"\
  509. " jb 1b \n\t"
  510. #define WRITEBGR24MMXEXT(dst, dstw, index) \
  511. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
  512. "movq "MANGLE(ff_M24A)", %%mm0 \n\t"\
  513. "movq "MANGLE(ff_M24C)", %%mm7 \n\t"\
  514. "pshufw $0x50, %%mm2, %%mm1 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */\
  515. "pshufw $0x50, %%mm4, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */\
  516. "pshufw $0x00, %%mm5, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */\
  517. \
  518. "pand %%mm0, %%mm1 \n\t" /* B2 B1 B0 */\
  519. "pand %%mm0, %%mm3 \n\t" /* G2 G1 G0 */\
  520. "pand %%mm7, %%mm6 \n\t" /* R1 R0 */\
  521. \
  522. "psllq $8, %%mm3 \n\t" /* G2 G1 G0 */\
  523. "por %%mm1, %%mm6 \n\t"\
  524. "por %%mm3, %%mm6 \n\t"\
  525. MOVNTQ(%%mm6, (dst))\
  526. \
  527. "psrlq $8, %%mm4 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */\
  528. "pshufw $0xA5, %%mm2, %%mm1 \n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */\
  529. "pshufw $0x55, %%mm4, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */\
  530. "pshufw $0xA5, %%mm5, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */\
  531. \
  532. "pand "MANGLE(ff_M24B)", %%mm1 \n\t" /* B5 B4 B3 */\
  533. "pand %%mm7, %%mm3 \n\t" /* G4 G3 */\
  534. "pand %%mm0, %%mm6 \n\t" /* R4 R3 R2 */\
  535. \
  536. "por %%mm1, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */\
  537. "por %%mm3, %%mm6 \n\t"\
  538. MOVNTQ(%%mm6, 8(dst))\
  539. \
  540. "pshufw $0xFF, %%mm2, %%mm1 \n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */\
  541. "pshufw $0xFA, %%mm4, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */\
  542. "pshufw $0xFA, %%mm5, %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */\
  543. \
  544. "pand %%mm7, %%mm1 \n\t" /* B7 B6 */\
  545. "pand %%mm0, %%mm3 \n\t" /* G7 G6 G5 */\
  546. "pand "MANGLE(ff_M24B)", %%mm6 \n\t" /* R7 R6 R5 */\
  547. \
  548. "por %%mm1, %%mm3 \n\t"\
  549. "por %%mm3, %%mm6 \n\t"\
  550. MOVNTQ(%%mm6, 16(dst))\
  551. \
  552. "add $24, "#dst" \n\t"\
  553. \
  554. "add $8, "#index" \n\t"\
  555. "cmp "dstw", "#index" \n\t"\
  556. " jb 1b \n\t"
  557. #undef WRITEBGR24
  558. #define WRITEBGR24(dst, dstw, index) WRITEBGR24MMXEXT(dst, dstw, index)
  559. #if HAVE_6REGS
  560. static void RENAME(yuv2bgr24_X_ar)(SwsContext *c, const int16_t *lumFilter,
  561. const int16_t **lumSrc, int lumFilterSize,
  562. const int16_t *chrFilter, const int16_t **chrUSrc,
  563. const int16_t **chrVSrc,
  564. int chrFilterSize, const int16_t **alpSrc,
  565. uint8_t *dest, int dstW, int dstY)
  566. {
  567. x86_reg dummy=0;
  568. x86_reg dstW_reg = dstW;
  569. x86_reg uv_off = c->uv_offx2;
  570. YSCALEYUV2PACKEDX_ACCURATE
  571. YSCALEYUV2RGBX
  572. "pxor %%mm7, %%mm7 \n\t"
  573. "lea (%%"FF_REG_a", %%"FF_REG_a", 2), %%"FF_REG_c"\n\t" //FIXME optimize
  574. "add %4, %%"FF_REG_c" \n\t"
  575. WRITEBGR24(%%FF_REGc, "%5", %%FF_REGa)
  576. :: "r" (&c->redDither),
  577. "m" (dummy), "m" (dummy), "m" (dummy),
  578. "r" (dest), "m" (dstW_reg), "m"(uv_off)
  579. NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
  580. : "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S
  581. );
  582. }
  583. static void RENAME(yuv2bgr24_X)(SwsContext *c, const int16_t *lumFilter,
  584. const int16_t **lumSrc, int lumFilterSize,
  585. const int16_t *chrFilter, const int16_t **chrUSrc,
  586. const int16_t **chrVSrc,
  587. int chrFilterSize, const int16_t **alpSrc,
  588. uint8_t *dest, int dstW, int dstY)
  589. {
  590. x86_reg dummy=0;
  591. x86_reg dstW_reg = dstW;
  592. x86_reg uv_off = c->uv_offx2;
  593. YSCALEYUV2PACKEDX
  594. YSCALEYUV2RGBX
  595. "pxor %%mm7, %%mm7 \n\t"
  596. "lea (%%"FF_REG_a", %%"FF_REG_a", 2), %%"FF_REG_c" \n\t" //FIXME optimize
  597. "add %4, %%"FF_REG_c" \n\t"
  598. WRITEBGR24(%%FF_REGc, "%5", %%FF_REGa)
  599. :: "r" (&c->redDither),
  600. "m" (dummy), "m" (dummy), "m" (dummy),
  601. "r" (dest), "m" (dstW_reg), "m"(uv_off)
  602. NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
  603. : "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S
  604. );
  605. }
  606. #endif /* HAVE_6REGS */
  607. #define REAL_WRITEYUY2(dst, dstw, index) \
  608. "packuswb %%mm3, %%mm3 \n\t"\
  609. "packuswb %%mm4, %%mm4 \n\t"\
  610. "packuswb %%mm7, %%mm1 \n\t"\
  611. "punpcklbw %%mm4, %%mm3 \n\t"\
  612. "movq %%mm1, %%mm7 \n\t"\
  613. "punpcklbw %%mm3, %%mm1 \n\t"\
  614. "punpckhbw %%mm3, %%mm7 \n\t"\
  615. \
  616. MOVNTQ(%%mm1, (dst, index, 2))\
  617. MOVNTQ(%%mm7, 8(dst, index, 2))\
  618. \
  619. "add $8, "#index" \n\t"\
  620. "cmp "dstw", "#index" \n\t"\
  621. " jb 1b \n\t"
  622. #define WRITEYUY2(dst, dstw, index) REAL_WRITEYUY2(dst, dstw, index)
  623. static void RENAME(yuv2yuyv422_X_ar)(SwsContext *c, const int16_t *lumFilter,
  624. const int16_t **lumSrc, int lumFilterSize,
  625. const int16_t *chrFilter, const int16_t **chrUSrc,
  626. const int16_t **chrVSrc,
  627. int chrFilterSize, const int16_t **alpSrc,
  628. uint8_t *dest, int dstW, int dstY)
  629. {
  630. x86_reg dummy=0;
  631. x86_reg dstW_reg = dstW;
  632. x86_reg uv_off = c->uv_offx2;
  633. YSCALEYUV2PACKEDX_ACCURATE
  634. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  635. "psraw $3, %%mm3 \n\t"
  636. "psraw $3, %%mm4 \n\t"
  637. "psraw $3, %%mm1 \n\t"
  638. "psraw $3, %%mm7 \n\t"
  639. WRITEYUY2(%4, "%5", %%FF_REGa)
  640. YSCALEYUV2PACKEDX_END
  641. }
  642. static void RENAME(yuv2yuyv422_X)(SwsContext *c, const int16_t *lumFilter,
  643. const int16_t **lumSrc, int lumFilterSize,
  644. const int16_t *chrFilter, const int16_t **chrUSrc,
  645. const int16_t **chrVSrc,
  646. int chrFilterSize, const int16_t **alpSrc,
  647. uint8_t *dest, int dstW, int dstY)
  648. {
  649. x86_reg dummy=0;
  650. x86_reg dstW_reg = dstW;
  651. x86_reg uv_off = c->uv_offx2;
  652. YSCALEYUV2PACKEDX
  653. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  654. "psraw $3, %%mm3 \n\t"
  655. "psraw $3, %%mm4 \n\t"
  656. "psraw $3, %%mm1 \n\t"
  657. "psraw $3, %%mm7 \n\t"
  658. WRITEYUY2(%4, "%5", %%FF_REGa)
  659. YSCALEYUV2PACKEDX_END
  660. }
  661. #define REAL_YSCALEYUV2RGB_UV(index, c) \
  662. "xor "#index", "#index" \n\t"\
  663. ".p2align 4 \n\t"\
  664. "1: \n\t"\
  665. "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
  666. "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
  667. "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  668. "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
  669. "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
  670. "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  671. "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\
  672. "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\
  673. "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\
  674. "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\
  675. "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\
  676. "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
  677. "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
  678. "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\
  679. "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\
  680. "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\
  681. "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\
  682. "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
  683. "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
  684. "pmulhw "UG_COEFF"("#c"), %%mm3 \n\t"\
  685. "pmulhw "VG_COEFF"("#c"), %%mm4 \n\t"\
  686. /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
  687. #define REAL_YSCALEYUV2RGB_YA(index, c, b1, b2) \
  688. "movq ("#b1", "#index", 2), %%mm0 \n\t" /*buf0[eax]*/\
  689. "movq ("#b2", "#index", 2), %%mm1 \n\t" /*buf1[eax]*/\
  690. "movq 8("#b1", "#index", 2), %%mm6 \n\t" /*buf0[eax]*/\
  691. "movq 8("#b2", "#index", 2), %%mm7 \n\t" /*buf1[eax]*/\
  692. "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\
  693. "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\
  694. "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
  695. "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm6 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
  696. "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
  697. "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
  698. "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
  699. "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
  700. #define REAL_YSCALEYUV2RGB_COEFF(c) \
  701. "pmulhw "UB_COEFF"("#c"), %%mm2 \n\t"\
  702. "pmulhw "VR_COEFF"("#c"), %%mm5 \n\t"\
  703. "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\
  704. "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\
  705. "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\
  706. "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\
  707. /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
  708. "paddw %%mm3, %%mm4 \n\t"\
  709. "movq %%mm2, %%mm0 \n\t"\
  710. "movq %%mm5, %%mm6 \n\t"\
  711. "movq %%mm4, %%mm3 \n\t"\
  712. "punpcklwd %%mm2, %%mm2 \n\t"\
  713. "punpcklwd %%mm5, %%mm5 \n\t"\
  714. "punpcklwd %%mm4, %%mm4 \n\t"\
  715. "paddw %%mm1, %%mm2 \n\t"\
  716. "paddw %%mm1, %%mm5 \n\t"\
  717. "paddw %%mm1, %%mm4 \n\t"\
  718. "punpckhwd %%mm0, %%mm0 \n\t"\
  719. "punpckhwd %%mm6, %%mm6 \n\t"\
  720. "punpckhwd %%mm3, %%mm3 \n\t"\
  721. "paddw %%mm7, %%mm0 \n\t"\
  722. "paddw %%mm7, %%mm6 \n\t"\
  723. "paddw %%mm7, %%mm3 \n\t"\
  724. /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
  725. "packuswb %%mm0, %%mm2 \n\t"\
  726. "packuswb %%mm6, %%mm5 \n\t"\
  727. "packuswb %%mm3, %%mm4 \n\t"\
  728. #define YSCALEYUV2RGB_YA(index, c, b1, b2) REAL_YSCALEYUV2RGB_YA(index, c, b1, b2)
  729. #define YSCALEYUV2RGB(index, c) \
  730. REAL_YSCALEYUV2RGB_UV(index, c) \
  731. REAL_YSCALEYUV2RGB_YA(index, c, %0, %1) \
  732. REAL_YSCALEYUV2RGB_COEFF(c)
  733. /**
  734. * vertical bilinear scale YV12 to RGB
  735. */
  736. static void RENAME(yuv2rgb32_2)(SwsContext *c, const int16_t *buf[2],
  737. const int16_t *ubuf[2], const int16_t *vbuf[2],
  738. const int16_t *abuf[2], uint8_t *dest,
  739. int dstW, int yalpha, int uvalpha, int y)
  740. {
  741. const int16_t *buf0 = buf[0], *buf1 = buf[1],
  742. *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
  743. if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
  744. const int16_t *abuf0 = abuf[0], *abuf1 = abuf[1];
  745. #if ARCH_X86_64
  746. __asm__ volatile(
  747. YSCALEYUV2RGB(%%r8, %5)
  748. YSCALEYUV2RGB_YA(%%r8, %5, %6, %7)
  749. "psraw $3, %%mm1 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
  750. "psraw $3, %%mm7 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
  751. "packuswb %%mm7, %%mm1 \n\t"
  752. WRITEBGR32(%4, DSTW_OFFSET"(%5)", %%r8, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
  753. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "r" (dest),
  754. "a" (&c->redDither),
  755. "r" (abuf0), "r" (abuf1)
  756. : "%r8"
  757. );
  758. #else
  759. c->u_temp=(intptr_t)abuf0;
  760. c->v_temp=(intptr_t)abuf1;
  761. __asm__ volatile(
  762. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  763. "mov %4, %%"FF_REG_b" \n\t"
  764. "push %%"FF_REG_BP" \n\t"
  765. YSCALEYUV2RGB(%%FF_REGBP, %5)
  766. "push %0 \n\t"
  767. "push %1 \n\t"
  768. "mov "U_TEMP"(%5), %0 \n\t"
  769. "mov "V_TEMP"(%5), %1 \n\t"
  770. YSCALEYUV2RGB_YA(%%FF_REGBP, %5, %0, %1)
  771. "psraw $3, %%mm1 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
  772. "psraw $3, %%mm7 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
  773. "packuswb %%mm7, %%mm1 \n\t"
  774. "pop %1 \n\t"
  775. "pop %0 \n\t"
  776. WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
  777. "pop %%"FF_REG_BP" \n\t"
  778. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  779. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  780. "a" (&c->redDither)
  781. );
  782. #endif
  783. } else {
  784. __asm__ volatile(
  785. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  786. "mov %4, %%"FF_REG_b" \n\t"
  787. "push %%"FF_REG_BP" \n\t"
  788. YSCALEYUV2RGB(%%FF_REGBP, %5)
  789. "pcmpeqd %%mm7, %%mm7 \n\t"
  790. WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
  791. "pop %%"FF_REG_BP" \n\t"
  792. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  793. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  794. "a" (&c->redDither)
  795. );
  796. }
  797. }
  798. static void RENAME(yuv2bgr24_2)(SwsContext *c, const int16_t *buf[2],
  799. const int16_t *ubuf[2], const int16_t *vbuf[2],
  800. const int16_t *abuf[2], uint8_t *dest,
  801. int dstW, int yalpha, int uvalpha, int y)
  802. {
  803. const int16_t *buf0 = buf[0], *buf1 = buf[1],
  804. *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
  805. __asm__ volatile(
  806. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  807. "mov %4, %%"FF_REG_b" \n\t"
  808. "push %%"FF_REG_BP" \n\t"
  809. YSCALEYUV2RGB(%%FF_REGBP, %5)
  810. "pxor %%mm7, %%mm7 \n\t"
  811. WRITEBGR24(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  812. "pop %%"FF_REG_BP" \n\t"
  813. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  814. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  815. "a" (&c->redDither)
  816. NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
  817. );
  818. }
  819. static void RENAME(yuv2rgb555_2)(SwsContext *c, const int16_t *buf[2],
  820. const int16_t *ubuf[2], const int16_t *vbuf[2],
  821. const int16_t *abuf[2], uint8_t *dest,
  822. int dstW, int yalpha, int uvalpha, int y)
  823. {
  824. const int16_t *buf0 = buf[0], *buf1 = buf[1],
  825. *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
  826. __asm__ volatile(
  827. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  828. "mov %4, %%"FF_REG_b" \n\t"
  829. "push %%"FF_REG_BP" \n\t"
  830. YSCALEYUV2RGB(%%FF_REGBP, %5)
  831. "pxor %%mm7, %%mm7 \n\t"
  832. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  833. "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
  834. "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
  835. "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
  836. WRITERGB15(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  837. "pop %%"FF_REG_BP" \n\t"
  838. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  839. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  840. "a" (&c->redDither)
  841. NAMED_CONSTRAINTS_ADD(bF8)
  842. );
  843. }
  844. static void RENAME(yuv2rgb565_2)(SwsContext *c, const int16_t *buf[2],
  845. const int16_t *ubuf[2], const int16_t *vbuf[2],
  846. const int16_t *abuf[2], uint8_t *dest,
  847. int dstW, int yalpha, int uvalpha, int y)
  848. {
  849. const int16_t *buf0 = buf[0], *buf1 = buf[1],
  850. *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
  851. __asm__ volatile(
  852. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  853. "mov %4, %%"FF_REG_b" \n\t"
  854. "push %%"FF_REG_BP" \n\t"
  855. YSCALEYUV2RGB(%%FF_REGBP, %5)
  856. "pxor %%mm7, %%mm7 \n\t"
  857. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  858. "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
  859. "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
  860. "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
  861. WRITERGB16(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  862. "pop %%"FF_REG_BP" \n\t"
  863. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  864. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  865. "a" (&c->redDither)
  866. NAMED_CONSTRAINTS_ADD(bF8,bFC)
  867. );
  868. }
  869. #define REAL_YSCALEYUV2PACKED(index, c) \
  870. "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\
  871. "movq "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm1 \n\t"\
  872. "psraw $3, %%mm0 \n\t"\
  873. "psraw $3, %%mm1 \n\t"\
  874. "movq %%mm0, "CHR_MMX_FILTER_OFFSET"+8("#c") \n\t"\
  875. "movq %%mm1, "LUM_MMX_FILTER_OFFSET"+8("#c") \n\t"\
  876. "xor "#index", "#index" \n\t"\
  877. ".p2align 4 \n\t"\
  878. "1: \n\t"\
  879. "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
  880. "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
  881. "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  882. "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
  883. "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
  884. "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  885. "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\
  886. "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\
  887. "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\
  888. "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\
  889. "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\
  890. "psraw $7, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
  891. "psraw $7, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
  892. "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\
  893. "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\
  894. "movq (%0, "#index", 2), %%mm0 \n\t" /*buf0[eax]*/\
  895. "movq (%1, "#index", 2), %%mm1 \n\t" /*buf1[eax]*/\
  896. "movq 8(%0, "#index", 2), %%mm6 \n\t" /*buf0[eax]*/\
  897. "movq 8(%1, "#index", 2), %%mm7 \n\t" /*buf1[eax]*/\
  898. "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\
  899. "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\
  900. "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
  901. "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm6 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
  902. "psraw $7, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
  903. "psraw $7, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
  904. "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
  905. "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
  906. #define YSCALEYUV2PACKED(index, c) REAL_YSCALEYUV2PACKED(index, c)
  907. static void RENAME(yuv2yuyv422_2)(SwsContext *c, const int16_t *buf[2],
  908. const int16_t *ubuf[2], const int16_t *vbuf[2],
  909. const int16_t *abuf[2], uint8_t *dest,
  910. int dstW, int yalpha, int uvalpha, int y)
  911. {
  912. const int16_t *buf0 = buf[0], *buf1 = buf[1],
  913. *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
  914. __asm__ volatile(
  915. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  916. "mov %4, %%"FF_REG_b" \n\t"
  917. "push %%"FF_REG_BP" \n\t"
  918. YSCALEYUV2PACKED(%%FF_REGBP, %5)
  919. WRITEYUY2(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  920. "pop %%"FF_REG_BP" \n\t"
  921. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  922. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  923. "a" (&c->redDither)
  924. );
  925. }
  926. #define REAL_YSCALEYUV2RGB1(index, c) \
  927. "xor "#index", "#index" \n\t"\
  928. ".p2align 4 \n\t"\
  929. "1: \n\t"\
  930. "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\
  931. "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  932. "movq (%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\
  933. "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  934. "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
  935. "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
  936. "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\
  937. "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\
  938. "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
  939. "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
  940. "pmulhw "UG_COEFF"("#c"), %%mm3 \n\t"\
  941. "pmulhw "VG_COEFF"("#c"), %%mm4 \n\t"\
  942. /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
  943. "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
  944. "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
  945. "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
  946. "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
  947. "pmulhw "UB_COEFF"("#c"), %%mm2 \n\t"\
  948. "pmulhw "VR_COEFF"("#c"), %%mm5 \n\t"\
  949. "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\
  950. "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\
  951. "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\
  952. "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\
  953. /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
  954. "paddw %%mm3, %%mm4 \n\t"\
  955. "movq %%mm2, %%mm0 \n\t"\
  956. "movq %%mm5, %%mm6 \n\t"\
  957. "movq %%mm4, %%mm3 \n\t"\
  958. "punpcklwd %%mm2, %%mm2 \n\t"\
  959. "punpcklwd %%mm5, %%mm5 \n\t"\
  960. "punpcklwd %%mm4, %%mm4 \n\t"\
  961. "paddw %%mm1, %%mm2 \n\t"\
  962. "paddw %%mm1, %%mm5 \n\t"\
  963. "paddw %%mm1, %%mm4 \n\t"\
  964. "punpckhwd %%mm0, %%mm0 \n\t"\
  965. "punpckhwd %%mm6, %%mm6 \n\t"\
  966. "punpckhwd %%mm3, %%mm3 \n\t"\
  967. "paddw %%mm7, %%mm0 \n\t"\
  968. "paddw %%mm7, %%mm6 \n\t"\
  969. "paddw %%mm7, %%mm3 \n\t"\
  970. /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
  971. "packuswb %%mm0, %%mm2 \n\t"\
  972. "packuswb %%mm6, %%mm5 \n\t"\
  973. "packuswb %%mm3, %%mm4 \n\t"\
  974. #define YSCALEYUV2RGB1(index, c) REAL_YSCALEYUV2RGB1(index, c)
  975. // do vertical chrominance interpolation
  976. #define REAL_YSCALEYUV2RGB1b(index, c) \
  977. "xor "#index", "#index" \n\t"\
  978. ".p2align 4 \n\t"\
  979. "1: \n\t"\
  980. "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
  981. "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
  982. "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  983. "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
  984. "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
  985. "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  986. "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\
  987. "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\
  988. "psrlw $5, %%mm3 \n\t" /*FIXME might overflow*/\
  989. "psrlw $5, %%mm4 \n\t" /*FIXME might overflow*/\
  990. "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\
  991. "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\
  992. "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
  993. "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
  994. "pmulhw "UG_COEFF"("#c"), %%mm3 \n\t"\
  995. "pmulhw "VG_COEFF"("#c"), %%mm4 \n\t"\
  996. /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
  997. "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
  998. "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
  999. "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
  1000. "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
  1001. "pmulhw "UB_COEFF"("#c"), %%mm2 \n\t"\
  1002. "pmulhw "VR_COEFF"("#c"), %%mm5 \n\t"\
  1003. "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\
  1004. "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\
  1005. "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\
  1006. "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\
  1007. /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
  1008. "paddw %%mm3, %%mm4 \n\t"\
  1009. "movq %%mm2, %%mm0 \n\t"\
  1010. "movq %%mm5, %%mm6 \n\t"\
  1011. "movq %%mm4, %%mm3 \n\t"\
  1012. "punpcklwd %%mm2, %%mm2 \n\t"\
  1013. "punpcklwd %%mm5, %%mm5 \n\t"\
  1014. "punpcklwd %%mm4, %%mm4 \n\t"\
  1015. "paddw %%mm1, %%mm2 \n\t"\
  1016. "paddw %%mm1, %%mm5 \n\t"\
  1017. "paddw %%mm1, %%mm4 \n\t"\
  1018. "punpckhwd %%mm0, %%mm0 \n\t"\
  1019. "punpckhwd %%mm6, %%mm6 \n\t"\
  1020. "punpckhwd %%mm3, %%mm3 \n\t"\
  1021. "paddw %%mm7, %%mm0 \n\t"\
  1022. "paddw %%mm7, %%mm6 \n\t"\
  1023. "paddw %%mm7, %%mm3 \n\t"\
  1024. /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
  1025. "packuswb %%mm0, %%mm2 \n\t"\
  1026. "packuswb %%mm6, %%mm5 \n\t"\
  1027. "packuswb %%mm3, %%mm4 \n\t"\
  1028. #define YSCALEYUV2RGB1b(index, c) REAL_YSCALEYUV2RGB1b(index, c)
  1029. #define REAL_YSCALEYUV2RGB1_ALPHA(index) \
  1030. "movq (%1, "#index", 2), %%mm7 \n\t" /* abuf0[index ] */\
  1031. "movq 8(%1, "#index", 2), %%mm1 \n\t" /* abuf0[index+4] */\
  1032. "psraw $7, %%mm7 \n\t" /* abuf0[index ] >>7 */\
  1033. "psraw $7, %%mm1 \n\t" /* abuf0[index+4] >>7 */\
  1034. "packuswb %%mm1, %%mm7 \n\t"
  1035. #define YSCALEYUV2RGB1_ALPHA(index) REAL_YSCALEYUV2RGB1_ALPHA(index)
  1036. /**
  1037. * YV12 to RGB without scaling or interpolating
  1038. */
  1039. static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0,
  1040. const int16_t *ubuf[2], const int16_t *vbuf[2],
  1041. const int16_t *abuf0, uint8_t *dest,
  1042. int dstW, int uvalpha, int y)
  1043. {
  1044. const int16_t *ubuf0 = ubuf[0];
  1045. const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
  1046. if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
  1047. const int16_t *ubuf1 = ubuf[0];
  1048. if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
  1049. __asm__ volatile(
  1050. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1051. "mov %4, %%"FF_REG_b" \n\t"
  1052. "push %%"FF_REG_BP" \n\t"
  1053. YSCALEYUV2RGB1(%%FF_REGBP, %5)
  1054. YSCALEYUV2RGB1_ALPHA(%%FF_REGBP)
  1055. WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
  1056. "pop %%"FF_REG_BP" \n\t"
  1057. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1058. :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1059. "a" (&c->redDither)
  1060. );
  1061. } else {
  1062. __asm__ volatile(
  1063. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1064. "mov %4, %%"FF_REG_b" \n\t"
  1065. "push %%"FF_REG_BP" \n\t"
  1066. YSCALEYUV2RGB1(%%FF_REGBP, %5)
  1067. "pcmpeqd %%mm7, %%mm7 \n\t"
  1068. WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
  1069. "pop %%"FF_REG_BP" \n\t"
  1070. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1071. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1072. "a" (&c->redDither)
  1073. );
  1074. }
  1075. } else {
  1076. const int16_t *ubuf1 = ubuf[1];
  1077. if (CONFIG_SWSCALE_ALPHA && c->needAlpha) {
  1078. __asm__ volatile(
  1079. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1080. "mov %4, %%"FF_REG_b" \n\t"
  1081. "push %%"FF_REG_BP" \n\t"
  1082. YSCALEYUV2RGB1b(%%FF_REGBP, %5)
  1083. YSCALEYUV2RGB1_ALPHA(%%FF_REGBP)
  1084. WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
  1085. "pop %%"FF_REG_BP" \n\t"
  1086. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1087. :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1088. "a" (&c->redDither)
  1089. );
  1090. } else {
  1091. __asm__ volatile(
  1092. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1093. "mov %4, %%"FF_REG_b" \n\t"
  1094. "push %%"FF_REG_BP" \n\t"
  1095. YSCALEYUV2RGB1b(%%FF_REGBP, %5)
  1096. "pcmpeqd %%mm7, %%mm7 \n\t"
  1097. WRITEBGR32(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
  1098. "pop %%"FF_REG_BP" \n\t"
  1099. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1100. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1101. "a" (&c->redDither)
  1102. );
  1103. }
  1104. }
  1105. }
  1106. static void RENAME(yuv2bgr24_1)(SwsContext *c, const int16_t *buf0,
  1107. const int16_t *ubuf[2], const int16_t *vbuf[2],
  1108. const int16_t *abuf0, uint8_t *dest,
  1109. int dstW, int uvalpha, int y)
  1110. {
  1111. const int16_t *ubuf0 = ubuf[0];
  1112. const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
  1113. if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
  1114. const int16_t *ubuf1 = ubuf[0];
  1115. __asm__ volatile(
  1116. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1117. "mov %4, %%"FF_REG_b" \n\t"
  1118. "push %%"FF_REG_BP" \n\t"
  1119. YSCALEYUV2RGB1(%%FF_REGBP, %5)
  1120. "pxor %%mm7, %%mm7 \n\t"
  1121. WRITEBGR24(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  1122. "pop %%"FF_REG_BP" \n\t"
  1123. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1124. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1125. "a" (&c->redDither)
  1126. NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
  1127. );
  1128. } else {
  1129. const int16_t *ubuf1 = ubuf[1];
  1130. __asm__ volatile(
  1131. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1132. "mov %4, %%"FF_REG_b" \n\t"
  1133. "push %%"FF_REG_BP" \n\t"
  1134. YSCALEYUV2RGB1b(%%FF_REGBP, %5)
  1135. "pxor %%mm7, %%mm7 \n\t"
  1136. WRITEBGR24(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  1137. "pop %%"FF_REG_BP" \n\t"
  1138. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1139. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1140. "a" (&c->redDither)
  1141. NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
  1142. );
  1143. }
  1144. }
  1145. static void RENAME(yuv2rgb555_1)(SwsContext *c, const int16_t *buf0,
  1146. const int16_t *ubuf[2], const int16_t *vbuf[2],
  1147. const int16_t *abuf0, uint8_t *dest,
  1148. int dstW, int uvalpha, int y)
  1149. {
  1150. const int16_t *ubuf0 = ubuf[0];
  1151. const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
  1152. if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
  1153. const int16_t *ubuf1 = ubuf[0];
  1154. __asm__ volatile(
  1155. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1156. "mov %4, %%"FF_REG_b" \n\t"
  1157. "push %%"FF_REG_BP" \n\t"
  1158. YSCALEYUV2RGB1(%%FF_REGBP, %5)
  1159. "pxor %%mm7, %%mm7 \n\t"
  1160. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  1161. "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
  1162. "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
  1163. "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
  1164. WRITERGB15(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  1165. "pop %%"FF_REG_BP" \n\t"
  1166. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1167. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1168. "a" (&c->redDither)
  1169. NAMED_CONSTRAINTS_ADD(bF8)
  1170. );
  1171. } else {
  1172. const int16_t *ubuf1 = ubuf[1];
  1173. __asm__ volatile(
  1174. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1175. "mov %4, %%"FF_REG_b" \n\t"
  1176. "push %%"FF_REG_BP" \n\t"
  1177. YSCALEYUV2RGB1b(%%FF_REGBP, %5)
  1178. "pxor %%mm7, %%mm7 \n\t"
  1179. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  1180. "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
  1181. "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
  1182. "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
  1183. WRITERGB15(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  1184. "pop %%"FF_REG_BP" \n\t"
  1185. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1186. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1187. "a" (&c->redDither)
  1188. NAMED_CONSTRAINTS_ADD(bF8)
  1189. );
  1190. }
  1191. }
  1192. static void RENAME(yuv2rgb565_1)(SwsContext *c, const int16_t *buf0,
  1193. const int16_t *ubuf[2], const int16_t *vbuf[2],
  1194. const int16_t *abuf0, uint8_t *dest,
  1195. int dstW, int uvalpha, int y)
  1196. {
  1197. const int16_t *ubuf0 = ubuf[0];
  1198. const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
  1199. if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
  1200. const int16_t *ubuf1 = ubuf[0];
  1201. __asm__ volatile(
  1202. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1203. "mov %4, %%"FF_REG_b" \n\t"
  1204. "push %%"FF_REG_BP" \n\t"
  1205. YSCALEYUV2RGB1(%%FF_REGBP, %5)
  1206. "pxor %%mm7, %%mm7 \n\t"
  1207. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  1208. "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
  1209. "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
  1210. "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
  1211. WRITERGB16(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  1212. "pop %%"FF_REG_BP" \n\t"
  1213. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1214. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1215. "a" (&c->redDither)
  1216. NAMED_CONSTRAINTS_ADD(bF8,bFC)
  1217. );
  1218. } else {
  1219. const int16_t *ubuf1 = ubuf[1];
  1220. __asm__ volatile(
  1221. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1222. "mov %4, %%"FF_REG_b" \n\t"
  1223. "push %%"FF_REG_BP" \n\t"
  1224. YSCALEYUV2RGB1b(%%FF_REGBP, %5)
  1225. "pxor %%mm7, %%mm7 \n\t"
  1226. /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
  1227. "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
  1228. "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
  1229. "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
  1230. WRITERGB16(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  1231. "pop %%"FF_REG_BP" \n\t"
  1232. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1233. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1234. "a" (&c->redDither)
  1235. NAMED_CONSTRAINTS_ADD(bF8,bFC)
  1236. );
  1237. }
  1238. }
  1239. #define REAL_YSCALEYUV2PACKED1(index, c) \
  1240. "xor "#index", "#index" \n\t"\
  1241. ".p2align 4 \n\t"\
  1242. "1: \n\t"\
  1243. "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\
  1244. "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  1245. "movq (%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\
  1246. "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  1247. "psraw $7, %%mm3 \n\t" \
  1248. "psraw $7, %%mm4 \n\t" \
  1249. "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
  1250. "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
  1251. "psraw $7, %%mm1 \n\t" \
  1252. "psraw $7, %%mm7 \n\t" \
  1253. #define YSCALEYUV2PACKED1(index, c) REAL_YSCALEYUV2PACKED1(index, c)
  1254. #define REAL_YSCALEYUV2PACKED1b(index, c) \
  1255. "xor "#index", "#index" \n\t"\
  1256. ".p2align 4 \n\t"\
  1257. "1: \n\t"\
  1258. "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
  1259. "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
  1260. "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  1261. "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
  1262. "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
  1263. "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
  1264. "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\
  1265. "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\
  1266. "psrlw $8, %%mm3 \n\t" \
  1267. "psrlw $8, %%mm4 \n\t" \
  1268. "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
  1269. "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
  1270. "psraw $7, %%mm1 \n\t" \
  1271. "psraw $7, %%mm7 \n\t"
  1272. #define YSCALEYUV2PACKED1b(index, c) REAL_YSCALEYUV2PACKED1b(index, c)
  1273. static void RENAME(yuv2yuyv422_1)(SwsContext *c, const int16_t *buf0,
  1274. const int16_t *ubuf[2], const int16_t *vbuf[2],
  1275. const int16_t *abuf0, uint8_t *dest,
  1276. int dstW, int uvalpha, int y)
  1277. {
  1278. const int16_t *ubuf0 = ubuf[0];
  1279. const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
  1280. if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
  1281. const int16_t *ubuf1 = ubuf[0];
  1282. __asm__ volatile(
  1283. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1284. "mov %4, %%"FF_REG_b" \n\t"
  1285. "push %%"FF_REG_BP" \n\t"
  1286. YSCALEYUV2PACKED1(%%FF_REGBP, %5)
  1287. WRITEYUY2(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  1288. "pop %%"FF_REG_BP" \n\t"
  1289. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1290. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1291. "a" (&c->redDither)
  1292. );
  1293. } else {
  1294. const int16_t *ubuf1 = ubuf[1];
  1295. __asm__ volatile(
  1296. "mov %%"FF_REG_b", "ESP_OFFSET"(%5) \n\t"
  1297. "mov %4, %%"FF_REG_b" \n\t"
  1298. "push %%"FF_REG_BP" \n\t"
  1299. YSCALEYUV2PACKED1b(%%FF_REGBP, %5)
  1300. WRITEYUY2(%%FF_REGb, DSTW_OFFSET"(%5)", %%FF_REGBP)
  1301. "pop %%"FF_REG_BP" \n\t"
  1302. "mov "ESP_OFFSET"(%5), %%"FF_REG_b" \n\t"
  1303. :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
  1304. "a" (&c->redDither)
  1305. );
  1306. }
  1307. }
  1308. static av_cold void RENAME(sws_init_swscale)(SwsContext *c)
  1309. {
  1310. enum AVPixelFormat dstFormat = c->dstFormat;
  1311. c->use_mmx_vfilter= 0;
  1312. if (!is16BPS(dstFormat) && !isNBPS(dstFormat) && !isSemiPlanarYUV(dstFormat)
  1313. && dstFormat != AV_PIX_FMT_GRAYF32BE && dstFormat != AV_PIX_FMT_GRAYF32LE
  1314. && !(c->flags & SWS_BITEXACT)) {
  1315. if (c->flags & SWS_ACCURATE_RND) {
  1316. if (!(c->flags & SWS_FULL_CHR_H_INT)) {
  1317. switch (c->dstFormat) {
  1318. case AV_PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break;
  1319. #if HAVE_6REGS
  1320. case AV_PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break;
  1321. #endif
  1322. case AV_PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X_ar); break;
  1323. case AV_PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X_ar); break;
  1324. case AV_PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break;
  1325. default: break;
  1326. }
  1327. }
  1328. } else {
  1329. c->use_mmx_vfilter= 1;
  1330. if (!(c->flags & SWS_FULL_CHR_H_INT)) {
  1331. switch (c->dstFormat) {
  1332. case AV_PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break;
  1333. case AV_PIX_FMT_BGR32: c->yuv2packedX = RENAME(yuv2bgr32_X); break;
  1334. #if HAVE_6REGS
  1335. case AV_PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break;
  1336. #endif
  1337. case AV_PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X); break;
  1338. case AV_PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X); break;
  1339. case AV_PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break;
  1340. default: break;
  1341. }
  1342. }
  1343. }
  1344. if (!(c->flags & SWS_FULL_CHR_H_INT)) {
  1345. switch (c->dstFormat) {
  1346. case AV_PIX_FMT_RGB32:
  1347. c->yuv2packed1 = RENAME(yuv2rgb32_1);
  1348. c->yuv2packed2 = RENAME(yuv2rgb32_2);
  1349. break;
  1350. case AV_PIX_FMT_BGR24:
  1351. c->yuv2packed1 = RENAME(yuv2bgr24_1);
  1352. c->yuv2packed2 = RENAME(yuv2bgr24_2);
  1353. break;
  1354. case AV_PIX_FMT_RGB555:
  1355. c->yuv2packed1 = RENAME(yuv2rgb555_1);
  1356. c->yuv2packed2 = RENAME(yuv2rgb555_2);
  1357. break;
  1358. case AV_PIX_FMT_RGB565:
  1359. c->yuv2packed1 = RENAME(yuv2rgb565_1);
  1360. c->yuv2packed2 = RENAME(yuv2rgb565_2);
  1361. break;
  1362. case AV_PIX_FMT_YUYV422:
  1363. c->yuv2packed1 = RENAME(yuv2yuyv422_1);
  1364. c->yuv2packed2 = RENAME(yuv2yuyv422_2);
  1365. break;
  1366. default:
  1367. break;
  1368. }
  1369. }
  1370. }
  1371. if (c->srcBpc == 8 && c->dstBpc <= 14) {
  1372. // Use the new MMX scaler if the MMXEXT one can't be used (it is faster than the x86 ASM one).
  1373. if (c->flags & SWS_FAST_BILINEAR && c->canMMXEXTBeUsed) {
  1374. c->hyscale_fast = ff_hyscale_fast_mmxext;
  1375. c->hcscale_fast = ff_hcscale_fast_mmxext;
  1376. } else {
  1377. c->hyscale_fast = NULL;
  1378. c->hcscale_fast = NULL;
  1379. }
  1380. }
  1381. }