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.

393 lines
12 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. ;* -------------------------------------------------------------------------
  15. ;* PVCS Source control information:
  16. ;*
  17. ;* $Header: S:\h26x\src\dec\dx5cnvy.asv 1.1 29 Aug 1995 16:50:02 DBRUCKS $
  18. ;*
  19. ;* $Log: S:\h26x\src\dec\dx5cnvy.asv $
  20. ;//
  21. ;// Rev 1.1 29 Aug 1995 16:50:02 DBRUCKS
  22. ;// add in and out pitch parameters
  23. ;//
  24. ;// Rev 1.0 23 Aug 1995 12:20:32 DBRUCKS
  25. ;// Initial revision.
  26. ;*
  27. ;* NOTE:
  28. ;* The starting source for this routine came for the PVCS database
  29. ;* for the H.261 decoder. cc12to7.asm version 1.6. This is a
  30. ;* working 16-bit version.
  31. ;* -------------------------------------------------------------------------
  32. ;////////////////////////////////////////////////////////////////////////////
  33. ; Convert_Y_8to7_Bit -- This function converts the Y data from 8 bits to 7 bits
  34. ; and moves the data into the format the MRV color
  35. ; convertors want.
  36. ;
  37. ; Input to this function is either YVU12 from the decoder,
  38. ; or YVU9 for looking glass.
  39. ;
  40. ; NOTES:
  41. ; Routine uses 4 DWORDs on stack for local variables
  42. ; The 16-bit code is not up to date.
  43. ;
  44. ; ASSUMPTIONS/LIMITATIONS:
  45. ; -- YPitchOut >= XResolution
  46. ; -- YPitch >= XResolution
  47. ;
  48. ;-------------------------------------------------------------------------------
  49. ifndef WIN32
  50. .MODEL SMALL
  51. endif
  52. .486
  53. ifdef WIN32
  54. .MODEL FLAT
  55. .DATA
  56. else ;; WIN16
  57. _DATA SEGMENT PUBLIC 'DATA'
  58. endif
  59. ;; Lookup Table for 8->7 bit conversion and clamping.
  60. tbl8to7 BYTE 8, 8, 8, 8, 8, 8, 8, 8
  61. BYTE 8, 8, 8, 8, 8, 8, 8, 8
  62. BYTE 8, 8, 9, 9, 10, 10, 11, 11
  63. BYTE 12, 12, 13, 13, 14, 14, 15, 15
  64. BYTE 16, 16, 17, 17, 18, 18, 19, 19
  65. BYTE 20, 20, 21, 21, 22, 22, 23, 23
  66. BYTE 24, 24, 25, 25, 26, 26, 27, 27
  67. BYTE 28, 28, 29, 29, 30, 30, 31, 31
  68. BYTE 32, 32, 33, 33, 34, 34, 35, 35
  69. BYTE 36, 36, 37, 37, 38, 38, 39, 39
  70. BYTE 40, 40, 41, 41, 42, 42, 43, 43
  71. BYTE 44, 44, 45, 45, 46, 46, 47, 47
  72. BYTE 48, 48, 49, 49, 50, 50, 51, 51
  73. BYTE 52, 52, 53, 53, 54, 54, 55, 55
  74. BYTE 56, 56, 57, 57, 58, 58, 59, 59
  75. BYTE 60, 60, 61, 61, 62, 62, 63, 63
  76. BYTE 64, 64, 65, 65, 66, 66, 67, 67
  77. BYTE 68, 68, 69, 69, 70, 70, 71, 71
  78. BYTE 72, 72, 73, 73, 74, 74, 75, 75
  79. BYTE 76, 76, 77, 77, 78, 78, 79, 79
  80. BYTE 80, 80, 81, 81, 82, 82, 83, 83
  81. BYTE 84, 84, 85, 85, 86, 86, 87, 87
  82. BYTE 88, 88, 89, 89, 90, 90, 91, 91
  83. BYTE 92, 92, 93, 93, 94, 94, 95, 95
  84. BYTE 96, 96, 97, 97, 98, 98, 99, 99
  85. BYTE 100,100,101,101,102,102,103,103
  86. BYTE 104,104,105,105,106,106,107,107
  87. BYTE 108,108,109,109,110,110,111,111
  88. BYTE 112,112,113,113,114,114,115,115
  89. BYTE 116,116,117,117,118,118,119,119
  90. BYTE 120,120,120,120,120,120,120,120
  91. BYTE 120,120,120,120,120,120,120,120
  92. _DATA ENDS
  93. ifdef WIN32
  94. .CODE
  95. assume cs : flat
  96. assume ds : flat
  97. assume es : flat
  98. assume fs : flat
  99. assume gs : flat
  100. assume ss : flat
  101. else
  102. _TEXT32 SEGMENT PUBLIC READONLY USE32 'CODE'
  103. ASSUME DS:_DATA
  104. ASSUME CS:_TEXT32
  105. ASSUME ES:nothing
  106. ASSUME FS:nothing
  107. ASSUME GS:nothing
  108. endif
  109. ;32-bit version of call
  110. ;C function prototype
  111. ;
  112. ;long Convert_Y_8to7_Bit(HPBYTE pYPlaneInput, /* ptr Y plane */
  113. ; DWORD YResolution, /* Y plane height */
  114. ; DWORD XResolution, /* Y plane width */
  115. ; DWORD YInPitch, /* Y input pitch */
  116. ; HPBYTE pYPlaneOutput, /* pYOut */
  117. ; DWORD YOutPitch /* Y output pitch */
  118. ; )
  119. ;
  120. ;16-bit version of call
  121. ;C function prototype -- not up to date
  122. ;
  123. ;long Convert_Y_8to7_Bit(HPBYTE pYPlaneInput, /*ptr Y plane*/
  124. ; WORD YResolution, /*Y plane height*/
  125. ; WORD XResolution, /*Y plane width*/
  126. ; HPBYTE pYPlaneOutput, /*pYOut*/
  127. ; WORD YPitchOut /*Pitch of Y plane Out*/
  128. ; )
  129. PUBLIC _Convert_Y_8to7_Bit
  130. ifdef WIN32
  131. _Convert_Y_8to7_Bit proc
  132. ; parmD pYPlaneIn ;ptr to Y input plane
  133. ; parmD YRes ;Y plane height
  134. ; parmD XRes ;Y plane width
  135. ; parmD YInPitch ;Y input pitch
  136. ; parmD pYPlaneOut ;ptr to Y output plane
  137. ; parmD YOutPitch ;ptr to Y output pitch
  138. else
  139. _Convert_Y_8to7_Bit proc far
  140. ; parmD pYPlaneIn ;ptr to Y input plane
  141. ; parmW YRes ;Y plane height
  142. ; parmW XRes ;Y plane width
  143. ; parmD pYPlaneOut ;ptr to Y output plane
  144. ; parmW YPitchOut ;Pitch of Y plane output
  145. endif
  146. ;set up equates
  147. ifdef WIN32
  148. pYPlaneIn EQU DWORD PTR[ebp+8]
  149. YRes EQU DWORD PTR[ebp+12]
  150. XRes EQU DWORD PTR[ebp+16]
  151. YInPitch EQU DWORD PTR[ebp+20]
  152. pYPlaneOut EQU DWORD PTR[ebp+24]
  153. YOutPitch EQU DWORD PTR[ebp+28]
  154. else
  155. pYPlaneIn EQU DWORD PTR[ebp+8]
  156. YRes EQU WORD PTR[ebp+12]
  157. XRes EQU WORD PTR[ebp+14]
  158. pYPlaneOut EQU DWORD PTR[ebp+16]
  159. YPitchOut EQU WORD PTR[ebp+20]
  160. endif
  161. ;; stack usage
  162. ; previous ebp at ebp
  163. ; previous edi at ebp - 4
  164. ; previous esi at ebp - 8
  165. ; lXResDiv4 at ebp -12
  166. ; YInDiff at ebp -16
  167. ; YOutDiff at ebp -20
  168. ; outloopcnt at ebp -24
  169. ; inloopcnt at ebp -28
  170. lXResDiv4 EQU DWORD PTR[ebp-12]
  171. YInDiff EQU DWORD PTR[ebp-16]
  172. YOutDiff EQU DWORD PTR[ebp-20]
  173. outloopcnt EQU DWORD PTR[ebp-24]
  174. inloopcnt EQU DWORD PTR[ebp-28]
  175. xor ax,ax ; These two instructions give definitive proof we are
  176. mov eax,0CCCCCCCCH ; in a 32-bit code segment. INT 3 occurs if not.
  177. ;get params
  178. push ebp
  179. ifdef WIN32
  180. mov ebp, esp
  181. else
  182. movzx ebp, sp
  183. endif
  184. push edi
  185. push esi
  186. ifdef WIN32
  187. ; zero out registers
  188. else
  189. ; zero out registers
  190. xor esi, esi
  191. xor edi, edi
  192. endif
  193. ; move variables to local space on stack
  194. ifdef WIN32
  195. mov eax, XRes
  196. mov ecx, YInPitch
  197. mov edx, YOutPitch
  198. else
  199. movzx eax, XRes
  200. movzx ecx, YPitchOut
  201. endif
  202. sub ecx, eax ; YInDiff = YInPitch - XRes
  203. sub edx, eax ; YOutDiff = YOutPitch - XRes
  204. shr eax, 2
  205. push eax ; store lXResDiv4 == XRes/4 on stack
  206. push ecx ; store YInDiff on stack
  207. push edx ; store YOutDiff on stack
  208. ; push stack with 0 2 additional times to make room for other locals
  209. xor edx, edx
  210. push edx ; outloopcnt
  211. push edx ; inloopcnt
  212. ; ********************
  213. ; Copy Y Plane from soure to dest and convert to 7 bits
  214. ; ********************
  215. ; Description of YPlane processing:
  216. ; - Double nested loop with
  217. ; Outlp1 executed YRes lines
  218. ; Collp1 loops for number of columns/4
  219. ; - Read 4 inputs in one DWORD
  220. ; - Convert each value from 8-bit to 7-bit
  221. ; - Store 4 output in one DWORD
  222. ;
  223. ; Register usage
  224. ; eax holds 4 output value 8 bits each
  225. ; ebx holds 4 source value and index into tbl8to7
  226. ; ecx index into tbl8to7
  227. ; edx index into tbl8to7
  228. ; esi src address
  229. ; edi des address
  230. ; ebp stack pointer stuff
  231. ;
  232. ; if 16-bit
  233. ; es input plane segment
  234. ; fs output plane segment
  235. ; ds table segment
  236. ; endif
  237. ;
  238. ; local variables
  239. ; outloopcnt
  240. ; inloopcnt
  241. ; lXResDiv4
  242. ; YInDiff
  243. ; YOutDiff
  244. ;
  245. ifdef WIN32
  246. mov esi, pYPlaneIn ; Initialize input cursor
  247. mov edi, pYPlaneOut ; Initialize output cursor
  248. mov ebx, YRes ; get YResolution
  249. sub edi, YOutDiff ; Pre-adjust for add in loop of
  250. ; difference between YPitchOut and
  251. ; XRes
  252. sub esi, YInDiff
  253. else
  254. les si, pYPlaneIn ; Initialize input cursor
  255. lfs di, pYPlaneOut ; Initialize output cursor
  256. sub edi, YOutDiff ; Pre-adjust for add in loop of
  257. ; difference between YPitchOut and
  258. ; XRes
  259. sub esi, YInDiff
  260. movzx ebx, YRes ; get YResolution
  261. endif
  262. Outlp:
  263. mov edx, lXResDiv4 ; edx = number of columns/4
  264. mov outloopcnt, ebx ; initialize/store updated outloopcnt
  265. add edi, YOutDiff ; adjust for difference
  266. mov inloopcnt, edx ; set inner loop count
  267. add esi, YInDiff ; adjust for difference
  268. ; Preamble
  269. ifdef WIN32
  270. mov ebx, [esi] ; Fetch source, 4 at a time
  271. nop
  272. mov ecx, ebx ; Move source to temp
  273. nop
  274. else
  275. mov ebx, es:[esi] ; Fetch source, 4 at a time
  276. mov ecx,ebx ; Move source to temp
  277. endif
  278. shr ecx,24 ; shift to get 4th address
  279. mov edx,ebx ; Move source to temp
  280. shr edx,16 ; Shift to get 3rd address
  281. add esi,4 ; increment source to next 4
  282. mov ah, tbl8to7[ecx]; convert 4th element to 7 bits
  283. and edx,0000000ffh ; and off 3rd element
  284. mov ecx,ebx ; Move source to temp
  285. add edi,4 ; incrment to next destination
  286. shr ecx,8 ; Shift to get 2nd address
  287. and ebx,0000000ffh ; and off 1st element
  288. and ecx,0000000ffh ; And off 2nd element
  289. mov al, tbl8to7[edx]; convert 3rd element to 7 bits
  290. shl eax,16 ; Shift output up
  291. mov edx, inloopcnt ; get inner loop count
  292. mov al, tbl8to7[ebx]; convert 1st element to 7 bits
  293. dec edx ; decrement inner loop counter
  294. mov ah, tbl8to7[ecx]; convert 2nd element to 7 bits
  295. Collp:
  296. ifdef WIN32
  297. mov ebx, [esi] ; Fetch source, 4 at a time
  298. mov inloopcnt, edx ; store updated inner loop count
  299. mov [edi-4],eax ; Store 4 converted values
  300. else
  301. mov ebx, es:[esi] ; Fetch source, 4 at a time
  302. mov inloopcnt, edx ; store updated inner loop count
  303. mov fs:[edi-4],eax ; Store 4 converted values
  304. endif
  305. mov ecx,ebx ; Move source to temp
  306. shr ecx,24 ; shift to get 4th address
  307. mov edx,ebx ; Move source to temp
  308. shr edx,16 ; Shift to get 3rd address
  309. add esi,4 ; increment source to next 4
  310. mov ah, tbl8to7[ecx]; convert 4th element to 7 bits
  311. and edx,0000000ffh ; and off 3rd element
  312. mov ecx,ebx ; Move source to temp
  313. add edi,4 ; incrment to next destination
  314. shr ecx,8 ; Shift to get 2nd address
  315. and ebx,0000000ffh ; and off 1st element
  316. and ecx,0000000ffh ; And off 2nd element
  317. mov al, tbl8to7[edx]; convert 3rd element to 7 bits
  318. shl eax,16 ; Shift output up
  319. mov edx, inloopcnt ; get inner loop count
  320. mov al, tbl8to7[ebx]; convert 1st element to 7 bits
  321. dec edx ; decrement inner loop counter
  322. mov ah, tbl8to7[ecx]; convert 2nd element to 7 bits
  323. jg Collp ; if not done loop
  324. ; Postscript
  325. ifdef WIN32
  326. mov [edi-4],eax ; Store 4 converted values
  327. else
  328. mov fs:[edi-4],eax ; Store 4 converted values
  329. endif
  330. mov ebx, outloopcnt ; get outer loop count
  331. dec ebx ; decrement outer loop count
  332. jnz Outlp ; if more to do loop
  333. ; clean out local variables on stack
  334. pop ecx
  335. pop eax
  336. pop ecx
  337. pop eax
  338. pop ecx
  339. ;clear special seg registers, restore stack, pop saved registers
  340. ifndef WIN32
  341. xor ecx, ecx
  342. mov es, cx
  343. mov fs, cx
  344. endif
  345. pop esi
  346. pop edi
  347. pop ebp
  348. ifdef WIN32
  349. ret
  350. else
  351. db 066h
  352. retf
  353. endif
  354. _Convert_Y_8to7_Bit endp
  355. END