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

http://github.com/zpao/v8monkey · Assembly · 138 lines · 75 code · 33 blank · 30 comment · 0 complexity · 26baf35a55f59e5301de9c6d75dfc6b4 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_mse16x16_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. ;
  19. ;note: Based on vp8_variance16x16_armv6. In this function, sum is never used.
  20. ; So, we can remove this part of calculation.
  21. |vp8_mse16x16_armv6| PROC
  22. push {r4-r9, lr}
  23. pld [r0, r1, lsl #0]
  24. pld [r2, r3, lsl #0]
  25. mov r12, #16 ; set loop counter to 16 (=block height)
  26. mov r4, #0 ; initialize sse = 0
  27. loop
  28. ; 1st 4 pixels
  29. ldr r5, [r0, #0x0] ; load 4 src pixels
  30. ldr r6, [r2, #0x0] ; load 4 ref pixels
  31. mov lr, #0 ; constant zero
  32. usub8 r8, r5, r6 ; calculate difference
  33. pld [r0, r1, lsl #1]
  34. sel r7, r8, lr ; select bytes with positive difference
  35. usub8 r9, r6, r5 ; calculate difference with reversed operands
  36. pld [r2, r3, lsl #1]
  37. sel r8, r9, lr ; select bytes with negative difference
  38. ; calculate partial sums
  39. usad8 r5, r7, lr ; calculate sum of positive differences
  40. usad8 r6, r8, lr ; calculate sum of negative differences
  41. orr r8, r8, r7 ; differences of all 4 pixels
  42. ldr r5, [r0, #0x4] ; load 4 src pixels
  43. ; calculate sse
  44. uxtb16 r6, r8 ; byte (two pixels) to halfwords
  45. uxtb16 r7, r8, ror #8 ; another two pixels to halfwords
  46. smlad r4, r6, r6, r4 ; dual signed multiply, add and accumulate (1)
  47. ; 2nd 4 pixels
  48. ldr r6, [r2, #0x4] ; load 4 ref pixels
  49. smlad r4, r7, r7, r4 ; dual signed multiply, add and accumulate (2)
  50. usub8 r8, r5, r6 ; calculate difference
  51. sel r7, r8, lr ; select bytes with positive difference
  52. usub8 r9, r6, r5 ; calculate difference with reversed operands
  53. sel r8, r9, lr ; select bytes with negative difference
  54. ; calculate partial sums
  55. usad8 r5, r7, lr ; calculate sum of positive differences
  56. usad8 r6, r8, lr ; calculate sum of negative differences
  57. orr r8, r8, r7 ; differences of all 4 pixels
  58. ldr r5, [r0, #0x8] ; load 4 src pixels
  59. ; calculate sse
  60. uxtb16 r6, r8 ; byte (two pixels) to halfwords
  61. uxtb16 r7, r8, ror #8 ; another two pixels to halfwords
  62. smlad r4, r6, r6, r4 ; dual signed multiply, add and accumulate (1)
  63. ; 3rd 4 pixels
  64. ldr r6, [r2, #0x8] ; load 4 ref pixels
  65. smlad r4, r7, r7, r4 ; dual signed multiply, add and accumulate (2)
  66. usub8 r8, r5, r6 ; calculate difference
  67. sel r7, r8, lr ; select bytes with positive difference
  68. usub8 r9, r6, r5 ; calculate difference with reversed operands
  69. sel r8, r9, lr ; select bytes with negative difference
  70. ; calculate partial sums
  71. usad8 r5, r7, lr ; calculate sum of positive differences
  72. usad8 r6, r8, lr ; calculate sum of negative differences
  73. orr r8, r8, r7 ; differences of all 4 pixels
  74. ldr r5, [r0, #0xc] ; load 4 src pixels
  75. ; calculate sse
  76. uxtb16 r6, r8 ; byte (two pixels) to halfwords
  77. uxtb16 r7, r8, ror #8 ; another two pixels to halfwords
  78. smlad r4, r6, r6, r4 ; dual signed multiply, add and accumulate (1)
  79. ; 4th 4 pixels
  80. ldr r6, [r2, #0xc] ; load 4 ref pixels
  81. smlad r4, r7, r7, r4 ; dual signed multiply, add and accumulate (2)
  82. usub8 r8, r5, r6 ; calculate difference
  83. add r0, r0, r1 ; set src_ptr to next row
  84. sel r7, r8, lr ; select bytes with positive difference
  85. usub8 r9, r6, r5 ; calculate difference with reversed operands
  86. add r2, r2, r3 ; set dst_ptr to next row
  87. sel r8, r9, lr ; select bytes with negative difference
  88. ; calculate partial sums
  89. usad8 r5, r7, lr ; calculate sum of positive differences
  90. usad8 r6, r8, lr ; calculate sum of negative differences
  91. orr r8, r8, r7 ; differences of all 4 pixels
  92. subs r12, r12, #1 ; next row
  93. ; calculate sse
  94. uxtb16 r6, r8 ; byte (two pixels) to halfwords
  95. uxtb16 r7, r8, ror #8 ; another two pixels to halfwords
  96. smlad r4, r6, r6, r4 ; dual signed multiply, add and accumulate (1)
  97. smlad r4, r7, r7, r4 ; dual signed multiply, add and accumulate (2)
  98. bne loop
  99. ; return stuff
  100. ldr r1, [sp, #28] ; get address of sse
  101. mov r0, r4 ; return sse
  102. str r4, [r1] ; store sse
  103. pop {r4-r9, pc}
  104. ENDP
  105. END