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.

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