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.

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