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.

871 lines
24 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. ;* PVCS Source control information:
  15. ;*
  16. ;* $Header: S:\h26x\src\dec\dx5aspec.asv 1.2 01 Sep 1995 17:12:12 DBRUCKS $
  17. ;*
  18. ;* $Log: S:\h26x\src\dec\dx5aspec.asv $
  19. ;//
  20. ;// Rev 1.2 01 Sep 1995 17:12:12 DBRUCKS
  21. ;// fix shaping
  22. ;//
  23. ;// Rev 1.1 29 Aug 1995 16:49:02 DBRUCKS
  24. ;// cleanup comment
  25. ;//
  26. ;// Rev 1.0 23 Aug 1995 12:20:32 DBRUCKS
  27. ;// Initial revision.
  28. ;*
  29. ;* NOTE:
  30. ;* The starting source for this routine came from the PVCS database
  31. ;* for the H261 decoder (aspeccor.asm version 1.1, which is a working
  32. ;* 16-bit version).
  33. ;* -------------------------------------------------------------------------
  34. ;////////////////////////////////////////////////////////////////////////////
  35. ; AspectCorrect -- This function converts the U & V data from 8 bits to 7 bits
  36. ; and moves the data into the YVU9 format the MRV color
  37. ; convertors want. Note: the Y data was already converted
  38. ; from 8 bits to 7 bits in Convert_Y_8to7_Bit.
  39. ;
  40. ; if (Input Format == YVU9)
  41. ; /* This is needed for looking glass output */
  42. ; copy U and V from src to dst
  43. ; else { /* Input Format == YVU12 */
  44. ; if (shaping) {
  45. ; copy Y from src to dst skiping every 12th line
  46. ; copy UV from src to dst subsampling and dropping one in 12 lines
  47. ; (although not every 12th).
  48. ; } else {
  49. ; copy UV from src to dst subsampling
  50. ; }
  51. ; }
  52. ;
  53. ; Notes:
  54. ; * the MRV color converters expect YVU9
  55. ; * we may need to drop every 12th line for aspect ratio correction of the
  56. ; YVU12 input.
  57. ;
  58. ; ASSUMPTIONS/LIMITATIONS:
  59. ; * IF input in YVU12, only 128x96, 176x144, & 352x288 resolutions are
  60. ; supported. YVU9 should support all sizes.
  61. ;
  62. ;-------------------------------------------------------------------------------
  63. include decconst.inc
  64. ifndef WIN32
  65. .MODEL SMALL
  66. endif
  67. .486
  68. ifdef WIN32
  69. .MODEL FLAT
  70. .DATA
  71. else ;; WIN16
  72. _DATA SEGMENT PUBLIC 'DATA'
  73. endif
  74. ;; Toss lines for aspect ratio correction 12 to 9
  75. ;; 6, 19, 30, 43, 54, 67,
  76. ;; 78, 91,102,115,126,139
  77. ;; Lookup Table for 8->7 bit conversion and clamping.
  78. ;; U and V range from 16..240->8..120
  79. gTAB_UVtbl8to7 BYTE 8, 8, 8, 8, 8, 8, 8, 8
  80. BYTE 8, 8, 8, 8, 8, 8, 8, 8
  81. BYTE 8, 8, 9, 9, 10, 10, 11, 11
  82. BYTE 12, 12, 13, 13, 14, 14, 15, 15
  83. BYTE 16, 16, 17, 17, 18, 18, 19, 19
  84. BYTE 20, 20, 21, 21, 22, 22, 23, 23
  85. BYTE 24, 24, 25, 25, 26, 26, 27, 27
  86. BYTE 28, 28, 29, 29, 30, 30, 31, 31
  87. BYTE 32, 32, 33, 33, 34, 34, 35, 35
  88. BYTE 36, 36, 37, 37, 38, 38, 39, 39
  89. BYTE 40, 40, 41, 41, 42, 42, 43, 43
  90. BYTE 44, 44, 45, 45, 46, 46, 47, 47
  91. BYTE 48, 48, 49, 49, 50, 50, 51, 51
  92. BYTE 52, 52, 53, 53, 54, 54, 55, 55
  93. BYTE 56, 56, 57, 57, 58, 58, 59, 59
  94. BYTE 60, 60, 61, 61, 62, 62, 63, 63
  95. BYTE 64, 64, 65, 65, 66, 66, 67, 67
  96. BYTE 68, 68, 69, 69, 70, 70, 71, 71
  97. BYTE 72, 72, 73, 73, 74, 74, 75, 75
  98. BYTE 76, 76, 77, 77, 78, 78, 79, 79
  99. BYTE 80, 80, 81, 81, 82, 82, 83, 83
  100. BYTE 84, 84, 85, 85, 86, 86, 87, 87
  101. BYTE 88, 88, 89, 89, 90, 90, 91, 91
  102. BYTE 92, 92, 93, 93, 94, 94, 95, 95
  103. BYTE 96, 96, 97, 97, 98, 98, 99, 99
  104. BYTE 100,100,101,101,102,102,103,103
  105. BYTE 104,104,105,105,106,106,107,107
  106. BYTE 108,108,109,109,110,110,111,111
  107. BYTE 112,112,113,113,114,114,115,115
  108. BYTE 116,116,117,117,118,118,119,119
  109. BYTE 120,120,120,120,120,120,120,120
  110. BYTE 120,120,120,120,120,120,120,120
  111. _DATA ENDS
  112. ifdef WIN32
  113. .CODE
  114. assume cs : flat
  115. assume ds : flat
  116. assume es : flat
  117. assume fs : flat
  118. assume gs : flat
  119. else
  120. _TEXT32 SEGMENT PUBLIC READONLY USE32 'CODE'
  121. ASSUME DS:_DATA
  122. ASSUME CS:_TEXT32
  123. ASSUME ES:nothing
  124. ASSUME FS:nothing
  125. ASSUME GS:nothing
  126. endif
  127. ;C function prototype
  128. ;
  129. ;long AspectCorrect(
  130. ; HPBYTE pYPlaneInput, /*ptr Y plane*/
  131. ; HPBYTE pVPlaneInput, /*ptr V plane*/
  132. ; HPBYTE pUPlaneInput, /*ptr U plane*/
  133. ; DWORD YResolution, /*Y plane height*/
  134. ; DWORD XResolution, /*Y plane width*/
  135. ; WORD far * pyNewHeight, /*Pitch of Y plane in*/
  136. ; DWORD YVU9InputFlag, /*flag = YUV9 or YUV12*/
  137. ; HPBYTE pYPlaneOutput, /*pYOut*/
  138. ; HPBYTE pVPlaneOutput, /*pUOut*/
  139. ; DWORD YPitchOut, /*Pitch of Y plane out*/
  140. ; DWORD ShapingFlag /*flag = Shaping or not*/
  141. ; )
  142. PUBLIC _AspectCorrect
  143. ifdef WIN32
  144. _AspectCorrect proc
  145. else
  146. _AspectCorrect proc far
  147. ; parmD pYPlaneIn ;ptr to Y input plane
  148. ; parmD pVPlaneIn ;ptr to V input plane
  149. ; parmD pUPlaneIn ;ptr to U input plane
  150. ; parmD YRes ;Y plane height
  151. ; parmD XRes ;Y plane width
  152. ; parmD pYNewHeight ;Pitch of Y plane input
  153. ; parmD YVU9Flag ;Flag=1 if YUV9
  154. ; parmD pYPlaneOut ;ptr to Y output plane
  155. ; parmD pVPlaneOut ;ptr to V output plane
  156. ; parmD YPitchOut ;Pitch of Y plane output
  157. ; parmD ShapingFlag ;Flag=1 if Shaping
  158. endif
  159. ;set up equates
  160. pYPlaneIn EQU DWORD PTR[ebp+8]
  161. pVPlaneIn EQU DWORD PTR[ebp+12]
  162. pUPlaneIn EQU DWORD PTR[ebp+16]
  163. YRes EQU DWORD PTR[ebp+20]
  164. XRes EQU DWORD PTR[ebp+24]
  165. pYNewHeight EQU DWORD PTR[ebp+28]
  166. YVU9Flag EQU DWORD PTR[ebp+32]
  167. pYPlaneOut EQU DWORD PTR[ebp+36]
  168. pVPlaneOut EQU DWORD PTR[ebp+40]
  169. YPitchOut EQU DWORD PTR[ebp+44]
  170. ShapingFlag EQU DWORD PTR[ebp+48]
  171. ;; stack usage
  172. ; previous ebp at ebp
  173. ; previous edi at ebp - 4
  174. ; previous esi at ebp - 8
  175. ; lXRes at ebp -12
  176. ; lYRes at ebp -16
  177. ; lYPitchOut at ebp -20
  178. ; YDiff at ebp -24
  179. ; outloopcnt at ebp -28
  180. ; uvWidth at ebp -32
  181. ; inloopcnt at ebp -36
  182. ; luvcounter at ebp -40
  183. ; uvoutloopcnt at ebp -44
  184. ; VDiff at ebp -48
  185. ; VInDiff at ebp -52
  186. lXRes EQU DWORD PTR[ebp-12]
  187. lYRes EQU DWORD PTR[ebp-16]
  188. lYPitchOut EQU DWORD PTR[ebp-20]
  189. YDiff EQU DWORD PTR[ebp-24]
  190. outloopcnt EQU DWORD PTR[ebp-28]
  191. uvWidth EQU DWORD PTR[ebp-32]
  192. inloopcnt EQU DWORD PTR[ebp-36]
  193. luvcounter EQU DWORD PTR[ebp-40]
  194. uvoutloopcnt EQU DWORD PTR[ebp-44]
  195. VDiff EQU DWORD PTR[ebp-48]
  196. VInDiff EQU DWORD PTR[ebp-52]
  197. xor ax,ax ; These two instructions give definitive proof we are
  198. mov eax,0CCCCCCCCH ; in a 32-bit code segment. INT 3 occurs if not.
  199. ;get params
  200. push ebp
  201. ifdef WIN32
  202. mov ebp, esp
  203. else
  204. movzx ebp, sp ;ebp now pointing to last pushed reg
  205. endif
  206. push edi
  207. push esi
  208. ; zero out registers
  209. xor edx, edx
  210. xor esi, esi
  211. xor edi, edi
  212. ; move stack variables to local space
  213. mov eax, XRes
  214. push eax ; store lXRes on stack
  215. mov ebx, YRes
  216. push ebx ; store lYRes on stack
  217. mov ecx, YPitchOut
  218. push ecx ; store lYpitchOut on stack
  219. sub ecx, eax ; YDiff = YPitchOut - XRes
  220. push ecx ; store YDiff on stack
  221. ; push stack with 0 6 additional times to make room for other locals
  222. push edx ; outloopcnt
  223. push edx ; uvWidth
  224. push edx ; inloopcnt
  225. push edx ; luvcounter
  226. push edx ; uvoutloopcnt
  227. push edx ; VDiff
  228. push edx ; VInDiff
  229. ; test if YUV9 mode
  230. mov edx, YVU9Flag
  231. test edx,edx
  232. jz YVU12; ; If the flag is false it must be YVU12
  233. ;**********************************************************************
  234. ;**********************************************************************
  235. ; know input was YVU9, Y Plane was processed in cc12to7.asm
  236. mov esi, pYNewHeight
  237. mov WORD PTR [esi], bx ; store YRes into address pYNewHeight
  238. ; ********************
  239. ; Copy V and U Plane from source to destination converting to 7 bit
  240. ; ********************
  241. ; Description of V & U Plane processing:
  242. ; - Double nested loop with
  243. ; Outlp1 executed YRes/4 lines
  244. ; Collp1 loops for number of columns
  245. ; - Read 1 U
  246. ; - Read 1 V
  247. ; - Convert each value from 8-bit to 7-bit
  248. ; - Store 1 U
  249. ; - Store 1 V
  250. ;
  251. ; Register usage
  252. ; eax U plane input address
  253. ; ebx source value and index into gTAB_UVtbl8to7
  254. ; ecx source value and index into gTAB_UVtbl8to7
  255. ; edx inner most loop counter
  256. ; esi V plane src address
  257. ; edi des address
  258. ; ebp stack pointer stuff
  259. ;
  260. ; if (16-bit)
  261. ; es input plane segment
  262. ; fs output plane segment
  263. ; ds table segment
  264. ; endif
  265. ;
  266. ; local variables
  267. ; outloopcnt
  268. ; lXRes
  269. ; lYRes
  270. ; uvWidth
  271. ; VDiff
  272. ;
  273. ; know input was YVU9
  274. mov ecx, lYRes
  275. mov ebx, lXRes
  276. shr ebx, 2 ; uvWidth=XRes/4
  277. mov eax, VPITCH ; get Fixed offset
  278. shr ecx, 2 ; outloopcnt=YRes/4
  279. mov uvWidth,ebx ; uvWidth=XRes/4
  280. sub eax, ebx ; VPITCH - uvWidth
  281. mov esi, pVPlaneIn ; Initialize input cursor
  282. mov edi, pVPlaneOut ; Initialize output cursor
  283. mov VDiff, eax ; store V difference
  284. mov eax, pUPlaneIn ; Initialize input cursor
  285. Row9lp2:
  286. mov outloopcnt,ecx ; store updated outer loop count
  287. mov edx, uvWidth ; init dx
  288. xor ebx, ebx
  289. xor ecx, ecx
  290. Col9lpv1:
  291. mov cl, BYTE PTR [eax] ; Fetch *PUtemp_IN
  292. inc edi ; Inc des by 1, PVtemp_OUT++
  293. mov bl, BYTE PTR [esi] ; Fetch *pVtemp_IN
  294. inc eax ; pUtemp+=1
  295. mov cl, gTAB_UVtbl8to7[ecx] ; cl = gTAB_UVtbl8to7[*pUtemp_IN]
  296. inc esi ; Inc source by 1,pVtemp+=1
  297. mov BYTE PTR [edi+167],cl ; store in PUtemp_OUT
  298. mov bl, gTAB_UVtbl8to7[ebx] ; bl = gTAB_UVtbl8to7[*pVtemp_IN]
  299. mov BYTE PTR [edi-1],bl ; store in PVtemp_OUT
  300. xor ecx, ecx ; dummy op
  301. dec edx
  302. jg Col9lpv1
  303. ;; increment to beginning of next line
  304. mov edx, VDiff
  305. mov ecx, outloopcnt ; get outer loop count
  306. add edi,edx ; Point to next output row
  307. dec ecx
  308. jnz Row9lp2 ; if more to do loop
  309. jmp Cleanup
  310. ;*****************************************************************
  311. ;*****************************************************************
  312. ; know input was YVU12
  313. ;
  314. ; if (!ShapingFlag) {
  315. ; goto YVU12_NO_SHAPING;
  316. ; } else {
  317. ; switch (YRes) { // YRes = YRes * 11 / 12;
  318. ; case 96: *pyNewHeight = 88; break;
  319. ; case 144: *pyNewHeight = 132; break;
  320. ; case 288: *pyNewHeight = 264; break;
  321. ; default: error;
  322. ; }
  323. ; }
  324. ;
  325. YVU12:
  326. mov eax, ShapingFlag
  327. test eax, eax
  328. jz YVU12_NO_SHAPING
  329. cmp lYRes, 96 ; If 96
  330. je YRes96
  331. cmp lYRes, 144 ; If 144
  332. je YRes144
  333. cmp lYRes, 288 ; If 288
  334. je YRes288
  335. jmp Error
  336. ;
  337. YRes96:
  338. mov ax, 88 ; pyNewHeight = ax = 132
  339. mov ecx, 7 ; for YRes lines loopcounter=11
  340. mov uvoutloopcnt, 1 ; process 1 full set of 13&11 lines
  341. jmp Rejoin2
  342. YRes144:
  343. mov ax, 132 ; pyNewHeight = ax = 132
  344. mov ecx, 11 ; for YRes lines loopcounter=11
  345. mov uvoutloopcnt, 2 ; process 2 full sets of 13&11 lines
  346. jmp Rejoin2
  347. YRes288:
  348. mov ax, 264 ; pyNewHeight = ax = 264
  349. mov ecx, 23 ; for YRes lines loopcounter=23
  350. mov uvoutloopcnt, 5 ; process 5 full sets of 13&11 lines
  351. Rejoin2:
  352. mov esi, pYNewHeight
  353. mov [esi], ax ; store adjusted height into
  354. ; address pYNewHeight
  355. ; ********************
  356. ; Copy Y Plane from soure to dest skipping every 12th line
  357. ; ********************
  358. ; Description of YPlane processing:
  359. ;
  360. ; Triple nested loop with
  361. ; Outlp1 executed 11 or 23 times based on 144 or 288 lines respectively
  362. ; Rowlp1 is executed 11 times
  363. ; Collp1 loops for number of columns
  364. ;
  365. ; Register usage
  366. ; eax rows loop count
  367. ; ebx input and output
  368. ; ecx outer loop count
  369. ; edx column loop counter
  370. ; esi src address
  371. ; edi des address
  372. ; ebp stack pointer stuff
  373. ;
  374. ; es input plane segment
  375. ; fs output plane segment
  376. ; ds table segment
  377. ;
  378. ; local variables
  379. ; lXRes
  380. ; YDiff
  381. ; lYPitchOut
  382. ;
  383. mov esi, pYPlaneIn ; Initialize input cursor
  384. mov edi, pYPlaneOut ; Initialize output cursor
  385. ; No need to re-copy first 11 lines
  386. mov eax, lYPitchOut
  387. mov edx, YDiff
  388. add edi, eax ; des + 1*lYPitchOut
  389. shl eax, 1 ; lYPitchOut*2
  390. ;;; add esi, edx ; Adjust for difference in YPitchOut
  391. ; and XRes
  392. add edi, eax ; des + 3*lYpitchOut
  393. shl eax, 1 ; lYPirchOut*4
  394. ;;; add edi, edx ; Adjust for difference in YPitchOut
  395. ; and XRes
  396. add esi, eax ; source + 4*lYpitchOut
  397. shl eax, 1 ; lYPitchOut*8
  398. add esi, eax ; source +12*lYpitchOut
  399. add edi, eax ; des + 11*lYPitchOut
  400. Outlp1:
  401. mov eax, 11 ; Initialize rows loop cnter
  402. mov edx, lXRes ; edx = number of columns
  403. Rowlp1:
  404. Collp1:
  405. mov ebx, [esi+edx-4] ; Fetch source, 4 at a time
  406. sub edx,4 ; decrement loop counter
  407. mov [edi+edx],ebx ; Store 4 converted values
  408. jnz Collp1 ; if not done loop
  409. mov edx, lYPitchOut
  410. mov ebx, YDiff
  411. add edi, edx ; Increment to where just processed
  412. add esi, edx
  413. ;;; add edi, ebx ; Adjust for difference in YPitchOut
  414. ;;; add esi, ebx ; and XRes
  415. dec eax ; decrement rows loop counter
  416. jg Rowlp1
  417. mov eax,lYPitchOut ; Skip 12th line
  418. add esi,eax ; Point to next input row
  419. dec ecx ; decrement outer loop counter
  420. jg Outlp1 ; if more to do loop
  421. ; ************************************************************
  422. ; Copy V and U Plane from source to destination converting to 7 bit
  423. ; skipping every other line and sometimes two moving only ever other
  424. ; pixel in a row.
  425. ; ********************
  426. ;
  427. ; Description of V & U Plane processing:
  428. ; - Double nested loop with
  429. ; Outlp1 executed YRes/4 lines
  430. ; Collp1 loops for number of columns
  431. ; - Read 1 U
  432. ; - Read 1 V
  433. ; - Convert each value from 8-bit to 7-bit
  434. ; - Store 1 U
  435. ; - Store 1 V
  436. ;
  437. ; Register usage
  438. ; eax U plane input address
  439. ; ebx source value and index into gTAB_UVtbl8to7
  440. ; ecx source value and index into gTAB_UVtbl8to7
  441. ; edx counter
  442. ; esi V plane src address
  443. ; edi des address, V Plane and U Plane
  444. ; ebp stack pointer stuff
  445. ;
  446. ; es input plane segment
  447. ; fs output plane segment
  448. ; ds table segment
  449. ;
  450. ; local variables
  451. ; luvcounter
  452. ; uvoutloopcnt
  453. ; inloopcnt
  454. ; lXRes
  455. ; uvWidth
  456. ; VDiff
  457. ;
  458. mov ebx, lXRes
  459. mov eax, VPITCH ; get Fixed offset
  460. shr ebx, 1 ; uvWidth=XRes/2
  461. mov uvWidth, ebx ; uvWidth=XRes/2
  462. shr ebx, 1
  463. sub eax, ebx ; VPITCH - uvWidth
  464. mov VDiff, eax ; store V difference
  465. mov luvcounter, ebx ; luvcounter = XRes/4
  466. mov ecx, YPITCH ; Distance to the next V
  467. add ecx, ecx
  468. sub ecx, uvWidth
  469. mov VInDiff, ecx ; = YPITCH + YPITCH - uvWidth
  470. mov esi, pVPlaneIn ; Initialize input cursor
  471. mov edi, pVPlaneOut ; Initialize output cursor
  472. mov eax, pUPlaneIn ; Initialize input cursor
  473. ; Process 6 first lines special
  474. mov ebx, 3 ; initialize inner loop count
  475. Rowlp2_6:
  476. mov edx, luvcounter ; init dx
  477. mov inloopcnt, ebx ; store updated inloopcnt
  478. xor ebx, ebx
  479. xor ecx, ecx
  480. Collpv1:
  481. mov cl, BYTE PTR [eax] ; Fetch *PUtemp_IN
  482. inc edi ; Inc des by 1, PVtemp_OUT++
  483. mov bl, BYTE PTR [esi] ; Fetch *pVtemp_IN
  484. add eax,2 ; pUtemp+=2
  485. mov cl, gTAB_UVtbl8to7[ecx] ; cl = gTAB_UVtbl8to7[*pUtemp_IN]
  486. add esi,2 ; Inc source by 2,pVtemp+=2
  487. mov BYTE PTR [edi+167],cl; store in PUtemp_OUT
  488. mov bl, gTAB_UVtbl8to7[ebx] ; bl = gTAB_UVtbl8to7[*pVtemp_IN]
  489. mov BYTE PTR [edi-1],bl ; store in PVtemp_OUT
  490. xor ecx, ecx ; dummy op
  491. dec edx
  492. jg Collpv1
  493. ; increment to beginning of next line then skip next input line
  494. add edi,VDiff ; Point to next output row
  495. mov edx,VInDiff ; Skip to next input row
  496. add esi,edx ;
  497. add eax,edx ;
  498. ; test if have processed 6 lines yet
  499. mov ebx, inloopcnt
  500. dec ebx
  501. jg Rowlp2_6 ; if more to do loop
  502. ; Skipping extra line
  503. mov edx,YPITCH ; Need same sized for add
  504. mov ecx, uvoutloopcnt
  505. add esi,edx ; Point to next input row
  506. add eax,edx ; Point to next input row
  507. ; Process groups of 13 and 11 lines
  508. Outlp2:
  509. ; Process 13 lines
  510. mov ebx, 6 ; initialize inner loop count
  511. mov uvoutloopcnt, ecx
  512. Rowlp2_13:
  513. mov edx, luvcounter ; init dx
  514. mov inloopcnt, ebx ; store updated inloopcnt
  515. xor ebx, ebx
  516. xor ecx, ecx
  517. Collpv1_13:
  518. mov cl, BYTE PTR [eax] ; Fetch *PUtemp_IN
  519. inc edi ; Inc des by 1, PVtemp_OUT++
  520. mov bl, BYTE PTR [esi] ; Fetch *pVtemp_IN
  521. add eax,2 ; pUtemp+=2
  522. mov cl, gTAB_UVtbl8to7[ecx] ; cl = gTAB_UVtbl8to7[*pUtemp_IN]
  523. add esi,2 ; Inc source by 2,pVtemp+=2
  524. mov BYTE PTR [edi+167],cl; store in PUtemp_OUT
  525. mov bl, gTAB_UVtbl8to7[ebx] ; bl = gTAB_UVtbl8to7[*pVtemp_IN]
  526. mov BYTE PTR [edi-1],bl ; store in PVtemp_OUT
  527. xor ecx, ecx ; dummy op
  528. dec edx
  529. jg Collpv1_13
  530. ; increment to beginning of next line then skip next input line
  531. add edi,VDiff ; Point to next output row
  532. mov edx,VInDiff ; Skip to next input row
  533. add esi,edx ;
  534. add eax,edx ;
  535. ; test if have processed 13 lines yet
  536. mov ebx, inloopcnt
  537. dec ebx
  538. jg Rowlp2_13 ; if more to do loop
  539. ; Skipping extra line
  540. mov edx,YPITCH ; Need same sized for add
  541. mov ebx, 5 ; initialize inner loop count
  542. add esi,edx ; Point to next input row
  543. add eax,edx ; Point to next input row
  544. ; Process 11 lines
  545. Rowlp2_11:
  546. mov edx, luvcounter ; init dx
  547. mov inloopcnt, ebx ; store updated inloopcnt
  548. xor ebx, ebx
  549. xor ecx, ecx
  550. Collpv1_11:
  551. mov cl, BYTE PTR [eax] ; Fetch *PUtemp_IN
  552. inc edi ; Inc des by 1, PVtemp_OUT++
  553. mov bl, BYTE PTR [esi] ; Fetch *pVtemp_IN
  554. add eax,2 ; pUtemp+=2
  555. mov cl, gTAB_UVtbl8to7[ecx] ; cl = gTAB_UVtbl8to7[*pUtemp_IN]
  556. add esi,2 ; Inc source by 2,pVtemp+=2
  557. mov BYTE PTR [edi+167],cl; store in PUtemp_OUT
  558. mov bl, gTAB_UVtbl8to7[ebx] ; bl = gTAB_UVtbl8to7[*pVtemp_IN]
  559. mov BYTE PTR [edi-1],bl ; store in PVtemp_OUT
  560. xor ecx, ecx ; dummy op
  561. dec edx
  562. jg Collpv1_11
  563. ; increment to beginning of next line, then skip next input line
  564. add edi, VDiff ; Point to next output row
  565. mov edx,VInDiff ; Skip to next input row
  566. add esi,edx ;
  567. add eax,edx ;
  568. ; test if have processed 11 lines yet
  569. mov ebx, inloopcnt
  570. dec ebx
  571. jg Rowlp2_11 ; if more to do loop
  572. ; Skipping extra line
  573. mov edx,YPITCH ; Need same sized for add
  574. mov ecx, uvoutloopcnt
  575. add esi,edx ; Point to next input row
  576. add eax,edx ; Point to next input row
  577. dec ecx
  578. jnz Outlp2 ; if more to do loop
  579. ;
  580. ; Process last set of 13
  581. ;
  582. mov ebx, 6 ; initialize inner loop count
  583. Rowlp2_13l:
  584. mov edx, luvcounter ; init dx
  585. mov inloopcnt, ebx ; store updated inloopcnt
  586. xor ebx, ebx
  587. xor ecx, ecx
  588. Collpv1_13l:
  589. mov cl, BYTE PTR [eax] ; Fetch *PUtemp_IN
  590. inc edi ; Inc des by 1, PVtemp_OUT++
  591. mov bl, BYTE PTR [esi] ; Fetch *pVtemp_IN
  592. add eax,2 ; pUtemp+=2
  593. mov cl, gTAB_UVtbl8to7[ecx] ; cl = gTAB_UVtbl8to7[*pUtemp_IN]
  594. add esi,2 ; Inc source by 2,pVtemp+=2
  595. mov BYTE PTR [edi+167],cl; store in PUtemp_OUT
  596. mov bl, gTAB_UVtbl8to7[ebx] ; bl = gTAB_UVtbl8to7[*pVtemp_IN]
  597. mov BYTE PTR [edi-1],bl ; store in PVtemp_OUT
  598. xor ecx, ecx ; dummy op
  599. dec edx
  600. jg Collpv1_13l
  601. ; increment to beginning of next line then skip next input line
  602. add edi,VDiff ; Point to next output row
  603. mov edx,VInDiff ; Skip to next input row
  604. add esi,edx ;
  605. add eax,edx ;
  606. ; test if have processed 13 lines yet
  607. mov ebx, inloopcnt
  608. dec ebx
  609. jg Rowlp2_13l ; if more to do loop
  610. ; Skipping extra line
  611. mov edx,YPITCH ; Need same sized for add
  612. mov ebx, 2 ; initialize inner loop count
  613. add esi,edx ; Point to next input row
  614. add eax,edx ; Point to next input row
  615. ; Process final 4 lines
  616. Rowlp2_f:
  617. mov edx, luvcounter ; init dx
  618. mov inloopcnt, ebx
  619. xor ebx, ebx
  620. xor ecx, ecx
  621. Collpv1_f:
  622. mov cl, BYTE PTR [eax] ; Fetch *PUtemp_IN
  623. inc edi ; Inc des by 1, PVtemp_OUT++
  624. mov bl, BYTE PTR [esi] ; Fetch *pVtemp_IN
  625. add eax,2 ; pUtemp+=2
  626. mov cl, gTAB_UVtbl8to7[ecx] ; cl = gTAB_UVtbl8to7[*pUtemp_IN]
  627. add esi,2 ; Inc source by 2,pVtemp+=2
  628. mov BYTE PTR [edi+167],cl; store in PUtemp_OUT
  629. mov bl, gTAB_UVtbl8to7[ebx] ; bl = gTAB_UVtbl8to7[*pVtemp_IN]
  630. mov BYTE PTR [edi-1],bl ; store in PVtemp_OUT
  631. xor ecx, ecx ; dummy op
  632. dec edx
  633. jg Collpv1_f
  634. ; increment to beginning of next line then skip next input line
  635. add edi, VDiff ; Point to next output row
  636. mov edx,VInDiff ; Skip to next input row
  637. add esi,edx ;
  638. add eax,edx ;
  639. ; test if have processed last lines yet
  640. mov ebx, inloopcnt
  641. dec ebx
  642. jg Rowlp2_f ; if more to do loop
  643. jmp Cleanup
  644. ; ************************************************************
  645. ; Copy V and U Plane from source to destination converting to 7 bit
  646. ; skipping every other line moving only ever other pixel in a row.
  647. ; ********************
  648. ;
  649. ; Description of V & U Plane processing:
  650. ; - Double nested loop with
  651. ; Outlp1 executed YRes/4 lines
  652. ; Collp1 loops for number of columns
  653. ; - Read 1 U
  654. ; - Read 1 V
  655. ; - Convert each value from 8-bit to 7-bit
  656. ; - Store 1 U
  657. ; - Store 1 V
  658. ;
  659. ; Register usage
  660. ; eax U plane input address
  661. ; ebx source value and index into gTAB_UVtbl8to7
  662. ; ecx source value and index into gTAB_UVtbl8to7
  663. ; edx counter
  664. ; esi V plane src address
  665. ; edi des address, V Plane and U Plane
  666. ; ebp stack pointer stuff
  667. ;
  668. ; es input plane segment
  669. ; fs output plane segment
  670. ; ds table segment
  671. ;
  672. ; local variables
  673. ; luvcounter
  674. ; inloopcnt
  675. ; lYRes
  676. ; lXRes
  677. ; uvWidth
  678. ; VDiff
  679. ; VInDiff
  680. ;
  681. YVU12_NO_SHAPING:
  682. cmp lYRes, 98
  683. je YRes98_NS
  684. cmp lYRes, 144
  685. je YRes144_NS
  686. cmp lYRes, 288
  687. je YRes288_NS
  688. jmp Error
  689. ;
  690. YRes98_NS: ; 98 No Shaping
  691. YRes144_NS: ; 144 No Shaping
  692. YRes288_NS: ; 288 No Shaping
  693. mov eax, lYRes ; pyNewHeight = ax = YRes
  694. mov esi, pYNewHeight
  695. mov [esi], ax ; store adjusted height into
  696. shr eax, 2 ; inloopcnt=YRes/2
  697. mov ebx, lXRes
  698. shr ebx, 1 ; uvWidth=XRes/2
  699. mov inloopcnt, eax ; initialize inner loop count
  700. mov uvWidth, ebx ; uvWidth=XRes/2
  701. mov ecx, VPITCH ; get output plane V pitch
  702. shr ebx, 1
  703. sub ecx, ebx ; VPITCH - uvWidth/2
  704. mov luvcounter, ebx ; luvcounter = XRes/4
  705. mov VDiff, ecx ; Store VDiff
  706. mov ecx, YPITCH ; Distance to the next V
  707. add ecx, ecx
  708. sub ecx, uvWidth
  709. mov VInDiff, ecx ; = YPITCH + YPITCH - uvWidth
  710. mov esi, pVPlaneIn ; Initialize input cursor
  711. mov edi, pVPlaneOut ; Initialize output cursor
  712. mov eax, pUPlaneIn ; Initialize input cursor
  713. mov ecx, inloopcnt
  714. ; Process all lines skipping just every other
  715. Rowlp2_NS:
  716. mov inloopcnt, ecx ; store update inloopcnt
  717. xor ebx, ebx
  718. mov edx, luvcounter ; init dx
  719. xor ecx, ecx
  720. Collpv1_NS:
  721. mov cl, BYTE PTR [eax] ; Fetch *PUtemp_IN
  722. inc edi ; Inc des by 1, PVtemp_OUT++
  723. mov bl, BYTE PTR [esi] ; Fetch *pVtemp_IN
  724. add eax,2 ; pUtemp+=2
  725. mov cl, gTAB_UVtbl8to7[ecx] ; cl = gTAB_UVtbl8to7[*pUtemp_IN]
  726. add esi,2 ; Inc source by 2,pVtemp+=2
  727. mov BYTE PTR [edi+167],cl; store in PUtemp_OUT
  728. mov bl, gTAB_UVtbl8to7[ebx] ; bl = gTAB_UVtbl8to7[*pVtemp_IN]
  729. mov BYTE PTR [edi-1],bl ; store in PVtemp_OUT
  730. xor ecx, ecx ; dummy op
  731. dec edx
  732. jg Collpv1_NS
  733. ; increment to beginning of next line then skip next input line
  734. add edi, VDiff ; Point to next output row
  735. mov edx,VInDiff ; Skip to next input row
  736. add esi,edx ;
  737. add eax,edx ;
  738. mov ecx, inloopcnt ; get inloopcnt
  739. ; test if have processed all lines yet
  740. dec ecx ; Process next line
  741. jne Rowlp2_NS ; if more to do loop
  742. Error:
  743. Cleanup:
  744. ; clean out local variables on stack
  745. pop ecx
  746. pop ebx
  747. pop ecx
  748. pop ebx
  749. pop ecx
  750. pop ebx
  751. pop ecx
  752. pop ebx
  753. pop ecx
  754. pop ebx
  755. pop ecx
  756. ;clear special seg registers, restore stack, pop saved registers
  757. ifndef WIN32
  758. xor ecx, ecx
  759. xor ebx, ebx
  760. mov es, cx
  761. mov fs, bx
  762. endif
  763. pop esi
  764. pop edi
  765. pop ebp
  766. ifdef WIN32
  767. ret
  768. else
  769. db 066h
  770. retf
  771. endif
  772. _AspectCorrect endp
  773. END