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.

504 lines
22KB

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