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.

481 lines
21KB

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