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