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

299 lines
13 KiB

  1. OPTION PROLOGUE: None
  2. OPTION EPILOGUE: ReturnAndRelieveEpilogueMacro
  3. .xlist
  4. include memmodel.inc
  5. .list
  6. .DATA
  7. ; any data would go here
  8. .CODE
  9. ASSUME cs: FLAT
  10. ASSUME ds: FLAT
  11. ASSUME es: FLAT
  12. ASSUME fs: FLAT
  13. ASSUME gs: FLAT
  14. ASSUME ss: FLAT
  15. PUBLIC YUV12ToYUY2
  16. YUV12ToYUY2 proc DIST LANG AuYPlane: DWORD,
  17. AuVPlane: DWORD,
  18. AuUPlane: DWORD,
  19. AuWidth: DWORD,
  20. AuHeight: DWORD,
  21. AuYPitch: DWORD,
  22. AUVPitch: DWORD,
  23. AbShapingFlag: DWORD,
  24. AuCCOutputBuffer: DWORD,
  25. AlOutput: DWORD,
  26. AuOffsetToLine0: DWORD,
  27. AintPitch: DWORD,
  28. ACCType: DWORD
  29. LocalFrameSize = 52
  30. RegisterStorageSize = 16 ; 4 registers pushed
  31. ; Argument offsets (after register pushed)
  32. uYPlane = LocalFrameSize + RegisterStorageSize + 4
  33. uVPlane = LocalFrameSize + RegisterStorageSize + 8
  34. uUPlane = LocalFrameSize + RegisterStorageSize + 12
  35. uWidth = LocalFrameSize + RegisterStorageSize + 16
  36. uHeight = LocalFrameSize + RegisterStorageSize + 20
  37. uYPitch = LocalFrameSize + RegisterStorageSize + 24
  38. uUVPitch = LocalFrameSize + RegisterStorageSize + 28
  39. bShapingFlag = LocalFrameSize + RegisterStorageSize + 32
  40. uCCOutputBuffer = LocalFrameSize + RegisterStorageSize + 36
  41. lOutput = LocalFrameSize + RegisterStorageSize + 40
  42. uOffsetToLine0 = LocalFrameSize + RegisterStorageSize + 44
  43. intPitch = LocalFrameSize + RegisterStorageSize + 48
  44. CCType = LocalFrameSize + RegisterStorageSize + 52
  45. ; Local offsets (after register pushes)
  46. ASMTMP1 = 48 ; 13
  47. Y = 44 ; 12
  48. U = 40 ; 11
  49. V = 36 ; 10
  50. Outt = 32 ; 9
  51. YTemp = 28 ; 8
  52. UTemp = 24 ; 7
  53. VTemp = 20 ; 6
  54. ASMTMP2 = 16 ; 5
  55. Col = 12 ; 4
  56. OutTemp = 8 ; 3
  57. VAL = 4 ; 2
  58. LineCount = 0 ; 1
  59. ; Arguments relative to esp
  60. _uYPlane EQU [esp + uYPlane]
  61. _uVPlane EQU [esp + uVPlane]
  62. _UUPlane EQU [esp + uUPlane]
  63. _uWidth EQU [esp + uWidth ]
  64. _uHeight EQU [esp + uHeight]
  65. _uYPitch EQU [esp + uYPitch]
  66. _uUVPitch EQU [esp + uUVPitch]
  67. _bShapingFlag EQU [esp + bShapingFlag]
  68. _uCCOutputBuffer EQU [esp + uCCOutputBuffer]
  69. _lOutput EQU [esp + lOutput]
  70. _uOffsetToLine0 EQU [esp + uOffsetToLine0]
  71. _intPitch EQU [esp + intPitch]
  72. _uCCType EQU [esp + CCType]
  73. ; Locals relative to esp
  74. _ASMTMP1 EQU [esp + ASMTMP1]
  75. _Y EQU [esp + Y]
  76. _U EQU [esp + U]
  77. _V EQU [esp + V]
  78. _Out EQU [esp + Outt]
  79. _YTemp EQU [esp + YTemp]
  80. _UTemp EQU [esp + UTemp]
  81. _VTemp EQU [esp + VTemp]
  82. _ASMTMP2 EQU [esp + ASMTMP2]
  83. _Col EQU [esp + Col]
  84. _OutTemp EQU [esp + OutTemp]
  85. _VAL EQU [esp + VAL]
  86. _LineCount EQU [esp + LineCount]
  87. ; Save registers and start working
  88. push ebx
  89. push esi
  90. push edi
  91. push ebp
  92. sub esp, LocalFrameSize
  93. mov eax, DWORD PTR _bShapingFlag ; eax = bShapingFlag
  94. mov ecx, DWORD PTR _uYPlane ; ecx = uYPlane
  95. dec eax ; eax = bShapingFlag - 1
  96. mov edx, DWORD PTR _uUPlane ; edx = uUPlane
  97. mov DWORD PTR _LineCount, eax ; eax = FREE, LineCount
  98. mov DWORD PTR _Y, ecx ; ecx = FREE, Y
  99. mov eax, DWORD PTR _uVPlane ; eax = uVPlane
  100. mov ecx, DWORD PTR _uOffsetToLine0 ; ecx = uOffsetToLine0
  101. mov DWORD PTR _U, edx ; edx = FREE, U
  102. add ecx, DWORD PTR _lOutput ; ecx = uOffsetToLine0 +
  103. mov DWORD PTR _V, eax ; eax = FREE, V
  104. mov eax, DWORD PTR _uCCOutputBuffer ; eax = uCCOutputBuffer
  105. add eax, ecx ; eax = uCCOutputBuffer +
  106. ; uOffsetToLine0 +
  107. ; lOutput
  108. ; ecx = FREE
  109. mov DWORD PTR _Out, eax ; eax = FREE, Out
  110. mov eax, DWORD PTR _uHeight ; eax = uHeight
  111. sar eax, 1 ; eax = uHeight/2
  112. mov DWORD PTR _ASMTMP2, eax ; eax = FREE, Row ready to
  113. ; count down
  114. RowLoop:; L27704 outer loop over all rows
  115. mov ecx, DWORD PTR _Y ; ecx = Y: ecx EQU YTemp
  116. mov edi, DWORD PTR _U ; edi = U: edi EQU UTemp
  117. mov ebp, DWORD PTR _V ; ebp = V: ebp EQU VTemp
  118. mov esi, DWORD PTR _Out ; esi = OutTemp
  119. mov eax, DWORD PTR _LineCount ; eax = LineCount
  120. test eax, eax ; is LineCount == 0? eax = FREE
  121. je SHORT SkipEvenRow ; L27708 loop if so, skip the even loop
  122. mov eax, DWORD PTR _uWidth ; eax = uWidth
  123. sar eax, 2 ; eax = uWidth/4 ** assume uWidth/4 != 0
  124. EvenRowPels:; L27709 loop over columns in even row - two YUY2 pels at a time.
  125. mov bl, BYTE PTR [ecx+1] ; bl = *(YTemp + 1)
  126. add ecx, 2 ; YTemp += 2
  127. mov bh, BYTE PTR [ebp] ; bh = *VTemp
  128. add esi, 4 ; DWORD *OutTemp++;
  129. shl ebx, 16 ; move VY2 to high word in ebx
  130. inc ebp ; VTemp++
  131. mov bh, BYTE PTR [edi] ; bh = *UTemp
  132. inc edi ; UTemp++;
  133. mov bl, BYTE PTR [ecx-2] ; bl = *YTemp BANK CONFLICT HERE !!!
  134. mov dl, BYTE PTR [ecx+1] ; dl = *(YTemp + 1) BANK CONFLICT HERE !!!
  135. mov DWORD PTR [esi-4], ebx ; store VAL in the right place
  136. add ecx, 2 ; YTemp += 2
  137. mov dh, BYTE PTR [ebp] ; dh = *VTemp
  138. add esi, 4 ; DWORD *OutTemp++;
  139. shl edx, 16 ; move VY2 to high word in ebx
  140. inc ebp ; VTemp++
  141. mov dh, BYTE PTR [edi] ; bh = *UTemp
  142. inc edi ; UTemp++;
  143. mov dl, BYTE PTR [ecx-2] ; bl = *YTemp
  144. dec eax ; loop counter decrement
  145. mov DWORD PTR [esi-4], edx ; store VAL in the right place
  146. jne SHORT EvenRowPels ; L27709 loop done ? if not, go
  147. ; around once again.
  148. mov eax, DWORD PTR _LineCount ; eax = LineCount
  149. jmp SHORT UpdatePointers ; L27770
  150. SkipEvenRow:; L27708
  151. mov eax, DWORD PTR _bShapingFlag ; eax = bShapingFlag
  152. mov edx, DWORD PTR _Out ; edx = Out
  153. mov ebx, DWORD PTR _intPitch ; edx = intPitch
  154. sub edx, ebx ; edx = Out - intPitch
  155. mov DWORD PTR _Out, edx ; save Out
  156. UpdatePointers: ; L27770
  157. mov ecx, DWORD PTR _Y ; ecx = Y
  158. dec eax ; eax = LineCount-1 OR bShapingFlag - 1
  159. mov edx, DWORD PTR _intPitch ; edx = intPitch
  160. mov esi, DWORD PTR _Out ; esi = Out
  161. mov DWORD PTR _LineCount, eax ; store decremented linecount
  162. ; eax = FREE
  163. add esi, edx ; (esi) Out += intPitch ***
  164. mov eax, DWORD PTR _uYPitch ; eax = uYPitch
  165. mov edi, DWORD PTR _U ; edi = U ***
  166. add ecx, eax ; (ecx) Y += uYPitch ***
  167. mov ebp, DWORD PTR _V ; ebp = V ***
  168. mov DWORD PTR _Y, ecx ; store updated Y
  169. mov DWORD PTR _Out, esi ; store Out
  170. mov eax, DWORD PTR _LineCount ; eax = LineCount
  171. test eax, eax ; is LineCount == 0?
  172. ; if so, ignore the odd
  173. ; row loop over columns
  174. je SHORT SkipOddRow ; L27714
  175. mov eax, DWORD PTR _uWidth ; eax = uWidth
  176. sar eax, 2 ; eax = uWidth/4
  177. OddRowPels: ;L27715 loop over columns of odd rows
  178. mov bl, BYTE PTR [ecx+1] ; bl = *(YTemp + 1)
  179. add ecx, 2 ; YTemp += 2
  180. mov bh, BYTE PTR [ebp] ; bh = *VTemp
  181. add esi, 4 ; DWORD *OutTemp++;
  182. shl ebx, 16 ; move VY2 to high word in ebx
  183. inc ebp ; VTemp++
  184. mov bh, BYTE PTR [edi] ; bh = *UTemp
  185. inc edi ; UTemp++;
  186. mov bl, BYTE PTR [ecx-2] ; bl = *YTemp BANK CONFLICT HERE !!!
  187. mov dl, BYTE PTR [ecx+1] ; dl = *(YTemp + 1) BANK CONFLICT HERE !!!
  188. mov DWORD PTR [esi-4], ebx ; store VAL in the right place
  189. add ecx, 2 ; YTemp += 2
  190. mov dh, BYTE PTR [ebp] ; dh = *VTemp
  191. add esi, 4 ; DWORD *OutTemp++;
  192. shl edx, 16 ; move VY2 to high word in ebx
  193. inc ebp ; VTemp++
  194. mov dh, BYTE PTR [edi] ; bh = *UTemp
  195. inc edi ; UTemp++;
  196. mov dl, BYTE PTR [ecx-2] ; bl = *YTemp
  197. dec eax ; loop counter decrement
  198. mov DWORD PTR [esi-4], edx ; store VAL in the right place
  199. jne SHORT OddRowPels ; L27715 loop done ? if not, go
  200. ; around once again.
  201. mov eax, DWORD PTR _LineCount ; eax = LineCount
  202. jmp SHORT UpdateAllPointers ; L27771
  203. SkipOddRow: ;L27714
  204. mov eax, DWORD PTR _bShapingFlag ; eax = bShapingFlag
  205. mov edx, DWORD PTR _Out ; edx = Out
  206. mov ebx, DWORD PTR _intPitch ; edx = intPitch
  207. sub edx, ebx ; edx = Out - intPitch
  208. mov DWORD PTR _Out, edx ; save Out
  209. UpdateAllPointers: ; L27771 update pointers
  210. dec eax ; eax = LineCount-1 OR bShapingFlag - 1
  211. mov ecx, DWORD PTR _Y ; ecx = Y
  212. mov edx, DWORD PTR _intPitch ; edx = intPitch
  213. mov ebx, DWORD PTR _Out ; ebx = Out
  214. add ebx, edx ; ebx = Out + intPitch
  215. mov ebp, DWORD PTR _ASMTMP2 ; ebp = row loop counter
  216. mov DWORD PTR _LineCount, eax ; store updated LineCount
  217. mov DWORD PTR _Out, ebx ; store updated Out
  218. mov edx, DWORD PTR _uUVPitch ; edx = uUVPitch
  219. mov eax, DWORD PTR _U ; eax = U
  220. mov esi, DWORD PTR _V ; esi = V
  221. add eax, edx ; eax = U + uUVPitch
  222. add esi, edx ; esi = V + uUVPitch
  223. mov DWORD PTR _U, eax ; store updated U
  224. mov DWORD PTR _V, esi ; store updated V
  225. add ecx, DWORD PTR _uYPitch ; ecx = Y + uYPitch
  226. dec ebp ; decrement loop counter
  227. mov DWORD PTR _Y, ecx ; store updated Y
  228. mov DWORD PTR _ASMTMP2, ebp ; store updated loop counter
  229. jne RowLoop ; back to L27704 row loop
  230. CleanUp:
  231. add esp, LocalFrameSize ; restore esp to registers
  232. pop ebp
  233. pop edi
  234. pop esi
  235. pop ebx
  236. ret 52 ; 13*4 bytes of arguments
  237. YUV12ToYUY2 ENDP
  238. END