/media/libvpx/vp8/encoder/arm/armv6/vp8_variance8x8_armv6.asm

http://github.com/zpao/v8monkey · Assembly · 101 lines · 55 code · 23 blank · 23 comment · 0 complexity · b4d46b33e1a06a552ff29963590ead42 MD5 · raw file

  1. ;
  2. ; Copyright (c) 2011 The WebM project authors. All Rights Reserved.
  3. ;
  4. ; Use of this source code is governed by a BSD-style license
  5. ; that can be found in the LICENSE file in the root of the source
  6. ; tree. An additional intellectual property rights grant can be found
  7. ; in the file PATENTS. All contributing project authors may
  8. ; be found in the AUTHORS file in the root of the source tree.
  9. ;
  10. EXPORT |vp8_variance8x8_armv6|
  11. ARM
  12. AREA ||.text||, CODE, READONLY, ALIGN=2
  13. ; r0 unsigned char *src_ptr
  14. ; r1 int source_stride
  15. ; r2 unsigned char *ref_ptr
  16. ; r3 int recon_stride
  17. ; stack unsigned int *sse
  18. |vp8_variance8x8_armv6| PROC
  19. push {r4-r10, lr}
  20. pld [r0, r1, lsl #0]
  21. pld [r2, r3, lsl #0]
  22. mov r12, #8 ; set loop counter to 8 (=block height)
  23. mov r4, #0 ; initialize sum = 0
  24. mov r5, #0 ; initialize sse = 0
  25. loop
  26. ; 1st 4 pixels
  27. ldr r6, [r0, #0x0] ; load 4 src pixels
  28. ldr r7, [r2, #0x0] ; load 4 ref pixels
  29. mov lr, #0 ; constant zero
  30. usub8 r8, r6, r7 ; calculate difference
  31. pld [r0, r1, lsl #1]
  32. sel r10, r8, lr ; select bytes with positive difference
  33. usub8 r9, r7, r6 ; calculate difference with reversed operands
  34. pld [r2, r3, lsl #1]
  35. sel r8, r9, lr ; select bytes with negative difference
  36. ; calculate partial sums
  37. usad8 r6, r10, lr ; calculate sum of positive differences
  38. usad8 r7, r8, lr ; calculate sum of negative differences
  39. orr r8, r8, r10 ; differences of all 4 pixels
  40. ; calculate total sum
  41. add r4, r4, r6 ; add positive differences to sum
  42. sub r4, r4, r7 ; substract negative differences from sum
  43. ; calculate sse
  44. uxtb16 r7, r8 ; byte (two pixels) to halfwords
  45. uxtb16 r10, r8, ror #8 ; another two pixels to halfwords
  46. smlad r5, r7, r7, r5 ; dual signed multiply, add and accumulate (1)
  47. ; 2nd 4 pixels
  48. ldr r6, [r0, #0x4] ; load 4 src pixels
  49. ldr r7, [r2, #0x4] ; load 4 ref pixels
  50. smlad r5, r10, r10, r5 ; dual signed multiply, add and accumulate (2)
  51. usub8 r8, r6, r7 ; calculate difference
  52. add r0, r0, r1 ; set src_ptr to next row
  53. sel r10, r8, lr ; select bytes with positive difference
  54. usub8 r9, r7, r6 ; calculate difference with reversed operands
  55. add r2, r2, r3 ; set dst_ptr to next row
  56. sel r8, r9, lr ; select bytes with negative difference
  57. ; calculate partial sums
  58. usad8 r6, r10, lr ; calculate sum of positive differences
  59. usad8 r7, r8, lr ; calculate sum of negative differences
  60. orr r8, r8, r10 ; differences of all 4 pixels
  61. ; calculate total sum
  62. add r4, r4, r6 ; add positive differences to sum
  63. sub r4, r4, r7 ; substract negative differences from sum
  64. ; calculate sse
  65. uxtb16 r7, r8 ; byte (two pixels) to halfwords
  66. uxtb16 r10, r8, ror #8 ; another two pixels to halfwords
  67. smlad r5, r7, r7, r5 ; dual signed multiply, add and accumulate (1)
  68. subs r12, r12, #1 ; next row
  69. smlad r5, r10, r10, r5 ; dual signed multiply, add and accumulate (2)
  70. bne loop
  71. ; return stuff
  72. ldr r8, [sp, #32] ; get address of sse
  73. mul r1, r4, r4 ; sum * sum
  74. str r5, [r8] ; store sse
  75. sub r0, r5, r1, ASR #6 ; return (sse - ((sum * sum) >> 6))
  76. pop {r4-r10, pc}
  77. ENDP
  78. END