1
# Pure Data Packet mmx routine.
2
# Copyright (c) by Tom Schouten <pdp@zzz.kotnet.org>
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
.type pixel_gain_s16,@function
21
# gain is integer, shift count is down
22
# void pixel_gain_s16(int *buf, int nb_8pixel_vectors, short int gain[4], unsigned long long *shift)
31
movq (%edi), %mm6 # get shift vector
34
movq (%edi), %mm7 # get gain vector
36
movl 8(%ebp), %esi # input array
37
movl 12(%ebp), %ecx # pixel count
43
movq (%esi), %mm0 # load 4 pixels from memory
45
pmulhw %mm7, %mm1 # apply gain (s15.0) fixed point, high word
46
pmullw %mm7, %mm0 # low word
48
movq %mm0, %mm2 # copy
51
punpcklwd %mm1, %mm0 # unpack lsw components
52
punpckhwd %mm3, %mm2 # unpack msw components
54
psrad %mm6, %mm0 # apply signed shift
57
packssdw %mm2, %mm0 # pack result & saturate
58
movq %mm0, (%esi) # store result
61
addl $8, %esi # increment source pointer