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.

451 lines
16 KiB

  1. ;*************************************************************************
  2. ;** INTEL Corporation Proprietary Information
  3. ;**
  4. ;** This listing is supplied under the terms of a license
  5. ;** agreement with INTEL Corporation and may not be copied
  6. ;** nor disclosed except in accordance with the terms of
  7. ;** that agreement.
  8. ;**
  9. ;** Copyright (c) 1995 Intel Corporation.
  10. ;** All Rights Reserved.
  11. ;**
  12. ;*************************************************************************
  13. ;//
  14. ;// $Header: S:\h26x\src\dec\cx512242.asv
  15. ;//
  16. ;// $Log: S:\h26x\src\dec\cx512242.asv $
  17. ;//
  18. ;// Rev 1.8 20 Mar 1996 10:57:22 bnickers
  19. ;// Fix numerous bugs.
  20. ;//
  21. ;// Rev 1.7 19 Mar 1996 11:50:22 bnickers
  22. ;// Fix error regarding commitment of pages to stack.
  23. ;//
  24. ;// Rev 1.6 18 Mar 1996 09:58:36 bnickers
  25. ;// Make color convertors non-destructive.
  26. ;//
  27. ;// Rev 1.5 05 Feb 1996 13:35:36 BNICKERS
  28. ;// Fix RGB16 color flash problem, by allowing different RGB16 formats at oce.
  29. ;//
  30. ;// Rev 1.4 22 Dec 1995 15:42:18 KMILLS
  31. ;// added new copyright notice
  32. ;//
  33. ;// Rev 1.3 30 Oct 1995 17:15:32 BNICKERS
  34. ;// Fix color shift in RGB24 color convertors.
  35. ;//
  36. ;// Rev 1.2 26 Oct 1995 17:49:36 CZHU
  37. ;// Fix a whole bunch of bugs.
  38. ;//
  39. ;// Rev 1.1 26 Oct 1995 09:46:22 BNICKERS
  40. ;// Reduce the number of blanks in the "proc" statement because the assembler
  41. ;// sometimes has problems with statements longer than 512 characters long.
  42. ;//
  43. ;// Rev 1.0 25 Oct 1995 17:59:28 BNICKERS
  44. ;// Initial revision.
  45. ;//
  46. ;////////////////////////////////////////////////////////////////////////////
  47. ;
  48. ; +---------- Color convertor.
  49. ; |+--------- For both H261 and H263.
  50. ; ||+-------- Version for the Pentium(r) Microprocessor.
  51. ; |||++------ Convert from YUV12.
  52. ; |||||++---- Convert to RGB24.
  53. ; |||||||+--- Zoom by two.
  54. ; ||||||||
  55. ; cx512242 -- This function performs YUV12-to-RGB24 zoom-by-two color conversion
  56. ; for H26x. It is tuned for best performance on the Pentium(r)
  57. ; Microprocessor. It handles the format in which the low order
  58. ; byte is B, the second byte is G, and the high order byte is R.
  59. ;
  60. ; The YUV12 input is planar, 8 bits per pel. The Y plane may have
  61. ; a pitch of up to 768. It may have a width less than or equal
  62. ; to the pitch. It must be DWORD aligned, and preferably QWORD
  63. ; aligned. Pitch and Width must be a multiple of four. For best
  64. ; performance, Pitch should not be 4 more than a multiple of 32.
  65. ; Height may be any amount, but must be a multiple of two. The U
  66. ; and V planes may have a different pitch than the Y plane, subject
  67. ; to the same limitations.
  68. ;
  69. ; The color convertor is non-destructive; the input Y, U, and V
  70. ; planes will not be clobbered.
  71. OPTION PROLOGUE:None
  72. OPTION EPILOGUE:ReturnAndRelieveEpilogueMacro
  73. include locals.inc
  74. include ccinst.inc
  75. include decconst.inc
  76. .xlist
  77. include memmodel.inc
  78. .list
  79. .DATA
  80. ; any data would go here
  81. .CODE
  82. ASSUME cs : FLAT
  83. ASSUME ds : FLAT
  84. ASSUME es : FLAT
  85. ASSUME fs : FLAT
  86. ASSUME gs : FLAT
  87. ASSUME ss : FLAT
  88. ; void FAR ASM_CALLTYPE YUV12ToRGB24ZoomBy2 (U8 * YPlane,
  89. ; U8 * VPlane,
  90. ; U8 * UPlane,
  91. ; UN FrameWidth,
  92. ; UN FrameHeight,
  93. ; UN YPitch,
  94. ; UN VPitch,
  95. ; UN AspectAdjustmentCount,
  96. ; U8 FAR * ColorConvertedFrame,
  97. ; U32 DCIOffset,
  98. ; U32 CCOffsetToLine0,
  99. ; IN CCOPitch,
  100. ; IN CCType)
  101. ;
  102. ; CCOffsetToLine0 is relative to ColorConvertedFrame.
  103. ;
  104. PUBLIC YUV12ToRGB24ZoomBy2
  105. ; due to the need for the ebp reg, these parameter declarations aren't used,
  106. ; they are here so the assembler knows how many bytes to relieve from the stack
  107. YUV12ToRGB24ZoomBy2 proc DIST LANG AYPlane: DWORD,
  108. AVPlane: DWORD,
  109. AUPlane: DWORD,
  110. AFrameWidth: DWORD,
  111. AFrameHeight: DWORD,
  112. AYPitch: DWORD,
  113. AVPitch: DWORD,
  114. AAspectAdjustmentCnt: DWORD,
  115. AColorConvertedFrame: DWORD,
  116. ADCIOffset: DWORD,
  117. ACCOffsetToLine0: DWORD,
  118. ACCOPitch: DWORD,
  119. ACCType: DWORD
  120. LocalFrameSize = 64+768*8+32
  121. RegisterStorageSize = 16
  122. ; Arguments:
  123. YPlane_arg = RegisterStorageSize + 4
  124. VPlane_arg = RegisterStorageSize + 8
  125. UPlane_arg = RegisterStorageSize + 12
  126. FrameWidth_arg = RegisterStorageSize + 16
  127. FrameHeight = RegisterStorageSize + 20
  128. YPitch_arg = RegisterStorageSize + 24
  129. ChromaPitch_arg = RegisterStorageSize + 28
  130. AspectAdjustmentCount_arg = RegisterStorageSize + 32
  131. ColorConvertedFrame = RegisterStorageSize + 36
  132. DCIOffset = RegisterStorageSize + 40
  133. CCOffsetToLine0 = RegisterStorageSize + 44
  134. CCOPitch = RegisterStorageSize + 48
  135. CCType_arg = RegisterStorageSize + 52
  136. EndOfArgList = RegisterStorageSize + 56
  137. ; Locals (on local stack frame)
  138. CCOCursor EQU [esp+ 0]
  139. CCOSkipDistance EQU [esp+ 4]
  140. ChromaLineLen EQU [esp+ 8]
  141. YSkipDistance EQU [esp+12]
  142. YLimit EQU [esp+16]
  143. YCursor EQU [esp+20]
  144. VCursor EQU [esp+24]
  145. DistanceFromVToU EQU [esp+28]
  146. EndOfChromaLine EQU [esp+32]
  147. AspectCount EQU [esp+36]
  148. ChromaPitch EQU [esp+40]
  149. AspectAdjustmentCount EQU [esp+44]
  150. LineParity EQU [esp+48]
  151. LumaPitch EQU [esp+52]
  152. FrameWidth EQU [esp+56]
  153. StashESP EQU [esp+60]
  154. ChromaContribution EQU [esp+64]
  155. B0R0G0B0 EQU [esp+72]
  156. G1B1R0G0 EQU [esp+76]
  157. R1G1B1R1 EQU [esp+80]
  158. B2R2G2B2 EQU [esp+84]
  159. G3B3R2G2 EQU [esp+88]
  160. R3G3B3R3 EQU [esp+92]
  161. push esi
  162. push edi
  163. push ebp
  164. push ebx
  165. mov edi,esp
  166. sub esp,4096
  167. mov eax,[esp]
  168. sub esp,LocalFrameSize-4096
  169. and esp,0FFFFF000H
  170. mov eax,[esp]
  171. and esp,0FFFFE000H
  172. mov eax,[esp]
  173. sub esp,1000H
  174. mov eax,[esp]
  175. sub esp,1000H
  176. mov eax,[esp]
  177. add esp,2000H
  178. mov eax,[edi+YPitch_arg]
  179. mov ebx,[edi+ChromaPitch_arg]
  180. mov ecx,[edi+AspectAdjustmentCount_arg]
  181. mov edx,[edi+FrameWidth_arg]
  182. mov LumaPitch,eax
  183. mov ChromaPitch,ebx
  184. mov AspectAdjustmentCount,ecx
  185. mov AspectCount,ecx
  186. mov FrameWidth,edx
  187. mov ebx,[edi+VPlane_arg]
  188. mov ecx,[edi+UPlane_arg]
  189. mov eax,[edi+YPlane_arg]
  190. sub ecx,ebx
  191. mov DistanceFromVToU,ecx
  192. mov VCursor,ebx
  193. mov YCursor,eax
  194. mov eax,[edi+ColorConvertedFrame]
  195. add eax,[edi+DCIOffset]
  196. add eax,[edi+CCOffsetToLine0]
  197. mov CCOCursor,eax
  198. mov StashESP,edi
  199. mov edx,[edi+FrameHeight]
  200. mov ecx,LumaPitch
  201. imul edx,ecx
  202. mov ebx,FrameWidth
  203. mov eax,[edi+CCOPitch]
  204. sub ecx,ebx
  205. mov esi,YCursor ; Fetch cursor over luma plane.
  206. lea ebp,[ebx+ebx*4]
  207. add edx,esi
  208. add ebp,ebx
  209. mov YSkipDistance,ecx
  210. sub eax,ebp
  211. mov YLimit,edx
  212. shr ebx,1
  213. mov CCOSkipDistance,eax
  214. mov ChromaLineLen,ebx
  215. mov ecx,AspectAdjustmentCount
  216. mov esi,VCursor
  217. mov AspectCount,ecx
  218. ; Register Usage:
  219. ;
  220. ; edi -- Y Line cursor. Chroma contribs go in lines above current Y line.
  221. ; esi -- Chroma Line cursor.
  222. ; ebp -- Y Pitch
  223. ; edx -- Distance from V pel to U pel.
  224. ; ecx -- V contribution to RGB; sum of U and V contributions.
  225. ; ebx -- U contribution to RGB.
  226. ; eax -- Alternately a U and a V pel.
  227. PrepareChromaLine:
  228. mov edi,ChromaLineLen
  229. xor eax,eax
  230. mov edx,DistanceFromVToU
  231. mov al,[esi] ; Fetch V.
  232. add edi,esi ; Compute EOL address.
  233. xor ecx,ecx
  234. mov ebp,PD V24Contrib[eax*8] ; ebp[ 0: 7] -- Zero
  235. ; ; ebp[ 8:15] -- V contrib to G.
  236. ; ; ebp[16:23] -- V contrib to R.
  237. ; ; ebp[24:31] -- Zero.
  238. mov cl,[esi+edx] ; Fetch U.
  239. mov EndOfChromaLine,edi
  240. xor ebx,ebx ; Keep pairing happy.
  241. mov ebx,PD U24Contrib[ecx*8] ; ebx[ 0: 7] -- U contrib to B.
  242. ; ; ebx[ 8:15] -- U contrib to G.
  243. ; ; ebx[16:23] -- Zero.
  244. mov cl,[esi+edx+1] ; Fetch next U.
  245. lea edi,ChromaContribution
  246. add ebp,ebx ; Chroma contributions to RGB.
  247. NextChromaPel:
  248. mov ebx,PD U24Contrib[ecx*8] ; See above.
  249. mov al,[esi+1] ; Fetch V.
  250. mov [edi],ebp ; Store contribs to use for even chroma pel.
  251. mov cl,[esi+edx+2] ; Fetch next U.
  252. mov ebp,PD V24Contrib[eax*8] ; See above.
  253. add edi,32
  254. add ebp,ebx ; Chroma contributions to RGB.
  255. mov al,[esi+2] ; Fetch V.
  256. mov [edi-28],ebp ; Store contribs to use for odd chroma pel.
  257. mov ebx,PD U24Contrib[ecx*8] ; See above.
  258. mov ebp,PD V24Contrib[eax*8] ; See above.
  259. mov cl,[esi+edx+3] ; Fetch next U.
  260. add ebp,ebx ; Chroma contributions to RGB.
  261. add esi,2 ; Inc Chroma cursor.
  262. cmp esi,EndOfChromaLine
  263. jne NextChromaPel
  264. xor eax,eax
  265. mov esi,YCursor
  266. mov [edi+4],eax ; Store EOL indicator.
  267. mov LineParity,eax
  268. DoLine1:
  269. xor ebx,ebx
  270. xor ecx,ecx
  271. mov ebp,ChromaContribution ; Fetch preprocessed chroma contribs.
  272. xor edx,edx
  273. mov cl,[esi] ; Fetch Y0.
  274. mov bl,ChromaContribution+3 ; Fetch U contrib to B value.
  275. mov dl,ChromaContribution+2 ; Fetch UV contrib to G value.
  276. and ebp,0000001FFH ; Extract V contrib to R.
  277. mov edi,CCOCursor
  278. sub esp,6144
  279. xor eax,eax
  280. ; Register Usage:
  281. ;
  282. ; esi -- Cursor over a line of the Y Plane.
  283. ; edi -- Cursor over the color conv output.
  284. ; ebp -- V contribution to R field of RGB value.
  285. ; edx -- UV contrib to G field; U contrib to B field of RGB value.
  286. ; ecx -- Y value (i.e. Y contribution to R, G, and B);
  287. ; ebx -- Construction of one and a third pels of RGB24.
  288. ; eax -- Construction of one and a third pels of RGB24.
  289. Next4YPelsLine0:
  290. mov ah,PB B24Value[ecx+ebx*2] ; Fetch Pel0 B.
  291. mov bh,PB R24Value[ecx+ebp*1] ; Fetch Pel0 R.
  292. mov bl,PB G24Value[ecx+edx] ; Fetch Pel0 G. -- -- R0 G0
  293. mov cl,[esi+1] ; Fetch Y1.
  294. shl ebx,16 ; R0 G0 -- --
  295. mov al,ah ; Copy Pel0 B. -- -- B0 B0
  296. or eax,ebx ; R0 G0 B0 B0
  297. mov bh,PB G24Value[ecx+edx] ; Fetch Pel1 G. R0 G0 G1 --
  298. ror eax,8 ; First output: B0 R0 G0 B0
  299. mov dl,ChromaContribution+6144+3 ; Refetch U contrib to B value.
  300. mov Ze [edi],eax ; Save B0R0G0B0.
  301. mov bl,PB B24Value[ecx+edx*2] ; Fetch Pel1 B. R0 G0 G1 B1
  302. rol ebx,16 ; Second output: G1 B1 R0 G0
  303. mov B0R0G0B0+6144,eax ; Stash for saving to second line.
  304. mov Ze [edi+4],ebx ; Save G1B1R0G0.
  305. mov G1B1R0G0+6144,ebx ; Stash for saving to second line.
  306. mov bl,PB R24Value[ecx+ebp*1] ; Fetch Pel1 R. G1 B1 -- R1
  307. mov ebp,ChromaContribution+6144+4 ; Fetch preprocessed chroma contribs.
  308. mov bh,bl ; Copy Pel1 R. G1 B1 R1 R1
  309. mov cl,[esi+2] ; Fetch Y2.
  310. ror ebx,8 ; Third output: R1 G1 B1 R1
  311. and ebp,0000001FFH ; Extract V contrib to R.
  312. mov dl,ChromaContribution+6144+6 ; Fetch UV contrib to G value.
  313. xor eax,eax
  314. mov al,ChromaContribution+6144+7 ; Fetch U contrib to B value.
  315. mov R1G1B1R1+6144,ebx ; Stash for saving to second line.
  316. mov Ze [edi+8],ebx ; Save R1G1B1R1.
  317. xor ebx,ebx
  318. mov bh,PB B24Value[ecx+eax*2] ; Fetch Pel2 B.
  319. mov ah,PB R24Value[ecx+ebp*1] ; Fetch Pel2 R.
  320. mov al,PB G24Value[ecx+edx] ; Fetch Pel2 G. -- -- R2 G2
  321. mov cl,[esi+3] ; Fetch Y3.
  322. shl eax,16 ; R2 G2 -- --
  323. mov bl,bh ; Copy Pel2 B. -- -- B2 B2
  324. or ebx,eax ; R2 G2 B2 B2
  325. mov ah,PB G24Value[ecx+edx] ; Fetch Pel1 G. R2 G2 G3 --
  326. ror ebx,8 ; Fourth output: B2 R2 G2 B2
  327. mov dl,ChromaContribution+6144+7 ; Refetch U contrib to B value.
  328. mov Ze [edi+12],ebx ; Save B2R2G2B2.
  329. mov al,PB B24Value[ecx+edx*2] ; Fetch Pel3 B. R2 G2 G3 B3
  330. rol eax,16 ; Fifth output: G3 B3 R2 G2
  331. mov B2R2G2B2+6144,ebx ; Stash for saving to second line.
  332. mov Ze [edi+16],eax ; Save G3B3R2G2.
  333. mov G3B3R2G2+6144,eax ; Stash for saving to second line.
  334. mov al,PB R24Value[ecx+ebp*1] ; Fetch Pel3 R. G3 B3 -- R3
  335. mov ebp,ChromaContribution+6144+32; Fetch preprocessed chroma contribs.
  336. mov ah,al ; Copy Pel3 R. G3 B3 R3 R3
  337. mov cl,[esi+4] ; Fetch Y4.
  338. ror eax,8 ; Sixth output: R3 G3 B3 R3
  339. xor ebx,ebx
  340. mov dl,ChromaContribution+6144+34 ; Fetch UV contrib to G value.
  341. and ebp,0000001FFH ; Extract U contrib to B.
  342. mov bl,ChromaContribution+6144+35 ; Fetch U contrib to B value.
  343. lea esi,[esi+4] ; Advance input cursor.
  344. mov Ze [edi+20],eax ; Save R3G3B3R3.
  345. mov R3G3B3R3+6144,eax ; Stash for saving to second line.
  346. mov eax,ebx
  347. lea esp,[esp+32]
  348. lea edi,[edi+24] ; Advance output cursor.
  349. jne Next4YPelsLine0
  350. and esp,0FFFFE000H
  351. add esp,02000H
  352. mov ebx,CCOSkipDistance
  353. mov ebp,AspectCount
  354. add edi,ebx
  355. sub ebp,2 ; If count is non-zero, we keep the line.
  356. mov AspectCount,ebp
  357. lea ecx,B0R0G0B0
  358. mov eax,FrameWidth
  359. jg Keep2ndLineOfLine0
  360. add ebp,AspectAdjustmentCount
  361. mov AspectCount,ebp
  362. jmp Skip2ndLineOfLine0
  363. Keep2ndLineOfLine0:
  364. Keep2ndLineOfLine0_Loop:
  365. mov ebp,[ecx]
  366. sub eax,4
  367. mov Ze PD [edi],ebp
  368. mov ebp,[ecx+4]
  369. mov Ze PD [edi+4],ebp
  370. mov ebp,[ecx+8]
  371. mov Ze PD [edi+8],ebp
  372. mov ebp,[ecx+12]
  373. mov Ze PD [edi+12],ebp
  374. mov ebp,[ecx+16]
  375. mov Ze PD [edi+16],ebp
  376. mov ebp,[ecx+20]
  377. mov Ze PD [edi+20],ebp
  378. lea ecx,[ecx+32]
  379. lea edi,[edi+24]
  380. jne Keep2ndLineOfLine0_Loop
  381. add edi,ebx
  382. Skip2ndLineOfLine0:
  383. mov bl,LineParity
  384. add esi,YSkipDistance
  385. xor bl,1
  386. mov CCOCursor,edi
  387. mov YCursor,esi
  388. mov LineParity,bl
  389. jne DoLine1
  390. mov eax,esi
  391. mov esi,VCursor ; Inc VPlane cursor to next line.
  392. mov ebp,ChromaPitch
  393. mov ebx,YLimit ; Done with last line?
  394. add esi,ebp
  395. cmp eax,ebx
  396. mov VCursor,esi
  397. jb PrepareChromaLine
  398. Done:
  399. mov esp,StashESP
  400. pop ebx
  401. pop ebp
  402. pop edi
  403. pop esi
  404. rturn
  405. YUV12ToRGB24ZoomBy2 endp
  406. END