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.

725 lines
36 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) 1996 Intel Corporation.
  10. ; All Rights Reserved.
  11. ;
  12. ;--------------------------------------------------------------------------------
  13. ;--------------------------------------------------------------------------------
  14. ;
  15. ; $Author: RMCKENZX $
  16. ; $Date: 03 Apr 1996 17:31:22 $
  17. ; $Archive: S:\h26x\src\dec\d3mbvriq.asv $
  18. ; $Header: S:\h26x\src\dec\d3mbvriq.asv 1.6 03 Apr 1996 17:31:22 RMCKENZX $
  19. ; $Log: S:\h26x\src\dec\d3mbvriq.asv $
  20. ;//
  21. ;// Rev 1.6 03 Apr 1996 17:31:22 RMCKENZX
  22. ;// Additional optimizations.
  23. ;//
  24. ;// Rev 1.5 01 Apr 1996 11:37:50 AGUPTA2
  25. ;// Moved the routine to IACODE1 segment.
  26. ;//
  27. ;// Rev 1.4 14 Mar 1996 14:21:56 AGUPTA2
  28. ;// Moved tables from mmxtable.c to this file. Added segment decls.
  29. ;//
  30. ;// Rev 1.3 13 Mar 1996 11:17:08 RMCKENZX
  31. ;// Added scaling of INTRA DC coefficient.
  32. ;//
  33. ;// Rev 1.2 12 Mar 1996 08:39:34 RMCKENZX
  34. ;// changed to fixed point scaling tables.
  35. ;//
  36. ;// Rev 1.0 27 Feb 1996 15:24:14 RMCKENZX
  37. ;// Initial revision.
  38. ;
  39. ;--------------------------------------------------------------------------------
  40. ;--------------------------------------------------------------------------------
  41. ;
  42. ; d3mbvriq.asm
  43. ;
  44. ; Description:
  45. ; This routine performs run length decoding and inverse quantization
  46. ; of transform coefficients for one block.
  47. ; MMx version.
  48. ;
  49. ; Routines:
  50. ; VLD_RLD_IQ_Block
  51. ;
  52. ; Inputs (dwords pushed onto stack by caller):
  53. ; lpBlockAction pointer to Block action stream for current block.
  54. ;
  55. ; lpSrc The input bitstream.
  56. ;
  57. ; lBitsInOut Number of bits already read.
  58. ;
  59. ; pIQ_INDEX Pointer to coefficients and indices.
  60. ;
  61. ; pN Pointer to number of coefficients read.
  62. ;
  63. ; Returns:
  64. ; total number of bits read (including number read
  65. ; prior to call). On error, returns 0.
  66. ;
  67. ;--------------------------------------------------------------------------------
  68. ;
  69. ; TABLES
  70. ; The structure of the MMx tables (DWORD entries) is:
  71. ; bits name description
  72. ; 31-16 level signed 16-bit quantized value
  73. ; 15 last 0 = more coef., 1 = last coef.
  74. ; 14-8 bits number of bits used by VLC
  75. ; 7-0 run number of preceeding 0s + 1
  76. ;
  77. ; special table values: (all signaled by run == 0)
  78. ; 0x00000000 escape code
  79. ; 0x80000000 illegal code
  80. ; 0xffffff00 major table miss
  81. ;
  82. ;
  83. ; ALGORITHM
  84. ; We use the following 4 cases to compute the reconstructed value
  85. ; depending on the sign of L=level and the parity of Q=quantizer:
  86. ;
  87. ; L pos L neg
  88. ; Q even 2QL+(Q-1) 2QL-(Q-1)
  89. ; Q odd 2QL+(Q) 2QL-(Q)
  90. ;
  91. ; The Q or Q-1 term is formed by subtracting 1 and then oring
  92. ; with 1. This leaves odd Qs unchanged, and decreases even Qs by 1.
  93. ; This is done in the function header and kept in mm3.
  94. ;
  95. ; The + or - on this term (moved to mm4) is gotten by using a mask
  96. ; in mm1 formed from the sign bit of L. This mask is exclusive or'd
  97. ; with the term and then subtracted from the result. When the mask is 0,
  98. ; this leaves the term unchanged. When the mask is -1, it first forms
  99. ; the one's complement, then changes it to the 2's complement.
  100. ;
  101. ;
  102. ; SCALING
  103. ; The scale factor is stored as a fixed point WORD. After multiplication
  104. ; by the scale and shifting , we have 8 fraction bits. Then a round
  105. ; bit is added in, and a final shift leaves 7 fraction bits.
  106. ;
  107. ;
  108. ; CLIPPING
  109. ; Clipping of the reconstructed coefficient to the range of -2048, ...
  110. ; +2047 is done for the (escape signalled) fixed length decodes. It is
  111. ; not needed for the variable length decodes as the most extreme level
  112. ; for any of the variable length coded events is +-12. Since the maximum
  113. ; quantizer is 31, this can generate at most a coefficient of +-775.
  114. ;
  115. ; Clipping is done by:
  116. ; 1. Adding (with SIGNED Saturation) TopClip (30720 or 0x7800)
  117. ; 2. Subtracting (with UNSIGNED Saturation) LowClip (28672 or 0x7000)
  118. ; 3. Adding MidClip (-2048 or 0xf800)
  119. ;
  120. ; since TopClip - LowClip + MidClip = 0, This will leave the coefficient
  121. ; unchanged unless:
  122. ; (1) the result of the first add is negative, or
  123. ; (2) saturation takes place.
  124. ;
  125. ; Since the maximum level is +-127, the most extreme coefficient (prior to
  126. ; clipping) is +-7905. Thus the result of the first add will always be
  127. ; positive.
  128. ;
  129. ; If the input value is 2047 or larger, the result of the first add will
  130. ; clip to 32767, then subtract to 4095, then add to +2047 as desired.
  131. ;
  132. ; If the input value is -2048 or smaller, the result of the first add
  133. ; will be 28672 or smaller (but at least 22815), hence the unsigned
  134. ; subtract will clip to 0. The final add will then yield -2048 as desired.
  135. ;
  136. ;--------------------------------------------------------------------------------
  137. ;
  138. ; Register Usage:
  139. ; eax = bitstream value
  140. ; ebx = lBitsInOut>>3 (byte offset into bitstream)
  141. ; cl = lBitsInOut&7 (bit offset into bitstream)
  142. ; dl = block type ([lpBlockAction])
  143. ; esi = bitstream source pointer (lpSrc)
  144. ; edi = coefficient destination pointer (pIQ_INDEX)
  145. ; ebp = coefficent counter (init to 0)
  146. ;
  147. ; mm0 = accumulator (initially level, finally coefficient*scale)
  148. ; mm1 = mask (0 when level positive, -1 when level negative)
  149. ; mm2 = 2Q 2*quantizer
  150. ; mm3 = term (see description above)
  151. ; mm4 = +- term (see description above)
  152. ; mm5 = rounding value
  153. ; mm6 = TopClip
  154. ; mm7 = LowClip
  155. ;
  156. ;--------------------------------------------------------------------------------
  157. .586
  158. .MODEL FLAT
  159. ; make all symbols case sensitive
  160. OPTION CASEMAP:NONE
  161. OPTION PROLOGUE:None
  162. OPTION EPILOGUE:None
  163. .xlist
  164. include iammx.inc
  165. .list
  166. IACODE1 SEGMENT PARA USE32 PUBLIC 'CODE'
  167. IACODE1 ENDS
  168. MMXDATA1 SEGMENT PARA USE32 PUBLIC 'DATA'
  169. MMXDATA1 ENDS
  170. MMXDATA1 SEGMENT
  171. ALIGN 8
  172. MMX_Scale LABEL DWORD
  173. DWORD 040000000H, 058c50000H, 0539f0000H, 04b420000H, 040000000H, 032490000H, 022a30000H, 011a80000H ; row 0
  174. DWORD 058c50000H, 07b210000H, 073fc0000H, 068620000H, 058c50000H, 045bf0000H, 0300b0000H, 0187e0000H ; row 1
  175. DWORD 0539f0000H, 073fc0000H, 06d410000H, 062540000H, 0539f0000H, 041b30000H, 02d410000H, 017120000H ; row 2
  176. DWORD 04b420000H, 068620000H, 062540000H, 0587e0000H, 04b420000H, 03b210000H, 028ba0000H, 014c30000H ; row 3
  177. DWORD 040000000H, 058c50000H, 0539f0000H, 04b420000H, 040000000H, 032490000H, 022a30000H, 011a80000H ; row 4
  178. DWORD 032490000H, 045bf0000H, 041b30000H, 03b210000H, 032490000H, 027820000H, 01b370000H, 00de00000H ; row 5
  179. DWORD 022a30000H, 0300b0000H, 02d410000H, 028ba0000H, 022a30000H, 01b370000H, 012bf0000H, 0098e0000H ; row 6
  180. DWORD 011a80000H, 0187e0000H, 017120000H, 014c30000H, 011a80000H, 00de00000H, 0098e0000H, 004df0000H ; row 7
  181. ALIGN 8
  182. MidClip DWORD 0f800f800h ; = Low
  183. ALIGN 4
  184. Round DWORD 00000200h
  185. TopClip DWORD 78007800h ; = max_pos - High
  186. LowClip DWORD 70007000h ; = TopClip + Low
  187. ALIGN 4
  188. MMX_TCOEFF_MAJOR LABEL DWORD
  189. DWORD 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 000000000H, 000000000H ; 0-7
  190. DWORD 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H ; 8-15
  191. DWORD 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H ; 16-23
  192. DWORD 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H, 0ffffff00H ; 24-31
  193. DWORD 000018809H, 0ffff8809H, 000018808H, 0ffff8808H, 000018807H, 0ffff8807H, 000018806H, 0ffff8806H ; 32-39
  194. DWORD 00001080dH, 0ffff080dH, 00001080cH, 0ffff080cH, 00001080bH, 0ffff080bH, 000040801H, 0fffc0801H ; 40-47
  195. DWORD 000018705H, 000018705H, 0ffff8705H, 0ffff8705H, 000018704H, 000018704H, 0ffff8704H, 0ffff8704H ; 48-55
  196. DWORD 000018703H, 000018703H, 0ffff8703H, 0ffff8703H, 000018702H, 000018702H, 0ffff8702H, 0ffff8702H ; 56-63
  197. DWORD 00001070aH, 00001070aH, 0ffff070aH, 0ffff070aH, 000010709H, 000010709H, 0ffff0709H, 0ffff0709H ; 64-71
  198. DWORD 000010708H, 000010708H, 0ffff0708H, 0ffff0708H, 000010707H, 000010707H, 0ffff0707H, 0ffff0707H ; 72-79
  199. DWORD 000020702H, 000020702H, 0fffe0702H, 0fffe0702H, 000030701H, 000030701H, 0fffd0701H, 0fffd0701H ; 80-87
  200. DWORD 000010606H, 000010606H, 000010606H, 000010606H, 0ffff0606H, 0ffff0606H, 0ffff0606H, 0ffff0606H ; 88-95
  201. DWORD 000010605H, 000010605H, 000010605H, 000010605H, 0ffff0605H, 0ffff0605H, 0ffff0605H, 0ffff0605H ; 96-103
  202. DWORD 000010604H, 000010604H, 000010604H, 000010604H, 0ffff0604H, 0ffff0604H, 0ffff0604H, 0ffff0604H ; 104-111
  203. DWORD 000018501H, 000018501H, 000018501H, 000018501H, 000018501H, 000018501H, 000018501H, 000018501H ; 112-119
  204. DWORD 0ffff8501H, 0ffff8501H, 0ffff8501H, 0ffff8501H, 0ffff8501H, 0ffff8501H, 0ffff8501H, 0ffff8501H ; 120-127
  205. DWORD 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H ; 128-135
  206. DWORD 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H ; 136-143
  207. DWORD 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H ; 144-151
  208. DWORD 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H, 000010301H ; 152-159
  209. DWORD 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H ; 160-167
  210. DWORD 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H ; 168-175
  211. DWORD 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H ; 176-183
  212. DWORD 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H, 0ffff0301H ; 184-191
  213. DWORD 000010402H, 000010402H, 000010402H, 000010402H, 000010402H, 000010402H, 000010402H, 000010402H ; 192-199
  214. DWORD 000010402H, 000010402H, 000010402H, 000010402H, 000010402H, 000010402H, 000010402H, 000010402H ; 200-207
  215. DWORD 0ffff0402H, 0ffff0402H, 0ffff0402H, 0ffff0402H, 0ffff0402H, 0ffff0402H, 0ffff0402H, 0ffff0402H ; 208-215
  216. DWORD 0ffff0402H, 0ffff0402H, 0ffff0402H, 0ffff0402H, 0ffff0402H, 0ffff0402H, 0ffff0402H, 0ffff0402H ; 216-223
  217. DWORD 000010503H, 000010503H, 000010503H, 000010503H, 000010503H, 000010503H, 000010503H, 000010503H ; 224-231
  218. DWORD 0ffff0503H, 0ffff0503H, 0ffff0503H, 0ffff0503H, 0ffff0503H, 0ffff0503H, 0ffff0503H, 0ffff0503H ; 232-239
  219. DWORD 000020501H, 000020501H, 000020501H, 000020501H, 000020501H, 000020501H, 000020501H, 000020501H ; 240-247
  220. DWORD 0fffe0501H, 0fffe0501H, 0fffe0501H, 0fffe0501H, 0fffe0501H, 0fffe0501H, 0fffe0501H, 0fffe0501H ; 248-255
  221. ALIGN 4
  222. MMX_TCOEFF_MINOR LABEL DWORD
  223. DWORD 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H ; 0-7 ILLEGAL CODES
  224. DWORD 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H ; 8-15 ILLEGAL CODES
  225. DWORD 000028c02H, 000028c02H, 0fffe8c02H, 0fffe8c02H, 000038c01H, 000038c01H, 0fffd8c01H, 0fffd8c01H ; 16-23
  226. DWORD 0000b0c01H, 0000b0c01H, 0fff50c01H, 0fff50c01H, 0000a0c01H, 0000a0c01H, 0fff60c01H, 0fff60c01H ; 24-31
  227. DWORD 000018b1dH, 000018b1dH, 000018b1dH, 000018b1dH, 0ffff8b1dH, 0ffff8b1dH, 0ffff8b1dH, 0ffff8b1dH ; 32-39
  228. DWORD 000018b1cH, 000018b1cH, 000018b1cH, 000018b1cH, 0ffff8b1cH, 0ffff8b1cH, 0ffff8b1cH, 0ffff8b1cH ; 40-47
  229. DWORD 000018b1bH, 000018b1bH, 000018b1bH, 000018b1bH, 0ffff8b1bH, 0ffff8b1bH, 0ffff8b1bH, 0ffff8b1bH ; 48-55
  230. DWORD 000018b1aH, 000018b1aH, 000018b1aH, 000018b1aH, 0ffff8b1aH, 0ffff8b1aH, 0ffff8b1aH, 0ffff8b1aH ; 56-63
  231. DWORD 000020b0aH, 000020b0aH, 000020b0aH, 000020b0aH, 0fffe0b0aH, 0fffe0b0aH, 0fffe0b0aH, 0fffe0b0aH ; 64-71
  232. DWORD 000020b09H, 000020b09H, 000020b09H, 000020b09H, 0fffe0b09H, 0fffe0b09H, 0fffe0b09H, 0fffe0b09H ; 72-79
  233. DWORD 000020b08H, 000020b08H, 000020b08H, 000020b08H, 0fffe0b08H, 0fffe0b08H, 0fffe0b08H, 0fffe0b08H ; 80-87
  234. DWORD 000020b07H, 000020b07H, 000020b07H, 000020b07H, 0fffe0b07H, 0fffe0b07H, 0fffe0b07H, 0fffe0b07H ; 88-95
  235. DWORD 000020b06H, 000020b06H, 000020b06H, 000020b06H, 0fffe0b06H, 0fffe0b06H, 0fffe0b06H, 0fffe0b06H ; 96-103
  236. DWORD 000030b04H, 000030b04H, 000030b04H, 000030b04H, 0fffd0b04H, 0fffd0b04H, 0fffd0b04H, 0fffd0b04H ; 104-111
  237. DWORD 000030b03H, 000030b03H, 000030b03H, 000030b03H, 0fffd0b03H, 0fffd0b03H, 0fffd0b03H, 0fffd0b03H ; 112-119
  238. DWORD 000040b02H, 000040b02H, 000040b02H, 000040b02H, 0fffc0b02H, 0fffc0b02H, 0fffc0b02H, 0fffc0b02H ; 120-127
  239. DWORD 0000c0c01H, 0000c0c01H, 0fff40c01H, 0fff40c01H, 000050c02H, 000050c02H, 0fffb0c02H, 0fffb0c02H ; 128-135
  240. DWORD 000010c18H, 000010c18H, 0ffff0c18H, 0ffff0c18H, 000010c19H, 000010c19H, 0ffff0c19H, 0ffff0c19H ; 136-143
  241. DWORD 000018c1eH, 000018c1eH, 0ffff8c1eH, 0ffff8c1eH, 000018c1fH, 000018c1fH, 0ffff8c1fH, 0ffff8c1fH ; 144-151
  242. DWORD 000018c20H, 000018c20H, 0ffff8c20H, 0ffff8c20H, 000018c21H, 000018c21H, 0ffff8c21H, 0ffff8c21H ; 152-159
  243. DWORD 000060d02H, 0fffa0d02H, 000040d03H, 0fffc0d03H, 000030d05H, 0fffd0d05H, 000030d06H, 0fffd0d06H ; 160-167
  244. DWORD 000030d07H, 0fffd0d07H, 000020d0bH, 0fffe0d0bH, 000010d1aH, 0ffff0d1aH, 000010d1bH, 0ffff0d1bH ; 168-175
  245. DWORD 000018d22H, 0ffff8d22H, 000018d23H, 0ffff8d23H, 000018d24H, 0ffff8d24H, 000018d25H, 0ffff8d25H ; 176-183
  246. DWORD 000018d26H, 0ffff8d26H, 000018d27H, 0ffff8d27H, 000018d28H, 0ffff8d28H, 000018d29H, 0ffff8d29H ; 184-191
  247. DWORD 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H ; 192-199 ILLEGAL CODES
  248. DWORD 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H ; 200-207 ILLEGAL CODES
  249. DWORD 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H ; 208-215 ILLEGAL CODES
  250. DWORD 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H ; 216-223 ILLEGAL CODES
  251. DWORD 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H ; 224-231 ILLEGAL CODES
  252. DWORD 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H ; 232-239 ILLEGAL CODES
  253. DWORD 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H ; 240-247 ILLEGAL CODES
  254. DWORD 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H, 080000000H ; 248-255 ILLEGAL CODES
  255. DWORD 000090b01H, 000090b01H, 000090b01H, 000090b01H, 0fff70b01H, 0fff70b01H, 0fff70b01H, 0fff70b01H ; 256-263
  256. DWORD 000080b01H, 000080b01H, 000080b01H, 000080b01H, 0fff80b01H, 0fff80b01H, 0fff80b01H, 0fff80b01H ; 264-271
  257. DWORD 000018a19H, 000018a19H, 000018a19H, 000018a19H, 000018a19H, 000018a19H, 000018a19H, 000018a19H ; 272-279
  258. DWORD 0ffff8a19H, 0ffff8a19H, 0ffff8a19H, 0ffff8a19H, 0ffff8a19H, 0ffff8a19H, 0ffff8a19H, 0ffff8a19H ; 280-287
  259. DWORD 000018a18H, 000018a18H, 000018a18H, 000018a18H, 000018a18H, 000018a18H, 000018a18H, 000018a18H ; 288-295
  260. DWORD 0ffff8a18H, 0ffff8a18H, 0ffff8a18H, 0ffff8a18H, 0ffff8a18H, 0ffff8a18H, 0ffff8a18H, 0ffff8a18H ; 296-303
  261. DWORD 000018a17H, 000018a17H, 000018a17H, 000018a17H, 000018a17H, 000018a17H, 000018a17H, 000018a17H ; 304-311
  262. DWORD 0ffff8a17H, 0ffff8a17H, 0ffff8a17H, 0ffff8a17H, 0ffff8a17H, 0ffff8a17H, 0ffff8a17H, 0ffff8a17H ; 312-319
  263. DWORD 000018a16H, 000018a16H, 000018a16H, 000018a16H, 000018a16H, 000018a16H, 000018a16H, 000018a16H ; 320-327
  264. DWORD 0ffff8a16H, 0ffff8a16H, 0ffff8a16H, 0ffff8a16H, 0ffff8a16H, 0ffff8a16H, 0ffff8a16H, 0ffff8a16H ; 328-335
  265. DWORD 000018a15H, 000018a15H, 000018a15H, 000018a15H, 000018a15H, 000018a15H, 000018a15H, 000018a15H ; 336-343
  266. DWORD 0ffff8a15H, 0ffff8a15H, 0ffff8a15H, 0ffff8a15H, 0ffff8a15H, 0ffff8a15H, 0ffff8a15H, 0ffff8a15H ; 344-351
  267. DWORD 000018a14H, 000018a14H, 000018a14H, 000018a14H, 000018a14H, 000018a14H, 000018a14H, 000018a14H ; 352-359
  268. DWORD 0ffff8a14H, 0ffff8a14H, 0ffff8a14H, 0ffff8a14H, 0ffff8a14H, 0ffff8a14H, 0ffff8a14H, 0ffff8a14H ; 360-367
  269. DWORD 000018a13H, 000018a13H, 000018a13H, 000018a13H, 000018a13H, 000018a13H, 000018a13H, 000018a13H ; 368-375
  270. DWORD 0ffff8a13H, 0ffff8a13H, 0ffff8a13H, 0ffff8a13H, 0ffff8a13H, 0ffff8a13H, 0ffff8a13H, 0ffff8a13H ; 376-383
  271. DWORD 000018a12H, 000018a12H, 000018a12H, 000018a12H, 000018a12H, 000018a12H, 000018a12H, 000018a12H ; 384-391
  272. DWORD 0ffff8a12H, 0ffff8a12H, 0ffff8a12H, 0ffff8a12H, 0ffff8a12H, 0ffff8a12H, 0ffff8a12H, 0ffff8a12H ; 392-399
  273. DWORD 000028a01H, 000028a01H, 000028a01H, 000028a01H, 000028a01H, 000028a01H, 000028a01H, 000028a01H ; 400-407
  274. DWORD 0fffe8a01H, 0fffe8a01H, 0fffe8a01H, 0fffe8a01H, 0fffe8a01H, 0fffe8a01H, 0fffe8a01H, 0fffe8a01H ; 408-415
  275. DWORD 000010a17H, 000010a17H, 000010a17H, 000010a17H, 000010a17H, 000010a17H, 000010a17H, 000010a17H ; 416-423
  276. DWORD 0ffff0a17H, 0ffff0a17H, 0ffff0a17H, 0ffff0a17H, 0ffff0a17H, 0ffff0a17H, 0ffff0a17H, 0ffff0a17H ; 424-431
  277. DWORD 000010a16H, 000010a16H, 000010a16H, 000010a16H, 000010a16H, 000010a16H, 000010a16H, 000010a16H ; 432-439
  278. DWORD 0ffff0a16H, 0ffff0a16H, 0ffff0a16H, 0ffff0a16H, 0ffff0a16H, 0ffff0a16H, 0ffff0a16H, 0ffff0a16H ; 440-447
  279. DWORD 000010a15H, 000010a15H, 000010a15H, 000010a15H, 000010a15H, 000010a15H, 000010a15H, 000010a15H ; 448-455
  280. DWORD 0ffff0a15H, 0ffff0a15H, 0ffff0a15H, 0ffff0a15H, 0ffff0a15H, 0ffff0a15H, 0ffff0a15H, 0ffff0a15H ; 456-463
  281. DWORD 000010a14H, 000010a14H, 000010a14H, 000010a14H, 000010a14H, 000010a14H, 000010a14H, 000010a14H ; 464-471
  282. DWORD 0ffff0a14H, 0ffff0a14H, 0ffff0a14H, 0ffff0a14H, 0ffff0a14H, 0ffff0a14H, 0ffff0a14H, 0ffff0a14H ; 472-479
  283. DWORD 000010a13H, 000010a13H, 000010a13H, 000010a13H, 000010a13H, 000010a13H, 000010a13H, 000010a13H ; 480-487
  284. DWORD 0ffff0a13H, 0ffff0a13H, 0ffff0a13H, 0ffff0a13H, 0ffff0a13H, 0ffff0a13H, 0ffff0a13H, 0ffff0a13H ; 488-495
  285. DWORD 000010a12H, 000010a12H, 000010a12H, 000010a12H, 000010a12H, 000010a12H, 000010a12H, 000010a12H ; 496-503
  286. DWORD 0ffff0a12H, 0ffff0a12H, 0ffff0a12H, 0ffff0a12H, 0ffff0a12H, 0ffff0a12H, 0ffff0a12H, 0ffff0a12H ; 504-511
  287. DWORD 000010a11H, 000010a11H, 000010a11H, 000010a11H, 000010a11H, 000010a11H, 000010a11H, 000010a11H ; 512-519
  288. DWORD 0ffff0a11H, 0ffff0a11H, 0ffff0a11H, 0ffff0a11H, 0ffff0a11H, 0ffff0a11H, 0ffff0a11H, 0ffff0a11H ; 520-527
  289. DWORD 000010a10H, 000010a10H, 000010a10H, 000010a10H, 000010a10H, 000010a10H, 000010a10H, 000010a10H ; 528-535
  290. DWORD 0ffff0a10H, 0ffff0a10H, 0ffff0a10H, 0ffff0a10H, 0ffff0a10H, 0ffff0a10H, 0ffff0a10H, 0ffff0a10H ; 536-543
  291. DWORD 000020a05H, 000020a05H, 000020a05H, 000020a05H, 000020a05H, 000020a05H, 000020a05H, 000020a05H ; 544-551
  292. DWORD 0fffe0a05H, 0fffe0a05H, 0fffe0a05H, 0fffe0a05H, 0fffe0a05H, 0fffe0a05H, 0fffe0a05H, 0fffe0a05H ; 552-559
  293. DWORD 000020a04H, 000020a04H, 000020a04H, 000020a04H, 000020a04H, 000020a04H, 000020a04H, 000020a04H ; 560-567
  294. DWORD 0fffe0a04H, 0fffe0a04H, 0fffe0a04H, 0fffe0a04H, 0fffe0a04H, 0fffe0a04H, 0fffe0a04H, 0fffe0a04H ; 568-575
  295. DWORD 000070a01H, 000070a01H, 000070a01H, 000070a01H, 000070a01H, 000070a01H, 000070a01H, 000070a01H ; 576-583
  296. DWORD 0fff90a01H, 0fff90a01H, 0fff90a01H, 0fff90a01H, 0fff90a01H, 0fff90a01H, 0fff90a01H, 0fff90a01H ; 584-591
  297. DWORD 000060a01H, 000060a01H, 000060a01H, 000060a01H, 000060a01H, 000060a01H, 000060a01H, 000060a01H ; 592-599
  298. DWORD 0fffa0a01H, 0fffa0a01H, 0fffa0a01H, 0fffa0a01H, 0fffa0a01H, 0fffa0a01H, 0fffa0a01H, 0fffa0a01H ; 600-607
  299. DWORD 000018911H, 000018911H, 000018911H, 000018911H, 000018911H, 000018911H, 000018911H, 000018911H ; 608-615
  300. DWORD 000018911H, 000018911H, 000018911H, 000018911H, 000018911H, 000018911H, 000018911H, 000018911H ; 616-623
  301. DWORD 0ffff8911H, 0ffff8911H, 0ffff8911H, 0ffff8911H, 0ffff8911H, 0ffff8911H, 0ffff8911H, 0ffff8911H ; 624-631
  302. DWORD 0ffff8911H, 0ffff8911H, 0ffff8911H, 0ffff8911H, 0ffff8911H, 0ffff8911H, 0ffff8911H, 0ffff8911H ; 632-639
  303. DWORD 000018910H, 000018910H, 000018910H, 000018910H, 000018910H, 000018910H, 000018910H, 000018910H ; 640-647
  304. DWORD 000018910H, 000018910H, 000018910H, 000018910H, 000018910H, 000018910H, 000018910H, 000018910H ; 648-655
  305. DWORD 0ffff8910H, 0ffff8910H, 0ffff8910H, 0ffff8910H, 0ffff8910H, 0ffff8910H, 0ffff8910H, 0ffff8910H ; 656-663
  306. DWORD 0ffff8910H, 0ffff8910H, 0ffff8910H, 0ffff8910H, 0ffff8910H, 0ffff8910H, 0ffff8910H, 0ffff8910H ; 664-671
  307. DWORD 00001890fH, 00001890fH, 00001890fH, 00001890fH, 00001890fH, 00001890fH, 00001890fH, 00001890fH ; 672-679
  308. DWORD 00001890fH, 00001890fH, 00001890fH, 00001890fH, 00001890fH, 00001890fH, 00001890fH, 00001890fH ; 680-687
  309. DWORD 0ffff890fH, 0ffff890fH, 0ffff890fH, 0ffff890fH, 0ffff890fH, 0ffff890fH, 0ffff890fH, 0ffff890fH ; 688-695
  310. DWORD 0ffff890fH, 0ffff890fH, 0ffff890fH, 0ffff890fH, 0ffff890fH, 0ffff890fH, 0ffff890fH, 0ffff890fH ; 696-703
  311. DWORD 00001890eH, 00001890eH, 00001890eH, 00001890eH, 00001890eH, 00001890eH, 00001890eH, 00001890eH ; 704-711
  312. DWORD 00001890eH, 00001890eH, 00001890eH, 00001890eH, 00001890eH, 00001890eH, 00001890eH, 00001890eH ; 712-719
  313. DWORD 0ffff890eH, 0ffff890eH, 0ffff890eH, 0ffff890eH, 0ffff890eH, 0ffff890eH, 0ffff890eH, 0ffff890eH ; 720-727
  314. DWORD 0ffff890eH, 0ffff890eH, 0ffff890eH, 0ffff890eH, 0ffff890eH, 0ffff890eH, 0ffff890eH, 0ffff890eH ; 728-735
  315. DWORD 00001890dH, 00001890dH, 00001890dH, 00001890dH, 00001890dH, 00001890dH, 00001890dH, 00001890dH ; 736-743
  316. DWORD 00001890dH, 00001890dH, 00001890dH, 00001890dH, 00001890dH, 00001890dH, 00001890dH, 00001890dH ; 744-751
  317. DWORD 0ffff890dH, 0ffff890dH, 0ffff890dH, 0ffff890dH, 0ffff890dH, 0ffff890dH, 0ffff890dH, 0ffff890dH ; 752-759
  318. DWORD 0ffff890dH, 0ffff890dH, 0ffff890dH, 0ffff890dH, 0ffff890dH, 0ffff890dH, 0ffff890dH, 0ffff890dH ; 760-767
  319. DWORD 00001890cH, 00001890cH, 00001890cH, 00001890cH, 00001890cH, 00001890cH, 00001890cH, 00001890cH ; 768-775
  320. DWORD 00001890cH, 00001890cH, 00001890cH, 00001890cH, 00001890cH, 00001890cH, 00001890cH, 00001890cH ; 776-783
  321. DWORD 0ffff890cH, 0ffff890cH, 0ffff890cH, 0ffff890cH, 0ffff890cH, 0ffff890cH, 0ffff890cH, 0ffff890cH ; 784-791
  322. DWORD 0ffff890cH, 0ffff890cH, 0ffff890cH, 0ffff890cH, 0ffff890cH, 0ffff890cH, 0ffff890cH, 0ffff890cH ; 792-799
  323. DWORD 00001890bH, 00001890bH, 00001890bH, 00001890bH, 00001890bH, 00001890bH, 00001890bH, 00001890bH ; 800-807
  324. DWORD 00001890bH, 00001890bH, 00001890bH, 00001890bH, 00001890bH, 00001890bH, 00001890bH, 00001890bH ; 808-815
  325. DWORD 0ffff890bH, 0ffff890bH, 0ffff890bH, 0ffff890bH, 0ffff890bH, 0ffff890bH, 0ffff890bH, 0ffff890bH ; 816-823
  326. DWORD 0ffff890bH, 0ffff890bH, 0ffff890bH, 0ffff890bH, 0ffff890bH, 0ffff890bH, 0ffff890bH, 0ffff890bH ; 824-831
  327. DWORD 00001890aH, 00001890aH, 00001890aH, 00001890aH, 00001890aH, 00001890aH, 00001890aH, 00001890aH ; 832-839
  328. DWORD 00001890aH, 00001890aH, 00001890aH, 00001890aH, 00001890aH, 00001890aH, 00001890aH, 00001890aH ; 840-847
  329. DWORD 0ffff890aH, 0ffff890aH, 0ffff890aH, 0ffff890aH, 0ffff890aH, 0ffff890aH, 0ffff890aH, 0ffff890aH ; 848-855
  330. DWORD 0ffff890aH, 0ffff890aH, 0ffff890aH, 0ffff890aH, 0ffff890aH, 0ffff890aH, 0ffff890aH, 0ffff890aH ; 856-863
  331. DWORD 00001090fH, 00001090fH, 00001090fH, 00001090fH, 00001090fH, 00001090fH, 00001090fH, 00001090fH ; 864-871
  332. DWORD 00001090fH, 00001090fH, 00001090fH, 00001090fH, 00001090fH, 00001090fH, 00001090fH, 00001090fH ; 872-879
  333. DWORD 0ffff090fH, 0ffff090fH, 0ffff090fH, 0ffff090fH, 0ffff090fH, 0ffff090fH, 0ffff090fH, 0ffff090fH ; 880-887
  334. DWORD 0ffff090fH, 0ffff090fH, 0ffff090fH, 0ffff090fH, 0ffff090fH, 0ffff090fH, 0ffff090fH, 0ffff090fH ; 888-895
  335. DWORD 00001090eH, 00001090eH, 00001090eH, 00001090eH, 00001090eH, 00001090eH, 00001090eH, 00001090eH ; 896-903
  336. DWORD 00001090eH, 00001090eH, 00001090eH, 00001090eH, 00001090eH, 00001090eH, 00001090eH, 00001090eH ; 904-911
  337. DWORD 0ffff090eH, 0ffff090eH, 0ffff090eH, 0ffff090eH, 0ffff090eH, 0ffff090eH, 0ffff090eH, 0ffff090eH ; 912-919
  338. DWORD 0ffff090eH, 0ffff090eH, 0ffff090eH, 0ffff090eH, 0ffff090eH, 0ffff090eH, 0ffff090eH, 0ffff090eH ; 920-927
  339. DWORD 000020903H, 000020903H, 000020903H, 000020903H, 000020903H, 000020903H, 000020903H, 000020903H ; 928-935
  340. DWORD 000020903H, 000020903H, 000020903H, 000020903H, 000020903H, 000020903H, 000020903H, 000020903H ; 936-943
  341. DWORD 0fffe0903H, 0fffe0903H, 0fffe0903H, 0fffe0903H, 0fffe0903H, 0fffe0903H, 0fffe0903H, 0fffe0903H ; 944-951
  342. DWORD 0fffe0903H, 0fffe0903H, 0fffe0903H, 0fffe0903H, 0fffe0903H, 0fffe0903H, 0fffe0903H, 0fffe0903H ; 952-959
  343. DWORD 000030902H, 000030902H, 000030902H, 000030902H, 000030902H, 000030902H, 000030902H, 000030902H ; 960-967
  344. DWORD 000030902H, 000030902H, 000030902H, 000030902H, 000030902H, 000030902H, 000030902H, 000030902H ; 968-975
  345. DWORD 0fffd0902H, 0fffd0902H, 0fffd0902H, 0fffd0902H, 0fffd0902H, 0fffd0902H, 0fffd0902H, 0fffd0902H ; 976-983
  346. DWORD 0fffd0902H, 0fffd0902H, 0fffd0902H, 0fffd0902H, 0fffd0902H, 0fffd0902H, 0fffd0902H, 0fffd0902H ; 984-991
  347. DWORD 000050901H, 000050901H, 000050901H, 000050901H, 000050901H, 000050901H, 000050901H, 000050901H ; 992-999
  348. DWORD 000050901H, 000050901H, 000050901H, 000050901H, 000050901H, 000050901H, 000050901H, 000050901H ; 1000-1007
  349. DWORD 0fffb0901H, 0fffb0901H, 0fffb0901H, 0fffb0901H, 0fffb0901H, 0fffb0901H, 0fffb0901H, 0fffb0901H ; 1008-1015
  350. DWORD 0fffb0901H, 0fffb0901H, 0fffb0901H, 0fffb0901H, 0fffb0901H, 0fffb0901H, 0fffb0901H, 0fffb0901H ; 1016-1023
  351. ALIGN 4
  352. TAB_ZZ_RUN LABEL DWORD
  353. DWORD 0, 1, 8, 16, 9, 2, 3, 10
  354. DWORD 17, 24, 32, 25, 18, 11, 4, 5
  355. DWORD 12, 19, 26, 33, 40, 48, 41, 34
  356. DWORD 27, 20, 13, 6, 7, 14, 21, 28
  357. DWORD 35, 42, 49, 56, 57, 50, 43, 36
  358. DWORD 29, 22, 15, 23, 30, 37, 44, 51
  359. DWORD 58, 59, 52, 45, 38, 31, 39, 46
  360. DWORD 53, 60, 61, 54, 47, 55, 62, 63
  361. MMXDATA1 ENDS
  362. ; global tables
  363. MajorTbl EQU MMX_TCOEFF_MAJOR
  364. MinorTbl EQU MMX_TCOEFF_MINOR
  365. RunTbl EQU TAB_ZZ_RUN
  366. Scale EQU MMX_Scale
  367. PITCH = 384
  368. IACODE1 SEGMENT
  369. MMX_VLD_RLD_IQ_Block PROC C
  370. ; Stack Use
  371. FRAMESIZE = 12 ; 12 bytes locals
  372. ; local variables
  373. lpN EQU esp+00 ; pointer to number of coef. decoded
  374. lBitsInOut EQU esp+04 ; bit offset
  375. lCumulativeRun EQU esp+08 ; cumulative run
  376. ; saved registers
  377. ; ebx esp+12
  378. ; edi esp+16
  379. ; esi esp+20
  380. ; ebp esp+24
  381. ; return address esp+28
  382. ; input parameters
  383. lpBlockAction EQU esp+32
  384. lpSrc EQU esp+36
  385. uBitsReadIn EQU esp+40
  386. pN EQU esp+44
  387. pIQ_INDEX EQU esp+48
  388. ; save registers
  389. push ebp
  390. push esi
  391. push edi
  392. push ebx
  393. sub esp, FRAMESIZE
  394. xor eax, eax ; zero eax for quantizer & coef. counter
  395. ;
  396. ; initialize
  397. ;
  398. movd mm5, [Round] ; mm5 = rounding value
  399. movd mm6, [TopClip] ; mm6 = TopClip
  400. movd mm7, [LowClip] ; mm7 = LowClip
  401. mov ebx, -1 ; beginning cumulative run value
  402. mov edx, [pN] ; fetch pointer to coefficient read
  403. mov [lpN], edx ; store pN pointer locally
  404. mov ecx, [uBitsReadIn] ; fetch bits read in
  405. mov [lCumulativeRun], ebx ; init cumulative run to -1
  406. mov ebx, ecx ; copy bits read to ebx
  407. mov [lBitsInOut], ecx ; store bits read locally
  408. mov edx, [lpBlockAction] ; fetch block action pointer
  409. and ecx, 7 ; mask the shift value for input
  410. mov esi, [lpSrc] ; fetch bitstream source pointer
  411. shr ebx, 3 ; compute offset for input
  412. mov al, [edx+3] ; fetch quantizer
  413. shl eax, 16 ; 2*quantizer to high order word
  414. mov dl, [edx] ; fetch block type (save it in dl)
  415. movd mm2, eax ; mm2 = quantizer (Q)
  416. sub eax, 10000h
  417. xor ebp, ebp ; got inputs, init coefficient counter
  418. or eax, 10000h
  419. cmp dl, 1 ; check for INTRA block type
  420. movd mm3, eax ; mm3 = Q if odd, else = Q-1
  421. paddw mm2, mm2 ; mm2 = 2*quantizer (2Q)
  422. mov edi, [pIQ_INDEX] ; fetch coefficient output pointer
  423. ja get_next_coefficient ; if type 2 or larger, no INTRADC
  424. ;
  425. ; Decode INTRADC
  426. ;
  427. ; uses dword load & bitswap to achieve big endian ordering.
  428. ; prior code prepares ebx, cl, and dl as follows:
  429. ; ebx = lBitsInOut>>3
  430. ; cl = lBitsInOut&7
  431. ; dl = BlockType (0=INTRA_DC, 1=INTRA, 2=INTER, etc.)
  432. ;
  433. mov eax, [esi+ebx] ; *** PROBABLE MALALIGNMENT ***
  434. inc ebp ; one coefficient decoded
  435. bswap eax ; big endian order
  436. ; *** NOT PAIRABLE ***
  437. shl eax, cl ; left justify bitstream buffer
  438. ; *** NOT PAIRABLE ***
  439. ; *** 4 CYCLES ***
  440. shr eax, 17 ; top 11 bits to bits 14-04
  441. mov ecx, [lBitsInOut] ; ecx = lBitsInOut
  442. and eax, 07f80h ; mask to get scaled coeff.
  443. add ecx, 8 ; bits used += 8 for INTRADC
  444. cmp eax, 07f80h ; check for 11111111 codeword
  445. jne @f
  446. mov eax, 04000h ; 11111111 decodes to 400h = 1024
  447. @@:
  448. mov [lBitsInOut], ecx ; update bits used
  449. xor ebx, ebx
  450. mov [lCumulativeRun], ebx ; save total run (starts with zero)
  451. mov [edi], eax ; save decoded DC coefficient
  452. mov [edi+4], ebx ; save 0 index
  453. mov ebx, ecx ; ebx = lBitsInOut
  454. shr ebx, 3 ; offset for input
  455. add edi, 8 ; update coefficient pointer
  456. ; check for last
  457. test dl, dl ; check for INTRA-DC (block type=0)
  458. jz finish ; if only the INTRADC present
  459. ;
  460. ; Get Next Coefficient
  461. ;
  462. ; prior codes prepares ebx and ecx as follows:
  463. ; ebx = lBitsInOut>>3
  464. ; ecx = lBitsInOut
  465. ;
  466. get_next_coefficient:
  467. ; use dword load & bitswap to achieve big endian ordering
  468. mov eax, [esi+ebx] ; *** PROBABLE MALALIGNMENT ***
  469. and ecx, 7 ; shift value
  470. bswap eax ; big endian order
  471. ; *** NOT PAIRABLE ***
  472. shl eax, cl ; left justify buffer
  473. ; *** NOT PAIRABLE ***
  474. ; *** 4 CYCLES ***
  475. ; do table lookups
  476. mov ebx, eax ; ebx for major table
  477. mov ecx, eax ; ecx for minor table
  478. shr ebx, 24 ; major table lookup
  479. shr ecx, 17 ; minor table lookup (with garbage)
  480. and ecx, 0ffch ; mask off garbage for minor table
  481. mov edx, [MajorTbl+4*ebx] ; get the major table value
  482. cmp dl, 0 ; run != 0 signals major table hit
  483. jne @f ; if hit major
  484. test edx, edx ; escape code's value is 0
  485. jz escape_code ; handle escape by major table.
  486. mov edx, [MinorTbl+ecx] ; else use minor table
  487. ;
  488. ; Input is edx = Table Value.
  489. ; See function header for the meaning of its fields.
  490. ; Now we decode the event, extracting the run, value, last.
  491. ;
  492. @@:
  493. cmp dl, 0 ; test for invalid code (run == 0)
  494. je error
  495. movd mm1, edx ; mm0 = table value
  496. ; (level = bits 31-16)
  497. movq mm0, mm1
  498. psrad mm1, 31 ; dword mask = -1|0 for L neg|pos
  499. pmullw mm0, mm2 ; L *= 2Q
  500. mov ecx, edx ; codeword to ecx to get run
  501. movq mm4, mm3 ; Q or Q-1
  502. and ecx, 0ffh ; run for this coefficient
  503. pxor mm4, mm1 ; 1s complement if L negative
  504. mov ebx, [lCumulativeRun] ; ebx = old total run
  505. psubw mm4, mm1 ; 2s complement if L negative
  506. add ebx, ecx ; ebx = new cumulative run
  507. paddw mm0, mm4 ; L +-== Q
  508. cmp ebx, 03fh ; check run for bitstream error
  509. jg error
  510. mov [lCumulativeRun], ebx ; update the cumulative run
  511. mov ebx, [RunTbl+4*ebx] ; ebx = index of the current coefficient
  512. mov [edi+4], ebx ; save coefficient's index
  513. add edi, 8 ; increment coefficient pointer
  514. movd mm4, [Scale+4*ebx] ; get normalized scale factor
  515. shr edx, 8 ; last & bits to bottom
  516. pmaddwd mm0, mm4 ; multiply by normalized scale factor
  517. mov ecx, [lBitsInOut] ; ecx = old number of bits used
  518. mov eax, edx ; codeword to eax to get bits
  519. inc ebp ; increment number of coefficients read
  520. and eax, 07fh ; bits used for this coefficient
  521. add ecx, eax ; ecx = new total bits used
  522. paddd mm0, mm5 ; add rounding bit
  523. mov ebx, ecx ; ebx = lBitsInOut
  524. psrad mm0, 10 ; shift to get 7 fraction bits rounded
  525. shr ebx, 3 ; offset for bitstream load
  526. mov [lBitsInOut], ecx ; update number of bits used
  527. movd [edi-8], mm0 ; save coefficient's signed, scaled value
  528. cmp dl, 080h ; check last bit
  529. jb get_next_coefficient
  530. finish:
  531. pop ecx ; lpN = pointer to number of coeffients
  532. pop eax ; lBitsInOut = total bits used
  533. pop edx ; lCumulativeRun
  534. pop ebx
  535. mov [ecx], ebp ; store number of coefficients read
  536. pop edi
  537. pop esi
  538. pop ebp
  539. ret
  540. ;
  541. ; Input is eax = bitstream.
  542. ; See the H.263 spec for the meaning of its fields.
  543. ; Now we decode the event, extracting the run, value, last.
  544. ;
  545. escape_code:
  546. test eax, 0001fc00h ; test for invalid codes
  547. jz error
  548. movd mm0, eax ; mm0 = table value
  549. ; (level = bits 17-10)
  550. mov ecx, eax ; preserve codeword in eax
  551. pslld mm0, 14 ; move up to dword boundary
  552. ; (level = bits 31-24)
  553. movq mm1, mm0 ; mm1 = mask
  554. psraw mm0, 8 ; sign extend level
  555. psrad mm1, 31 ; dword mask = -1|0 for L neg|pos
  556. pmullw mm0, mm2 ; L *= 2Q
  557. shr ecx, 18 ; run to bottom
  558. movq mm4, mm3 ; Q or Q-1
  559. mov ebx, [lCumulativeRun] ; ebx = old total run
  560. pxor mm4, mm1 ; 1s complement if L negative
  561. and ecx, 3fh ; mask off bottom 6 bits for run
  562. psubw mm4, mm1 ; 2s complement if L negative
  563. inc ebx ; old run ++
  564. paddw mm0, mm4 ; L +-== Q
  565. add ebx, ecx ; ebx = new cumulative run
  566. mov ecx, [lBitsInOut] ; ebx = number of bits used
  567. cmp ebx, 03fh ; check run for bitstream error
  568. ja error
  569. mov [lCumulativeRun], ebx ; update the cumulative run
  570. paddsw mm0, mm6 ; add max_pos - High
  571. mov ebx, [RunTbl+4*ebx] ; ebx = index of the current coefficient
  572. psubusw mm0, mm7 ; sub max_pos - High + Low
  573. paddw mm0, [MidClip] ; add Low
  574. movd mm4, [Scale+4*ebx] ; fetch normalized scale factor
  575. pmaddwd mm0, mm4 ; multiply by normalized scale factor
  576. add ecx, 22 ; escape code uses 22 bits
  577. mov [edi+4], ebx ; save coefficient's index
  578. add edi, 8 ; increment coefficient pointer
  579. inc ebp ; increment number of coefficients read
  580. mov ebx, ecx ; ebx = lBitsInOut
  581. shr ebx, 3 ; offset for bitstream load
  582. paddd mm0, mm5 ; add rounding bit
  583. mov [lBitsInOut], ecx ; update number of bits used
  584. psrad mm0, 10 ; shift to get 7 fraction bits rounded
  585. ; *** 1 cycle load penalty delay ***
  586. movd [edi-8], mm0 ; save coefficient's signed, scaled value
  587. test eax, 01000000h ; check last bit
  588. jz get_next_coefficient
  589. jmp finish
  590. error:
  591. pop ecx ; lpN = pointer to number of coeffients
  592. pop eax ; lBitsInOut = total bits used
  593. pop edx ; lCumulativeRun
  594. xor eax, eax ; zero bits used indicates ERROR
  595. pop ebx
  596. pop edi
  597. pop esi
  598. pop ebp
  599. ret
  600. ; 11111111112222222222333333333344444444445555555555666666666677777777778
  601. ;12345678901234567890123456789012345678901234567890123456789012345678901234567890
  602. ;--------------------------------------------------------------------------------
  603. MMX_VLD_RLD_IQ_Block ENDP
  604. IACODE1 ENDS
  605. END