1; 2; Copyright (c) 2010 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 11 12%include "vpx_ports/x86_abi_support.asm" 13 14SECTION .text 15 16;void vpx_plane_add_noise_sse2(uint8_t *start, const int8_t *noise, 17; int blackclamp, int whiteclamp, 18; int width, int height, int pitch) 19global sym(vpx_plane_add_noise_sse2) PRIVATE 20sym(vpx_plane_add_noise_sse2): 21 push rbp 22 mov rbp, rsp 23 SHADOW_ARGS_TO_STACK 7 24 GET_GOT rbx 25 push rsi 26 push rdi 27 28 mov rdx, 0x01010101 29 mov rax, arg(2) 30 mul rdx 31 movq xmm3, rax 32 pshufd xmm3, xmm3, 0 ; xmm3 is 16 copies of char in blackclamp 33 34 mov rdx, 0x01010101 35 mov rax, arg(3) 36 mul rdx 37 movq xmm4, rax 38 pshufd xmm4, xmm4, 0 ; xmm4 is 16 copies of char in whiteclamp 39 40 movdqu xmm5, xmm3 ; both clamp = black clamp + white clamp 41 paddusb xmm5, xmm4 42 43.addnoise_loop: 44 call sym(LIBVPX_RAND) WRT_PLT 45 mov rcx, arg(1) ;noise 46 and rax, 0xff 47 add rcx, rax 48 49 mov rdi, rcx 50 movsxd rcx, dword arg(4) ;[Width] 51 mov rsi, arg(0) ;Pos 52 xor rax, rax 53 54.addnoise_nextset: 55 movdqu xmm1,[rsi+rax] ; get the source 56 57 psubusb xmm1, xmm3 ; subtract black clamp 58 paddusb xmm1, xmm5 ; add both clamp 59 psubusb xmm1, xmm4 ; subtract whiteclamp 60 61 movdqu xmm2,[rdi+rax] ; get the noise for this line 62 paddb xmm1,xmm2 ; add it in 63 movdqu [rsi+rax],xmm1 ; store the result 64 65 add rax,16 ; move to the next line 66 67 cmp rax, rcx 68 jl .addnoise_nextset 69 70 movsxd rax, dword arg(6) ; Pitch 71 add arg(0), rax ; Start += Pitch 72 sub dword arg(5), 1 ; Height -= 1 73 jg .addnoise_loop 74 75 ; begin epilog 76 pop rdi 77 pop rsi 78 RESTORE_GOT 79 UNSHADOW_ARGS 80 pop rbp 81 ret 82 83SECTION_RODATA 84align 16 85rd42: 86 times 8 dw 0x04 87four8s: 88 times 4 dd 8 89