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.

518 lines
17 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\cx51282.asv
  15. ;//
  16. ;// $Log: S:\h26x\src\dec\cx51282.asv $
  17. ;//
  18. ;// Rev 1.6 18 Mar 1996 09:58:42 bnickers
  19. ;// Make color convertors non-destructive.
  20. ;//
  21. ;// Rev 1.5 05 Feb 1996 13:35:38 BNICKERS
  22. ;// Fix RGB16 color flash problem, by allowing different RGB16 formats at oce.
  23. ;//
  24. ;// Rev 1.4 16 Jan 1996 11:23:08 BNICKERS
  25. ;// Fix starting point in output stream, so we don't start at line two and
  26. ;// write off the end of the output frame.
  27. ;//
  28. ;// Rev 1.3 22 Dec 1995 15:53:50 KMILLS
  29. ;// added new copyright notice
  30. ;//
  31. ;// Rev 1.2 03 Nov 1995 14:39:42 BNICKERS
  32. ;// Support YUV12 to CLUT8 zoom by 2.
  33. ;//
  34. ;// Rev 1.1 26 Oct 1995 09:46:10 BNICKERS
  35. ;// Reduce the number of blanks in the "proc" statement because the assembler
  36. ;// sometimes has problems with statements longer than 512 characters long.
  37. ;//
  38. ;// Rev 1.0 25 Oct 1995 17:59:22 BNICKERS
  39. ;// Initial revision.
  40. ;//
  41. ;////////////////////////////////////////////////////////////////////////////
  42. ; +---------- Color convertor.
  43. ; |+--------- For both H261 and H263.
  44. ; ||+-------- Version for the Pentium Microprocessor.
  45. ; |||++------ Convert from YUV12.
  46. ; |||||+----- Convert to CLUT8.
  47. ; ||||||+---- Zoom by two.
  48. ; |||||||
  49. ; cx51282 -- This function performs YUV12 to CLUT8 zoom-by-2 color conversion
  50. ; for H26x. It is tuned for best performance on the Pentium(r)
  51. ; Microprocessor. It dithers among 9 chroma points and 26 luma
  52. ; points, mapping the 8 bit luma pels into the 26 luma points by
  53. ; clamping the ends and stepping the luma by 8.
  54. ;
  55. ; The color convertor is non-destructive; the input Y, U, and V
  56. ; planes will not be clobbered.
  57. OPTION PROLOGUE:None
  58. OPTION EPILOGUE:ReturnAndRelieveEpilogueMacro
  59. include locals.inc
  60. include ccinst.inc
  61. include decconst.inc
  62. .xlist
  63. include memmodel.inc
  64. .list
  65. .DATA
  66. ; any data would go here
  67. .CODE
  68. ASSUME cs : FLAT
  69. ASSUME ds : FLAT
  70. ASSUME es : FLAT
  71. ASSUME fs : FLAT
  72. ASSUME gs : FLAT
  73. ASSUME ss : FLAT
  74. ; void FAR ASM_CALLTYPE YUV12ToCLUT8ZoomBy2 (U8 * YPlane,
  75. ; U8 * VPlane,
  76. ; U8 * UPlane,
  77. ; UN FrameWidth,
  78. ; UN FrameHeight,
  79. ; UN YPitch,
  80. ; UN VPitch,
  81. ; UN AspectAdjustmentCount,
  82. ; U8 * ColorConvertedFrame,
  83. ; U32 DCIOffset,
  84. ; U32 CCOffsetToLine0,
  85. ; IN CCOPitch,
  86. ; IN CCType)
  87. ;
  88. ; CCOffsetToLine0 is relative to ColorConvertedFrame.
  89. ;
  90. PUBLIC YUV12ToCLUT8ZoomBy2
  91. ; due to the need for the ebp reg, these parameter declarations aren't used,
  92. ; they are here so the assembler knows how many bytes to relieve from the stack
  93. YUV12ToCLUT8ZoomBy2 proc DIST LANG AYPlane: DWORD,
  94. AVPlane: DWORD,
  95. AUPlane: DWORD,
  96. AFrameWidth: DWORD,
  97. AFrameHeight: DWORD,
  98. AYPitch: DWORD,
  99. AVPitch: DWORD,
  100. AAspectAdjustmentCnt: DWORD,
  101. AColorConvertedFrame: DWORD,
  102. ADCIOffset: DWORD,
  103. ACCOffsetToLine0: DWORD,
  104. ACCOPitch: DWORD,
  105. ACCType: DWORD
  106. LocalFrameSize = 64+768*2+4
  107. RegisterStorageSize = 16
  108. ; Arguments:
  109. YPlane_arg = RegisterStorageSize + 4
  110. VPlane_arg = RegisterStorageSize + 8
  111. UPlane_arg = RegisterStorageSize + 12
  112. FrameWidth_arg = RegisterStorageSize + 16
  113. FrameHeight = RegisterStorageSize + 20
  114. YPitch_arg = RegisterStorageSize + 24
  115. ChromaPitch_arg = RegisterStorageSize + 28
  116. AspectAdjustmentCount_arg = RegisterStorageSize + 32
  117. ColorConvertedFrame = RegisterStorageSize + 36
  118. DCIOffset = RegisterStorageSize + 40
  119. CCOffsetToLine0 = RegisterStorageSize + 44
  120. CCOPitch_arg = RegisterStorageSize + 48
  121. CCType_arg = RegisterStorageSize + 52
  122. EndOfArgList = RegisterStorageSize + 56
  123. ; Locals (on local stack frame)
  124. CCOCursor EQU [esp+ 0]
  125. ChromaLineLen EQU [esp+ 4]
  126. YLimit EQU [esp+ 8]
  127. YCursor EQU [esp+12]
  128. VCursor EQU [esp+16]
  129. DistanceFromVToU EQU [esp+20]
  130. EndOfChromaLine EQU [esp+24]
  131. AspectCount EQU [esp+28]
  132. FrameWidth EQU [esp+32]
  133. ChromaPitch EQU [esp+36]
  134. AspectAdjustmentCount EQU [esp+40]
  135. LumaPitch EQU [esp+44]
  136. CCOPitch EQU [esp+48]
  137. StashESP EQU [esp+52]
  138. ChromaContribution EQU [esp+64]
  139. push esi
  140. push edi
  141. push ebp
  142. push ebx
  143. mov edi,esp
  144. sub esp,LocalFrameSize
  145. and esp,0FFFFF800H
  146. mov eax,[edi+FrameWidth_arg]
  147. mov ebx,[edi+ChromaPitch_arg]
  148. mov ecx,[edi+AspectAdjustmentCount_arg]
  149. mov edx,[edi+YPitch_arg]
  150. mov esi,[edi+CCOPitch_arg]
  151. mov FrameWidth,eax
  152. mov ChromaPitch,ebx
  153. mov AspectAdjustmentCount,ecx
  154. mov AspectCount,ecx
  155. mov LumaPitch,edx
  156. mov CCOPitch,esi
  157. mov ebx,[edi+VPlane_arg]
  158. mov ecx,[edi+UPlane_arg]
  159. mov eax,[edi+YPlane_arg]
  160. sub ecx,ebx
  161. mov DistanceFromVToU,ecx
  162. mov VCursor,ebx
  163. mov YCursor,eax
  164. mov eax,[edi+ColorConvertedFrame]
  165. add eax,[edi+DCIOffset]
  166. add eax,[edi+CCOffsetToLine0]
  167. mov CCOCursor,eax
  168. mov StashESP,edi
  169. mov edx,[edi+FrameHeight]
  170. mov ecx,LumaPitch
  171. imul edx,ecx
  172. mov ebx,FrameWidth
  173. mov esi,YCursor ; Fetch cursor over luma plane.
  174. sar ebx,1
  175. add edx,esi
  176. mov ChromaLineLen,ebx
  177. mov YLimit,edx
  178. NextTwoLines:
  179. ; Convert line of U and V pels to the corresponding UVDitherPattern Indices.
  180. ;
  181. ; Register Usage
  182. ;
  183. ; edi -- Cursor over V line
  184. ; esi -- Cursor over storage to hold preprocessed UV.
  185. ; ebp -- Distance from V line to U line.
  186. ; edx -- UVDitherPattern index: ((V:{0:8}*9) + U:{0:8}) * 2 + 1
  187. ; bl -- U pel value
  188. ; cl -- V pel value
  189. ; eax -- Scratch
  190. mov edi,VCursor ; Fetch address of pel 0 of next line of V.
  191. mov ebp,DistanceFromVToU ; Fetch span from V plane to U plane.
  192. lea esi,ChromaContribution
  193. mov eax,ChromaLineLen
  194. mov edx,ChromaPitch
  195. add eax,edi
  196. mov EndOfChromaLine,eax
  197. add edx,edi
  198. mov bl,[edi] ; Fetch first V pel.
  199. ;
  200. and ebx,0FCH ; Reduce to 6 bits.
  201. mov cl,[edi+ebp*1] ; Fetch first U pel.
  202. and ecx,0FCH ; Reduce to 6 bits.
  203. mov VCursor,edx ; Stash for next time around.
  204. @@:
  205. mov edx,PD UVDitherLine01[ebx] ; Fetch dither pattern for V point.
  206. mov bl,[edi+1] ; Fetch next V pel.
  207. mov eax,PD UVDitherLine23[ecx] ; Fetch dither pattern for U point.
  208. mov cl,[edi+ebp*1+1] ; Fetch next U pel.
  209. lea edx,[edx+edx*2+00A0A0A0AH] ; Weight V dither pattern.
  210. and bl,0FCH ; Reduce to 6 bits.
  211. add eax,edx ; Combine dither patterns for U and V.
  212. and cl,0FCH ; Reduce to 6 bits.
  213. mov edx,PD UVDitherLine01[ebx] ; Fetch dither pattern for V point.
  214. mov [esi],eax ; Stash UV corresponding to Y00,Y01,Y10,Y11.
  215. mov eax,PD UVDitherLine23[ecx] ; Fetch dither pattern for U point.
  216. mov bl,[edi+2] ; Fetch next V pel.
  217. lea edx,[edx+edx*2+00A0A0A0AH] ; Weight V dither pattern.
  218. mov cl,[edi+ebp*1+2] ; Fetch next U pel.
  219. add eax,edx ; Combine dither patterns for U and V.
  220. mov edx,EndOfChromaLine ; Fetch EOL address.
  221. mov [esi+4],eax ; Stash UV corresponding to Y02,Y03,Y12,Y13.
  222. add edi,2 ; Advance U plane cursor.
  223. and bl,0FCH ; Reduce to 6 bits.
  224. and cl,0FCH ; Reduce to 6 bits.
  225. add esi,8
  226. sub edx,edi
  227. jne @b
  228. ; Now color convert a line of luma.
  229. ;
  230. ; Register Usage
  231. ; edi -- Cursor over line of color converted output frame, minus esi.
  232. ; esi -- Cursor over Y line.
  233. ; ebp -- Not used.
  234. ; edx,eax -- Build output pels.
  235. ; ecx,ebx -- Y pels.
  236. mov [esi],edx ; Stash EOL indication.
  237. mov esi,YCursor ; Reload cursor over Y line.
  238. mov edi,CCOCursor ; Fetch output cursor.
  239. mov eax,CCOPitch ; Compute start of next line.
  240. mov bl,[esi+1] ; Fetch Y01.
  241. add eax,edi
  242. mov cl,[esi] ; Fetch Y00.
  243. mov CCOCursor,eax ; Stash start of next line.
  244. mov edx,PD YDitherZ2[ebx*4] ; Fetch < Y01 Y01 Y01 Y01>.
  245. sub edi,esi ; Get span from Y cursor to CCO cursor.
  246. and edx,0FFFF0000H ; Extract < Y01 Y01 ___ ___>.
  247. sub edi,esi
  248. mov eax,PD YDitherZ2[ecx*4] ; Fetch < Y00 Y00 Y00 Y00>.
  249. mov bl,[esi+3] ; Fetch Y03.
  250. and eax,00000FFFFH ; Extract < ___ ___ Y00 Y00>.
  251. mov cl,[esi+2] ; Fetch Y02.
  252. or eax,edx ; < Y01 Y01 Y00 Y00>.
  253. mov edx,ChromaContribution ; Fetch <UV01 UV01 UV00 UV00>.
  254. sub esp,1536
  255. Line0Loop:
  256. add eax,edx ; < P01 P01 P00 P00>.
  257. mov edx,PD YDitherZ2[ebx*4] ; Fetch < Y03 Y03 Y03 Y03>.
  258. mov Ze [edi+esi*2],eax ; Store four pels to color conv output.
  259. add esi,4 ; Advance cursor.
  260. and edx,0FFFF0000H ; Extract < Y03 Y03 ___ ___>.
  261. mov eax,PD YDitherZ2[ecx*4] ; Fetch < Y02 Y02 Y02 Y02>.
  262. and eax,00000FFFFH ; Extract < ___ ___ Y02 Y02>.
  263. mov bl,[esi+1] ; Fetch next Y01.
  264. or eax,edx ; < Y03 Y03 Y02 Y02>.
  265. mov edx,ChromaContribution+1536+4 ; Fetch <UV03 UV03 UV02 UV02>.
  266. add eax,edx ; < P03 P03 P02 P02>.
  267. mov cl,[esi] ; Fetch next Y00.
  268. mov Ze [edi+esi*2+4-8],eax ; Store four pels to color conv output.
  269. mov edx,PD YDitherZ2[ebx*4] ; Fetch < Y01 Y01 Y01 Y01>.
  270. and edx,0FFFF0000H ; Extract < Y01 Y01 ___ ___>.
  271. mov eax,PD YDitherZ2[ecx*4] ; Fetch < Y00 Y00 Y00 Y00>.
  272. and eax,00000FFFFH ; Extract < ___ ___ Y00 Y00>.
  273. mov bl,[esi+3] ; Fetch Y03.
  274. or eax,edx ; < Y01 Y01 Y00 Y00>.
  275. mov edx,ChromaContribution+1536+8 ; Fetch <UV01 UV01 UV00 UV00>.
  276. add esp,8
  277. mov cl,[esi+2] ; Fetch Y02.
  278. test edx,edx
  279. jne Line0Loop
  280. and esp,0FFFFF800H
  281. add esp,0800H
  282. ; Color convert same input line, dithering differently.
  283. mov edx,AspectCount
  284. mov edi,CCOCursor ; Fetch output cursor.
  285. sub edx,2
  286. mov eax,CCOPitch ; Compute start of next line.
  287. mov AspectCount,edx
  288. mov esi,YCursor ; Reload cursor over Y line.
  289. mov ebp,AspectAdjustmentCount
  290. jg KeepLine1
  291. add edx,ebp
  292. mov AspectCount,edx
  293. jmp SkipLine1
  294. KeepLine1:
  295. mov bl,[esi+1] ; Fetch Y01.
  296. add eax,edi
  297. mov cl,[esi] ; Fetch Y00.
  298. mov CCOCursor,eax ; Stash start of next line.
  299. mov edx,PD YDitherZ2[ebx*4] ; Fetch < Y01 Y01 Y01 Y01>.
  300. sub edi,esi ; Get span from Y cursor to CCO cursor.
  301. shl edx,16 ; Extract < Y01 Y01 ___ ___>.
  302. sub edi,esi
  303. mov eax,PD YDitherZ2[ecx*4] ; Fetch < Y00 Y00 Y00 Y00>.
  304. mov bl,[esi+3] ; Fetch Y03.
  305. shr eax,16 ; Extract < ___ ___ Y00 Y00>.
  306. mov cl,[esi+2] ; Fetch Y02.
  307. or eax,edx ; < Y01 Y01 Y00 Y00>.
  308. mov edx,ChromaContribution ; Fetch <UV01 UV01 UV00 UV00>.
  309. rol edx,16 ; Swap dither pattern.
  310. sub esp,1536
  311. Line1Loop:
  312. add eax,edx ; < P01 P01 P00 P00>.
  313. mov edx,PD YDitherZ2[ebx*4] ; Fetch < Y03 Y03 Y03 Y03>.
  314. mov Ze [edi+esi*2],eax ; Store four pels to color conv output.
  315. add esi,4 ; Advance cursor.
  316. shl edx,16 ; Extract < Y03 Y03 ___ ___>.
  317. mov eax,PD YDitherZ2[ecx*4] ; Fetch < Y02 Y02 Y02 Y02>.
  318. shr eax,16 ; Extract < ___ ___ Y02 Y02>.
  319. mov bl,[esi+1] ; Fetch next Y01.
  320. or eax,edx ; < Y03 Y03 Y02 Y02>.
  321. mov edx,ChromaContribution+1536+4 ; Fetch <UV03 UV03 UV02 UV02>.
  322. rol edx,16 ; Swap dither pattern.
  323. add esp,8
  324. add eax,edx ; < P03 P03 P02 P02>.
  325. mov cl,[esi] ; Fetch next Y00.
  326. mov Ze [edi+esi*2+4-8],eax ; Store four pels to color conv output.
  327. mov edx,PD YDitherZ2[ebx*4] ; Fetch < Y01 Y01 Y01 Y01>.
  328. shl edx,16 ; Extract < Y01 Y01 ___ ___>.
  329. mov eax,PD YDitherZ2[ecx*4] ; Fetch < Y00 Y00 Y00 Y00>.
  330. shr eax,16 ; Extract < ___ ___ Y00 Y00>.
  331. mov bl,[esi+3] ; Fetch Y03.
  332. or eax,edx ; < Y01 Y01 Y00 Y00>.
  333. mov edx,ChromaContribution+1536 ; Fetch <UV01 UV01 UV00 UV00>.
  334. rol edx,16 ; Swap dither pattern.
  335. mov cl,[esi+2] ; Fetch Y02.
  336. test edx,edx
  337. jne Line1Loop
  338. and esp,0FFFFF800H
  339. add esp,0800H
  340. SkipLine1:
  341. ; Now color convert the second input line of luma.
  342. mov esi,YCursor
  343. mov ebp,LumaPitch
  344. mov edi,CCOCursor
  345. mov eax,CCOPitch
  346. mov bl,[esi+ebp*1]
  347. add eax,edi
  348. mov cl,[esi+ebp*1+1]
  349. mov CCOCursor,eax
  350. mov edx,PD YDitherZ2[ebx*4]
  351. sub edi,esi
  352. shl edx,16
  353. sub edi,esi
  354. mov eax,PD YDitherZ2[ecx*4]
  355. mov bl,[esi+ebp*1+2]
  356. shr eax,16
  357. mov cl,[esi+ebp*1+3]
  358. or eax,edx
  359. mov edx,ChromaContribution
  360. rol edx,16
  361. sub esp,1536
  362. Line2Loop:
  363. add eax,edx
  364. mov edx,PD YDitherZ2[ebx*4]
  365. bswap eax
  366. mov Ze [edi+esi*2],eax
  367. add esi,4
  368. shl edx,16
  369. mov eax,PD YDitherZ2[ecx*4]
  370. shr eax,16
  371. mov bl,[esi+ebp*1]
  372. or eax,edx
  373. mov edx,ChromaContribution+1536+4
  374. rol edx,16
  375. add esp,8
  376. add eax,edx
  377. mov cl,[esi+ebp*1+1]
  378. bswap eax
  379. mov Ze [edi+esi*2+4-8],eax
  380. mov edx,PD YDitherZ2[ebx*4]
  381. shl edx,16
  382. mov eax,PD YDitherZ2[ecx*4]
  383. shr eax,16
  384. mov bl,[esi+ebp*1+2]
  385. or eax,edx
  386. mov edx,ChromaContribution+1536
  387. rol edx,16
  388. mov cl,[esi+ebp*1+3]
  389. test edx,edx
  390. jne Line2Loop
  391. and esp,0FFFFF800H
  392. add esp,0800H
  393. ; Color convert same input line, dithering differently.
  394. mov esi,YCursor
  395. mov edx,AspectCount
  396. mov edi,CCOCursor
  397. sub edx,2
  398. lea eax,[esi+ebp*2]
  399. mov AspectCount,edx
  400. mov YCursor,eax
  401. jg KeepLine3
  402. add edx,AspectAdjustmentCount
  403. mov AspectCount,edx
  404. jmp SkipLine3
  405. KeepLine3:
  406. mov bl,[esi+ebp*1]
  407. mov eax,CCOPitch
  408. add eax,edi
  409. mov cl,[esi+ebp*1+1]
  410. mov CCOCursor,eax
  411. mov edx,PD YDitherZ2[ebx*4]
  412. sub edi,esi
  413. mov eax,PD YDitherZ2[ecx*4]
  414. and edx,0FFFF0000H
  415. sub edi,esi
  416. mov bl,[esi+ebp*1+2]
  417. and eax,00000FFFFH
  418. mov cl,[esi+ebp*1+3]
  419. or eax,edx
  420. mov edx,ChromaContribution
  421. sub esp,1536
  422. Line3Loop:
  423. add eax,edx
  424. mov edx,PD YDitherZ2[ebx*4]
  425. bswap eax
  426. mov Ze [edi+esi*2],eax
  427. add esi,4
  428. and edx,0FFFF0000H
  429. mov eax,PD YDitherZ2[ecx*4]
  430. and eax,00000FFFFH
  431. mov bl,[esi+ebp*1]
  432. or eax,edx
  433. mov edx,ChromaContribution+1536+4
  434. add eax,edx
  435. mov cl,[esi+ebp*1+1]
  436. bswap eax
  437. mov Ze [edi+esi*2+4-8],eax
  438. mov edx,PD YDitherZ2[ebx*4]
  439. and edx,0FFFF0000H
  440. mov eax,PD YDitherZ2[ecx*4]
  441. and eax,00000FFFFH
  442. mov bl,[esi+ebp*1+2]
  443. or eax,edx
  444. mov edx,ChromaContribution+1536+8
  445. add esp,8
  446. mov cl,[esi+ebp*1+3]
  447. test edx,edx
  448. jne Line3Loop
  449. and esp,0FFFFF800H
  450. add esp,0800H
  451. SkipLine3:
  452. mov esi,YCursor
  453. mov eax,YLimit
  454. cmp eax,esi
  455. jne NextTwoLines
  456. mov esp,StashESP
  457. pop ebx
  458. pop ebp
  459. pop edi
  460. pop esi
  461. rturn
  462. YUV12ToCLUT8ZoomBy2 endp
  463. END