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.

487 lines
22KB

  1. /*
  2. * simple_idct_arm.S
  3. * Copyright (C) 2002 Frederic 'dilb' Boulay
  4. *
  5. * Author: Frederic Boulay <dilb@handhelds.org>
  6. *
  7. * The function defined in this file is derived from the simple_idct function
  8. * from the libavcodec library part of the FFmpeg project.
  9. *
  10. * This file is part of FFmpeg.
  11. *
  12. * FFmpeg is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU Lesser General Public
  14. * License as published by the Free Software Foundation; either
  15. * version 2.1 of the License, or (at your option) any later version.
  16. *
  17. * FFmpeg is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with FFmpeg; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  25. */
  26. #include "asm.S"
  27. /* useful constants for the algorithm, they are save in __constant_ptr__ at */
  28. /* the end of the source code.*/
  29. #define W1 22725
  30. #define W2 21407
  31. #define W3 19266
  32. #define W4 16383
  33. #define W5 12873
  34. #define W6 8867
  35. #define W7 4520
  36. #define MASK_MSHW 0xFFFF0000
  37. /* offsets of the constants in the vector */
  38. #define offW1 0
  39. #define offW2 4
  40. #define offW3 8
  41. #define offW4 12
  42. #define offW5 16
  43. #define offW6 20
  44. #define offW7 24
  45. #define offMASK_MSHW 28
  46. #define ROW_SHIFT 11
  47. #define ROW_SHIFT2MSHW (16-11)
  48. #define COL_SHIFT 20
  49. #define ROW_SHIFTED_1 1024 /* 1<< (ROW_SHIFT-1) */
  50. #define COL_SHIFTED_1 524288 /* 1<< (COL_SHIFT-1) */
  51. .text
  52. function simple_idct_ARM, export=1
  53. @@ void simple_idct_ARM(int16_t *block)
  54. @@ save stack for reg needed (take all of them),
  55. @@ R0-R3 are scratch regs, so no need to save them, but R0 contains the pointer to block
  56. @@ so it must not be overwritten, if it is not saved!!
  57. @@ R12 is another scratch register, so it should not be saved too
  58. @@ save all registers
  59. stmfd sp!, {r4-r11, r14} @ R14 is also called LR
  60. @@ at this point, R0=block, other registers are free.
  61. add r14, r0, #112 @ R14=&block[8*7], better start from the last row, and decrease the value until row=0, i.e. R12=block.
  62. add r12, pc, #(__constant_ptr__-.-8) @ R12=__constant_ptr__, the vector containing the constants, probably not necessary to reserve a register for it
  63. @@ add 2 temporary variables in the stack: R0 and R14
  64. sub sp, sp, #8 @ allow 2 local variables
  65. str r0, [sp, #0] @ save block in sp[0]
  66. @@ stack status
  67. @@ sp+4 free
  68. @@ sp+0 R0 (block)
  69. @@ at this point, R0=block, R14=&block[56], R12=__const_ptr_, R1-R11 free
  70. __row_loop:
  71. @@ read the row and check if it is null, almost null, or not, according to strongarm specs, it is not necessary to optimize ldr accesses (i.e. split 32bits in 2 16bits words), at least it gives more usable registers :)
  72. ldr r1, [r14, #0] @ R1=(int32)(R12)[0]=ROWr32[0] (relative row cast to a 32b pointer)
  73. ldr r2, [r14, #4] @ R2=(int32)(R12)[1]=ROWr32[1]
  74. ldr r3, [r14, #8] @ R3=ROWr32[2]
  75. ldr r4, [r14, #12] @ R4=ROWr32[3]
  76. @@ check if the words are null, if all of them are null, then proceed with next row (branch __end_row_loop),
  77. @@ if ROWr16[0] is the only one not null, then proceed with this special case (branch __almost_empty_row)
  78. @@ else follow the complete algorithm.
  79. @@ at this point, R0=block, R14=&block[n], R12=__const_ptr_, R1=ROWr32[0], R2=ROWr32[1],
  80. @@ R3=ROWr32[2], R4=ROWr32[3], R5-R11 free
  81. orr r5, r4, r3 @ R5=R4 | R3
  82. orr r5, r5, r2 @ R5=R4 | R3 | R2
  83. orrs r6, r5, r1 @ Test R5 | R1 (the aim is to check if everything is null)
  84. beq __end_row_loop
  85. mov r7, r1, asr #16 @ R7=R1>>16=ROWr16[1] (evaluate it now, as it could be useful later)
  86. ldrsh r6, [r14, #0] @ R6=ROWr16[0]
  87. orrs r5, r5, r7 @ R5=R4 | R3 | R2 | R7
  88. beq __almost_empty_row
  89. __b_evaluation:
  90. @@ at this point, R0=block (temp), R1(free), R2=ROWr32[1], R3=ROWr32[2], R4=ROWr32[3],
  91. @@ R5=(temp), R6=ROWr16[0], R7=ROWr16[1], R8-R11 free,
  92. @@ R12=__const_ptr_, R14=&block[n]
  93. @@ to save some registers/calls, proceed with b0-b3 first, followed by a0-a3
  94. @@ MUL16(b0, W1, row[1]);
  95. @@ MUL16(b1, W3, row[1]);
  96. @@ MUL16(b2, W5, row[1]);
  97. @@ MUL16(b3, W7, row[1]);
  98. @@ MAC16(b0, W3, row[3]);
  99. @@ MAC16(b1, -W7, row[3]);
  100. @@ MAC16(b2, -W1, row[3]);
  101. @@ MAC16(b3, -W5, row[3]);
  102. ldr r8, [r12, #offW1] @ R8=W1
  103. mov r2, r2, asr #16 @ R2=ROWr16[3]
  104. mul r0, r8, r7 @ R0=W1*ROWr16[1]=b0 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
  105. ldr r9, [r12, #offW3] @ R9=W3
  106. ldr r10, [r12, #offW5] @ R10=W5
  107. mul r1, r9, r7 @ R1=W3*ROWr16[1]=b1 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
  108. ldr r11, [r12, #offW7] @ R11=W7
  109. mul r5, r10, r7 @ R5=W5*ROWr16[1]=b2 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
  110. mul r7, r11, r7 @ R7=W7*ROWr16[1]=b3 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
  111. teq r2, #0 @ if null avoid muls
  112. mlane r0, r9, r2, r0 @ R0+=W3*ROWr16[3]=b0 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
  113. rsbne r2, r2, #0 @ R2=-ROWr16[3]
  114. mlane r1, r11, r2, r1 @ R1-=W7*ROWr16[3]=b1 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
  115. mlane r5, r8, r2, r5 @ R5-=W1*ROWr16[3]=b2 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
  116. mlane r7, r10, r2, r7 @ R7-=W5*ROWr16[3]=b3 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
  117. @@ at this point, R0=b0, R1=b1, R2 (free), R3=ROWr32[2], R4=ROWr32[3],
  118. @@ R5=b2, R6=ROWr16[0], R7=b3, R8=W1, R9=W3, R10=W5, R11=W7,
  119. @@ R12=__const_ptr_, R14=&block[n]
  120. @@ temp = ((uint32_t*)row)[2] | ((uint32_t*)row)[3];
  121. @@ if (temp != 0) {}
  122. orrs r2, r3, r4 @ R2=ROWr32[2] | ROWr32[3]
  123. beq __end_b_evaluation
  124. @@ at this point, R0=b0, R1=b1, R2 (free), R3=ROWr32[2], R4=ROWr32[3],
  125. @@ R5=b2, R6=ROWr16[0], R7=b3, R8=W1, R9=W3, R10=W5, R11=W7,
  126. @@ R12=__const_ptr_, R14=&block[n]
  127. @@ MAC16(b0, W5, row[5]);
  128. @@ MAC16(b2, W7, row[5]);
  129. @@ MAC16(b3, W3, row[5]);
  130. @@ MAC16(b1, -W1, row[5]);
  131. @@ MAC16(b0, W7, row[7]);
  132. @@ MAC16(b2, W3, row[7]);
  133. @@ MAC16(b3, -W1, row[7]);
  134. @@ MAC16(b1, -W5, row[7]);
  135. mov r3, r3, asr #16 @ R3=ROWr16[5]
  136. teq r3, #0 @ if null avoid muls
  137. mlane r0, r10, r3, r0 @ R0+=W5*ROWr16[5]=b0
  138. mov r4, r4, asr #16 @ R4=ROWr16[7]
  139. mlane r5, r11, r3, r5 @ R5+=W7*ROWr16[5]=b2
  140. mlane r7, r9, r3, r7 @ R7+=W3*ROWr16[5]=b3
  141. rsbne r3, r3, #0 @ R3=-ROWr16[5]
  142. mlane r1, r8, r3, r1 @ R7-=W1*ROWr16[5]=b1
  143. @@ R3 is free now
  144. teq r4, #0 @ if null avoid muls
  145. mlane r0, r11, r4, r0 @ R0+=W7*ROWr16[7]=b0
  146. mlane r5, r9, r4, r5 @ R5+=W3*ROWr16[7]=b2
  147. rsbne r4, r4, #0 @ R4=-ROWr16[7]
  148. mlane r7, r8, r4, r7 @ R7-=W1*ROWr16[7]=b3
  149. mlane r1, r10, r4, r1 @ R1-=W5*ROWr16[7]=b1
  150. @@ R4 is free now
  151. __end_b_evaluation:
  152. @@ at this point, R0=b0, R1=b1, R2=ROWr32[2] | ROWr32[3] (tmp), R3 (free), R4 (free),
  153. @@ R5=b2, R6=ROWr16[0], R7=b3, R8 (free), R9 (free), R10 (free), R11 (free),
  154. @@ R12=__const_ptr_, R14=&block[n]
  155. __a_evaluation:
  156. @@ a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
  157. @@ a1 = a0 + W6 * row[2];
  158. @@ a2 = a0 - W6 * row[2];
  159. @@ a3 = a0 - W2 * row[2];
  160. @@ a0 = a0 + W2 * row[2];
  161. ldr r9, [r12, #offW4] @ R9=W4
  162. mul r6, r9, r6 @ R6=W4*ROWr16[0]
  163. ldr r10, [r12, #offW6] @ R10=W6
  164. ldrsh r4, [r14, #4] @ R4=ROWr16[2] (a3 not defined yet)
  165. add r6, r6, #ROW_SHIFTED_1 @ R6=W4*ROWr16[0] + 1<<(ROW_SHIFT-1) (a0)
  166. mul r11, r10, r4 @ R11=W6*ROWr16[2]
  167. ldr r8, [r12, #offW2] @ R8=W2
  168. sub r3, r6, r11 @ R3=a0-W6*ROWr16[2] (a2)
  169. @@ temp = ((uint32_t*)row)[2] | ((uint32_t*)row)[3];
  170. @@ if (temp != 0) {}
  171. teq r2, #0
  172. beq __end_bef_a_evaluation
  173. add r2, r6, r11 @ R2=a0+W6*ROWr16[2] (a1)
  174. mul r11, r8, r4 @ R11=W2*ROWr16[2]
  175. sub r4, r6, r11 @ R4=a0-W2*ROWr16[2] (a3)
  176. add r6, r6, r11 @ R6=a0+W2*ROWr16[2] (a0)
  177. @@ at this point, R0=b0, R1=b1, R2=a1, R3=a2, R4=a3,
  178. @@ R5=b2, R6=a0, R7=b3, R8=W2, R9=W4, R10=W6, R11 (free),
  179. @@ R12=__const_ptr_, R14=&block[n]
  180. @@ a0 += W4*row[4]
  181. @@ a1 -= W4*row[4]
  182. @@ a2 -= W4*row[4]
  183. @@ a3 += W4*row[4]
  184. ldrsh r11, [r14, #8] @ R11=ROWr16[4]
  185. teq r11, #0 @ if null avoid muls
  186. mulne r11, r9, r11 @ R11=W4*ROWr16[4]
  187. @@ R9 is free now
  188. ldrsh r9, [r14, #12] @ R9=ROWr16[6]
  189. addne r6, r6, r11 @ R6+=W4*ROWr16[4] (a0)
  190. subne r2, r2, r11 @ R2-=W4*ROWr16[4] (a1)
  191. subne r3, r3, r11 @ R3-=W4*ROWr16[4] (a2)
  192. addne r4, r4, r11 @ R4+=W4*ROWr16[4] (a3)
  193. @@ W6 alone is no more useful, save W2*ROWr16[6] in it instead
  194. teq r9, #0 @ if null avoid muls
  195. mulne r11, r10, r9 @ R11=W6*ROWr16[6]
  196. addne r6, r6, r11 @ R6+=W6*ROWr16[6] (a0)
  197. mulne r10, r8, r9 @ R10=W2*ROWr16[6]
  198. @@ a0 += W6*row[6];
  199. @@ a3 -= W6*row[6];
  200. @@ a1 -= W2*row[6];
  201. @@ a2 += W2*row[6];
  202. subne r4, r4, r11 @ R4-=W6*ROWr16[6] (a3)
  203. subne r2, r2, r10 @ R2-=W2*ROWr16[6] (a1)
  204. addne r3, r3, r10 @ R3+=W2*ROWr16[6] (a2)
  205. __end_a_evaluation:
  206. @@ at this point, R0=b0, R1=b1, R2=a1, R3=a2, R4=a3,
  207. @@ R5=b2, R6=a0, R7=b3, R8 (free), R9 (free), R10 (free), R11 (free),
  208. @@ R12=__const_ptr_, R14=&block[n]
  209. @@ row[0] = (a0 + b0) >> ROW_SHIFT;
  210. @@ row[1] = (a1 + b1) >> ROW_SHIFT;
  211. @@ row[2] = (a2 + b2) >> ROW_SHIFT;
  212. @@ row[3] = (a3 + b3) >> ROW_SHIFT;
  213. @@ row[4] = (a3 - b3) >> ROW_SHIFT;
  214. @@ row[5] = (a2 - b2) >> ROW_SHIFT;
  215. @@ row[6] = (a1 - b1) >> ROW_SHIFT;
  216. @@ row[7] = (a0 - b0) >> ROW_SHIFT;
  217. add r8, r6, r0 @ R8=a0+b0
  218. add r9, r2, r1 @ R9=a1+b1
  219. @@ put 2 16 bits half-words in a 32bits word
  220. @@ ROWr32[0]=ROWr16[0] | (ROWr16[1]<<16) (only Little Endian compliant then!!!)
  221. ldr r10, [r12, #offMASK_MSHW] @ R10=0xFFFF0000
  222. and r9, r10, r9, lsl #ROW_SHIFT2MSHW @ R9=0xFFFF0000 & ((a1+b1)<<5)
  223. mvn r11, r10 @ R11= NOT R10= 0x0000FFFF
  224. and r8, r11, r8, asr #ROW_SHIFT @ R8=0x0000FFFF & ((a0+b0)>>11)
  225. orr r8, r8, r9
  226. str r8, [r14, #0]
  227. add r8, r3, r5 @ R8=a2+b2
  228. add r9, r4, r7 @ R9=a3+b3
  229. and r9, r10, r9, lsl #ROW_SHIFT2MSHW @ R9=0xFFFF0000 & ((a3+b3)<<5)
  230. and r8, r11, r8, asr #ROW_SHIFT @ R8=0x0000FFFF & ((a2+b2)>>11)
  231. orr r8, r8, r9
  232. str r8, [r14, #4]
  233. sub r8, r4, r7 @ R8=a3-b3
  234. sub r9, r3, r5 @ R9=a2-b2
  235. and r9, r10, r9, lsl #ROW_SHIFT2MSHW @ R9=0xFFFF0000 & ((a2-b2)<<5)
  236. and r8, r11, r8, asr #ROW_SHIFT @ R8=0x0000FFFF & ((a3-b3)>>11)
  237. orr r8, r8, r9
  238. str r8, [r14, #8]
  239. sub r8, r2, r1 @ R8=a1-b1
  240. sub r9, r6, r0 @ R9=a0-b0
  241. and r9, r10, r9, lsl #ROW_SHIFT2MSHW @ R9=0xFFFF0000 & ((a0-b0)<<5)
  242. and r8, r11, r8, asr #ROW_SHIFT @ R8=0x0000FFFF & ((a1-b1)>>11)
  243. orr r8, r8, r9
  244. str r8, [r14, #12]
  245. bal __end_row_loop
  246. __almost_empty_row:
  247. @@ the row was empty, except ROWr16[0], now, management of this special case
  248. @@ at this point, R0=block, R14=&block[n], R12=__const_ptr_, R1=ROWr32[0], R2=ROWr32[1],
  249. @@ R3=ROWr32[2], R4=ROWr32[3], R5=(temp), R6=ROWr16[0], R7=ROWr16[1],
  250. @@ R8=0xFFFF (temp), R9-R11 free
  251. mov r8, #0x10000 @ R8=0xFFFF (2 steps needed!) it saves a ldr call (because of delay run).
  252. sub r8, r8, #1 @ R8 is now ready.
  253. and r5, r8, r6, lsl #3 @ R5=R8 & (R6<<3)= (ROWr16[0]<<3) & 0xFFFF
  254. orr r5, r5, r5, lsl #16 @ R5=R5 | (R5<<16)
  255. str r5, [r14, #0] @ R14[0]=ROWr32[0]=R5
  256. str r5, [r14, #4] @ R14[4]=ROWr32[1]=R5
  257. str r5, [r14, #8] @ R14[8]=ROWr32[2]=R5
  258. str r5, [r14, #12] @ R14[12]=ROWr32[3]=R5
  259. __end_row_loop:
  260. @@ at this point, R0-R11 (free)
  261. @@ R12=__const_ptr_, R14=&block[n]
  262. ldr r0, [sp, #0] @ R0=block
  263. teq r0, r14 @ compare current &block[8*n] to block, when block is reached, the loop is finished.
  264. sub r14, r14, #16
  265. bne __row_loop
  266. @@ at this point, R0=block, R1-R11 (free)
  267. @@ R12=__const_ptr_, R14=&block[n]
  268. add r14, r0, #14 @ R14=&block[7], better start from the last col, and decrease the value until col=0, i.e. R14=block.
  269. __col_loop:
  270. __b_evaluation2:
  271. @@ at this point, R0=block (temp), R1-R11 (free)
  272. @@ R12=__const_ptr_, R14=&block[n]
  273. @@ proceed with b0-b3 first, followed by a0-a3
  274. @@ MUL16(b0, W1, col[8x1]);
  275. @@ MUL16(b1, W3, col[8x1]);
  276. @@ MUL16(b2, W5, col[8x1]);
  277. @@ MUL16(b3, W7, col[8x1]);
  278. @@ MAC16(b0, W3, col[8x3]);
  279. @@ MAC16(b1, -W7, col[8x3]);
  280. @@ MAC16(b2, -W1, col[8x3]);
  281. @@ MAC16(b3, -W5, col[8x3]);
  282. ldr r8, [r12, #offW1] @ R8=W1
  283. ldrsh r7, [r14, #16]
  284. mul r0, r8, r7 @ R0=W1*ROWr16[1]=b0 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
  285. ldr r9, [r12, #offW3] @ R9=W3
  286. ldr r10, [r12, #offW5] @ R10=W5
  287. mul r1, r9, r7 @ R1=W3*ROWr16[1]=b1 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
  288. ldr r11, [r12, #offW7] @ R11=W7
  289. mul r5, r10, r7 @ R5=W5*ROWr16[1]=b2 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
  290. ldrsh r2, [r14, #48]
  291. mul r7, r11, r7 @ R7=W7*ROWr16[1]=b3 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
  292. teq r2, #0 @ if 0, then avoid muls
  293. mlane r0, r9, r2, r0 @ R0+=W3*ROWr16[3]=b0 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
  294. rsbne r2, r2, #0 @ R2=-ROWr16[3]
  295. mlane r1, r11, r2, r1 @ R1-=W7*ROWr16[3]=b1 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
  296. mlane r5, r8, r2, r5 @ R5-=W1*ROWr16[3]=b2 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
  297. mlane r7, r10, r2, r7 @ R7-=W5*ROWr16[3]=b3 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
  298. @@ at this point, R0=b0, R1=b1, R2 (free), R3 (free), R4 (free),
  299. @@ R5=b2, R6 (free), R7=b3, R8=W1, R9=W3, R10=W5, R11=W7,
  300. @@ R12=__const_ptr_, R14=&block[n]
  301. @@ MAC16(b0, W5, col[5x8]);
  302. @@ MAC16(b2, W7, col[5x8]);
  303. @@ MAC16(b3, W3, col[5x8]);
  304. @@ MAC16(b1, -W1, col[5x8]);
  305. @@ MAC16(b0, W7, col[7x8]);
  306. @@ MAC16(b2, W3, col[7x8]);
  307. @@ MAC16(b3, -W1, col[7x8]);
  308. @@ MAC16(b1, -W5, col[7x8]);
  309. ldrsh r3, [r14, #80] @ R3=COLr16[5x8]
  310. teq r3, #0 @ if 0 then avoid muls
  311. mlane r0, r10, r3, r0 @ R0+=W5*ROWr16[5x8]=b0
  312. mlane r5, r11, r3, r5 @ R5+=W7*ROWr16[5x8]=b2
  313. mlane r7, r9, r3, r7 @ R7+=W3*ROWr16[5x8]=b3
  314. rsbne r3, r3, #0 @ R3=-ROWr16[5x8]
  315. ldrsh r4, [r14, #112] @ R4=COLr16[7x8]
  316. mlane r1, r8, r3, r1 @ R7-=W1*ROWr16[5x8]=b1
  317. @@ R3 is free now
  318. teq r4, #0 @ if 0 then avoid muls
  319. mlane r0, r11, r4, r0 @ R0+=W7*ROWr16[7x8]=b0
  320. mlane r5, r9, r4, r5 @ R5+=W3*ROWr16[7x8]=b2
  321. rsbne r4, r4, #0 @ R4=-ROWr16[7x8]
  322. mlane r7, r8, r4, r7 @ R7-=W1*ROWr16[7x8]=b3
  323. mlane r1, r10, r4, r1 @ R1-=W5*ROWr16[7x8]=b1
  324. @@ R4 is free now
  325. __end_b_evaluation2:
  326. @@ at this point, R0=b0, R1=b1, R2 (free), R3 (free), R4 (free),
  327. @@ R5=b2, R6 (free), R7=b3, R8 (free), R9 (free), R10 (free), R11 (free),
  328. @@ R12=__const_ptr_, R14=&block[n]
  329. __a_evaluation2:
  330. @@ a0 = (W4 * col[8x0]) + (1 << (COL_SHIFT - 1));
  331. @@ a1 = a0 + W6 * row[2];
  332. @@ a2 = a0 - W6 * row[2];
  333. @@ a3 = a0 - W2 * row[2];
  334. @@ a0 = a0 + W2 * row[2];
  335. ldrsh r6, [r14, #0]
  336. ldr r9, [r12, #offW4] @ R9=W4
  337. mul r6, r9, r6 @ R6=W4*ROWr16[0]
  338. ldr r10, [r12, #offW6] @ R10=W6
  339. ldrsh r4, [r14, #32] @ R4=ROWr16[2] (a3 not defined yet)
  340. add r6, r6, #COL_SHIFTED_1 @ R6=W4*ROWr16[0] + 1<<(COL_SHIFT-1) (a0)
  341. mul r11, r10, r4 @ R11=W6*ROWr16[2]
  342. ldr r8, [r12, #offW2] @ R8=W2
  343. add r2, r6, r11 @ R2=a0+W6*ROWr16[2] (a1)
  344. sub r3, r6, r11 @ R3=a0-W6*ROWr16[2] (a2)
  345. mul r11, r8, r4 @ R11=W2*ROWr16[2]
  346. sub r4, r6, r11 @ R4=a0-W2*ROWr16[2] (a3)
  347. add r6, r6, r11 @ R6=a0+W2*ROWr16[2] (a0)
  348. @@ at this point, R0=b0, R1=b1, R2=a1, R3=a2, R4=a3,
  349. @@ R5=b2, R6=a0, R7=b3, R8=W2, R9=W4, R10=W6, R11 (free),
  350. @@ R12=__const_ptr_, R14=&block[n]
  351. @@ a0 += W4*row[4]
  352. @@ a1 -= W4*row[4]
  353. @@ a2 -= W4*row[4]
  354. @@ a3 += W4*row[4]
  355. ldrsh r11, [r14, #64] @ R11=ROWr16[4]
  356. teq r11, #0 @ if null avoid muls
  357. mulne r11, r9, r11 @ R11=W4*ROWr16[4]
  358. @@ R9 is free now
  359. addne r6, r6, r11 @ R6+=W4*ROWr16[4] (a0)
  360. subne r2, r2, r11 @ R2-=W4*ROWr16[4] (a1)
  361. subne r3, r3, r11 @ R3-=W4*ROWr16[4] (a2)
  362. ldrsh r9, [r14, #96] @ R9=ROWr16[6]
  363. addne r4, r4, r11 @ R4+=W4*ROWr16[4] (a3)
  364. @@ W6 alone is no more useful, save W2*ROWr16[6] in it instead
  365. teq r9, #0 @ if null avoid muls
  366. mulne r11, r10, r9 @ R11=W6*ROWr16[6]
  367. addne r6, r6, r11 @ R6+=W6*ROWr16[6] (a0)
  368. mulne r10, r8, r9 @ R10=W2*ROWr16[6]
  369. @@ a0 += W6*row[6];
  370. @@ a3 -= W6*row[6];
  371. @@ a1 -= W2*row[6];
  372. @@ a2 += W2*row[6];
  373. subne r4, r4, r11 @ R4-=W6*ROWr16[6] (a3)
  374. subne r2, r2, r10 @ R2-=W2*ROWr16[6] (a1)
  375. addne r3, r3, r10 @ R3+=W2*ROWr16[6] (a2)
  376. __end_a_evaluation2:
  377. @@ at this point, R0=b0, R1=b1, R2=a1, R3=a2, R4=a3,
  378. @@ R5=b2, R6=a0, R7=b3, R8 (free), R9 (free), R10 (free), R11 (free),
  379. @@ R12=__const_ptr_, R14=&block[n]
  380. @@ col[0 ] = ((a0 + b0) >> COL_SHIFT);
  381. @@ col[8 ] = ((a1 + b1) >> COL_SHIFT);
  382. @@ col[16] = ((a2 + b2) >> COL_SHIFT);
  383. @@ col[24] = ((a3 + b3) >> COL_SHIFT);
  384. @@ col[32] = ((a3 - b3) >> COL_SHIFT);
  385. @@ col[40] = ((a2 - b2) >> COL_SHIFT);
  386. @@ col[48] = ((a1 - b1) >> COL_SHIFT);
  387. @@ col[56] = ((a0 - b0) >> COL_SHIFT);
  388. @@@@@ no optimization here @@@@@
  389. add r8, r6, r0 @ R8=a0+b0
  390. add r9, r2, r1 @ R9=a1+b1
  391. mov r8, r8, asr #COL_SHIFT
  392. mov r9, r9, asr #COL_SHIFT
  393. strh r8, [r14, #0]
  394. strh r9, [r14, #16]
  395. add r8, r3, r5 @ R8=a2+b2
  396. add r9, r4, r7 @ R9=a3+b3
  397. mov r8, r8, asr #COL_SHIFT
  398. mov r9, r9, asr #COL_SHIFT
  399. strh r8, [r14, #32]
  400. strh r9, [r14, #48]
  401. sub r8, r4, r7 @ R8=a3-b3
  402. sub r9, r3, r5 @ R9=a2-b2
  403. mov r8, r8, asr #COL_SHIFT
  404. mov r9, r9, asr #COL_SHIFT
  405. strh r8, [r14, #64]
  406. strh r9, [r14, #80]
  407. sub r8, r2, r1 @ R8=a1-b1
  408. sub r9, r6, r0 @ R9=a0-b0
  409. mov r8, r8, asr #COL_SHIFT
  410. mov r9, r9, asr #COL_SHIFT
  411. strh r8, [r14, #96]
  412. strh r9, [r14, #112]
  413. __end_col_loop:
  414. @@ at this point, R0-R11 (free)
  415. @@ R12=__const_ptr_, R14=&block[n]
  416. ldr r0, [sp, #0] @ R0=block
  417. teq r0, r14 @ compare current &block[n] to block, when block is reached, the loop is finished.
  418. sub r14, r14, #2
  419. bne __col_loop
  420. __end_simple_idct_ARM:
  421. @@ restore registers to previous status!
  422. add sp, sp, #8 @@ the local variables!
  423. ldmfd sp!, {r4-r11, r15} @@ update PC with LR content.
  424. @@ kind of sub-function, here not to overload the common case.
  425. __end_bef_a_evaluation:
  426. add r2, r6, r11 @ R2=a0+W6*ROWr16[2] (a1)
  427. mul r11, r8, r4 @ R11=W2*ROWr16[2]
  428. sub r4, r6, r11 @ R4=a0-W2*ROWr16[2] (a3)
  429. add r6, r6, r11 @ R6=a0+W2*ROWr16[2] (a0)
  430. bal __end_a_evaluation
  431. __constant_ptr__: @@ see #defines at the beginning of the source code for values.
  432. .align
  433. .word W1
  434. .word W2
  435. .word W3
  436. .word W4
  437. .word W5
  438. .word W6
  439. .word W7
  440. .word MASK_MSHW