idct_mmx.asm
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:5k
源码类别:

Windows CE

开发平台:

C/C++

  1. ;*****************************************************************************
  2. ;*
  3. ;* This program is free software ; you can redistribute it and/or modify
  4. ;* it under the terms of the GNU General Public License as published by
  5. ;* the Free Software Foundation; either version 2 of the License, or
  6. ;* (at your option) any later version.
  7. ;*
  8. ;* This program is distributed in the hope that it will be useful,
  9. ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;* GNU General Public License for more details.
  12. ;*
  13. ;* You should have received a copy of the GNU General Public License
  14. ;* along with this program; if not, write to the Free Software
  15. ;* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  16. ;*
  17. ;* $Id: idct_mmx.asm 432 2005-12-28 16:39:13Z picard $
  18. ;*
  19. ;* The Core Pocket Media Player
  20. ;* Copyright (c) 2004-2005 Gabor Kovacs
  21. ;*
  22. ;*****************************************************************************
  23. ;******************
  24. ;*  NOT FINISHED  *
  25. ;******************
  26. BITS 32
  27. ROW_SHIFT equ 11
  28. COL_SHIFT equ 6
  29. SECTION .data
  30. ALIGN 16
  31. SECTION .text
  32. %macro cglobal 2
  33. %define %1 _%1@%2
  34. global %1
  35. %endmacro
  36. cglobal IDCT_Const8x8,16
  37. cglobal IDCT_Const4x4,16
  38. ;cglobal IDCT_Block8x8,16
  39. ;cglobal IDCT_Block8x4,16
  40. ; ecx:block
  41. %macro Row 1
  42. movq mm0,[ecx+%1*16]
  43. movq mm1,[ecx+%1*16+8]
  44. ; x0 x4 x3 x7 x1 x6 x2 x5
  45. ; x4' = W7 * x5 + W1 * x4;
  46. ; x5' = W7 * x4 - W1 * x5;
  47. ; x6' = W3 * x7 + W5 * x6;
  48. ; x7' = W3 * x6 - W5 * x7;
  49. ; x6' = x4 + x6;
  50. ; x4' = x4 - x6;
  51. ; x7' = x5 + x7;
  52. ; x5' = x5 - x7;
  53. ; x5' = (181 * (x4 + x5) + 128) >> 8;
  54. ; x4' = (181 * (x4 - x5) + 128) >> 8;
  55. ; x3' = W6 * x2 + W2 * x3;
  56. ; x2' = W6 * x3 - W2 * x2;
  57. ; x1 <<= 11;
  58. ; x0 <<= 11;
  59.    
  60. ; x1' = x0 + x1;
  61. ; x0' = x0 - x1;
  62. ; x3' = x1 + x3;
  63. ; x1' = x1 - x3;
  64. ; x2' = x0 + x2;
  65. ; x0' = x0 - x2;
  66. movq [ecx+%1*16],mm0
  67. movq [ecx+%1*16+8],mm1
  68. %endmacro
  69. ; ecx:block
  70. ; edi:dest   edx:dest pitch
  71. ; esi:src    eax:src pitch
  72. %macro Col4x4 2
  73. %endmacro
  74. %macro Col4x8 2
  75. %endmacro
  76. %if 0
  77. ALIGN 16
  78. IDCT_Block8x8:
  79. push esi
  80. push edi
  81. mov ecx,[esp+12] ;block
  82. mov edi,[esp+12+4] ;dst
  83. mov edx,[esp+12+8] ;dst pitch
  84. mov esi,[esp+12+12] ;src 
  85. mov eax,8 ;src pitch
  86. Row 0
  87. Row 1
  88. Row 2
  89. Row 3
  90. Row 4
  91. Row 5
  92. Row 6
  93. Row 7
  94. or esi,esi
  95. jne .Add
  96. Col4x8 0,0
  97. Col4x8 8,0
  98. pop edi
  99. pop esi 
  100. ret 16
  101. .Add:
  102. Col4x8 0,1
  103. Col4x8 8,1
  104. pop edi
  105. pop esi 
  106. ret 16
  107. ALIGN 16
  108. IDCT_Block8x4:
  109. push esi
  110. push edi
  111. mov ecx,[esp+12] ;src
  112. mov edi,[esp+12+4] ;dst
  113. mov edx,[esp+12+8] ;dst pitch
  114. mov esi,[esp+12+12] ;src 
  115. mov eax,8 ;src pitch
  116. Row 0
  117. Row 1
  118. Row 2
  119. Row 3
  120. or esi,esi
  121. jne .Add
  122. Col4x4 0,0
  123. Col4x4 8,0
  124. pop edi
  125. pop esi 
  126. ret 16
  127. .Add:
  128. Col4x4 0,1
  129. Col4x4 8,1
  130. pop edi
  131. pop esi 
  132. ret 16
  133. %endif
  134. ALIGN 16
  135. IDCT_Const8x8:
  136. push esi
  137. push edi
  138. mov ecx,[esp+12] ;v
  139. mov edi,[esp+12+4] ;dst
  140. mov edx,[esp+12+8] ;dst pitch
  141. mov esi,[esp+12+12] ;src
  142. mov eax,8 ;src pitch
  143. or ecx,ecx
  144. js .Sub
  145. .Add:
  146. movd mm7,ecx
  147. punpcklbw mm7,mm7
  148. punpcklwd mm7,mm7
  149. punpckldq mm7,mm7
  150. %rep 4
  151. movq mm0,[esi]
  152. movq mm1,[esi+eax]
  153. paddusb mm0,mm7
  154. lea esi,[esi+eax*2]
  155. paddusb mm1,mm7
  156. movq [edi],mm0
  157. movq [edi+edx],mm1
  158. lea edi,[edi+edx*2]
  159. %endrep
  160. pop edi
  161. pop esi 
  162. ret 16
  163. .Sub:
  164. neg ecx
  165. movd mm7,ecx
  166. punpcklbw mm7,mm7
  167. punpcklwd mm7,mm7
  168. punpckldq mm7,mm7
  169. %rep 4
  170. movq mm0,[esi]
  171. movq mm1,[esi+eax]
  172. psubusb mm0,mm7
  173. lea esi,[esi+eax*2]
  174. psubusb mm1,mm7
  175. movq [edi],mm0
  176. movq [edi+edx],mm1
  177. lea edi,[edi+edx*2]
  178. %endrep
  179. pop edi
  180. pop esi 
  181. ret 16
  182. ALIGN 16
  183. IDCT_Const4x4:
  184. push esi
  185. push edi
  186. mov ecx,[esp+12] ;v
  187. mov edi,[esp+12+4] ;dst
  188. mov edx,[esp+12+8] ;dst pitch
  189. mov esi,[esp+12+12] ;src
  190. mov eax,8 ;src pitch
  191. or ecx,ecx
  192. js .Sub
  193. .Add:
  194. movd mm7,ecx
  195. punpcklbw mm7,mm7
  196. punpcklwd mm7,mm7
  197. punpckldq mm7,mm7
  198. %rep 2
  199. movd mm0,[esi]
  200. movd mm1,[esi+eax]
  201. paddusb mm0,mm7
  202. lea esi,[esi+eax*2]
  203. paddusb mm1,mm7
  204. movd [edi],mm0
  205. movd [edi+edx],mm1
  206. lea edi,[edi+edx*2]
  207. %endrep
  208. pop edi
  209. pop esi 
  210. ret 16
  211. .Sub:
  212. neg ecx
  213. movd mm7,ecx
  214. punpcklbw mm7,mm7
  215. punpcklwd mm7,mm7
  216. punpckldq mm7,mm7
  217. %rep 2
  218. movd mm0,[esi]
  219. movd mm1,[esi+eax]
  220. psubusb mm0,mm7
  221. lea esi,[esi+eax*2]
  222. psubusb mm1,mm7
  223. movd [edi],mm0
  224. movd [edi+edx],mm1
  225. lea edi,[edi+edx*2]
  226. %endrep
  227. pop edi
  228. pop esi 
  229. ret 16