annotate i386/motion_est_mmx.c @ 5877:aea495619138 libavcodec

fix predictor initialization for adpcm-ima encoder not to lose first sample in block in adpcm-ima decoder Patch by Timofei V. Bondarenko: tim ¡ò ipi, ac, ru Original thread: [FFmpeg-devel] [PATCH] adpcm-ima-wav header and codec Date: 10/15/2007 05:55 PM
author benoit
date Tue, 06 Nov 2007 13:08:04 +0000
parents 470601203f44
children 2aa536e36c89
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
1 /*
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
2 * MMX optimized motion estimation
429
718a22dc121f license/copyright change
glantau
parents: 330
diff changeset
3 * Copyright (c) 2001 Fabrice Bellard.
1739
07a484280a82 copyright year update of the files i touched and remembered, things look annoyingly unmaintained otherwise
michael
parents: 1708
diff changeset
4 * Copyright (c) 2002-2004 Michael Niedermayer
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
5 *
5214
470601203f44 Group all copyright and author notices together.
diego
parents: 5010
diff changeset
6 * mostly by Michael Niedermayer <michaelni@gmx.at>
470601203f44 Group all copyright and author notices together.
diego
parents: 5010
diff changeset
7 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3576
diff changeset
8 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3576
diff changeset
9 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3576
diff changeset
10 * FFmpeg is free software; you can redistribute it and/or
429
718a22dc121f license/copyright change
glantau
parents: 330
diff changeset
11 * modify it under the terms of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 330
diff changeset
12 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3576
diff changeset
13 * version 2.1 of the License, or (at your option) any later version.
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
14 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3576
diff changeset
15 * FFmpeg is distributed in the hope that it will be useful,
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
429
718a22dc121f license/copyright change
glantau
parents: 330
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
718a22dc121f license/copyright change
glantau
parents: 330
diff changeset
18 * Lesser General Public License for more details.
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
19 *
429
718a22dc121f license/copyright change
glantau
parents: 330
diff changeset
20 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3576
diff changeset
21 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2979
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
23 */
5010
d5ba514e3f4a Add libavcodec to compiler include flags in order to simplify header
diego
parents: 4982
diff changeset
24 #include "dsputil.h"
3398
e0927bc44a10 Move REG_* macros from libavcodec/i386/mmx.h to libavutil/x86_cpu.h
lucabe
parents: 3036
diff changeset
25 #include "x86_cpu.h"
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
26
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
27 static const __attribute__ ((aligned(8))) uint64_t round_tab[3]={
1569
1f8d1e1173d8 Fixes GCC 3.3.2 warnings patch by (Panagiotis Issaris <takis at lumumba dot luc dot ac dot be>)
michael
parents: 1455
diff changeset
28 0x0000000000000000ULL,
1f8d1e1173d8 Fixes GCC 3.3.2 warnings patch by (Panagiotis Issaris <takis at lumumba dot luc dot ac dot be>)
michael
parents: 1455
diff changeset
29 0x0001000100010001ULL,
1f8d1e1173d8 Fixes GCC 3.3.2 warnings patch by (Panagiotis Issaris <takis at lumumba dot luc dot ac dot be>)
michael
parents: 1455
diff changeset
30 0x0002000200020002ULL,
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
31 };
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
32
1845
3054613980a8 attribute used patch by (mitya at school dot ioffe dot ru (Dmitry Baryshkov))
michael
parents: 1739
diff changeset
33 static attribute_used __attribute__ ((aligned(8))) uint64_t bone= 0x0101010101010101LL;
330
54d86f074a4b rounding bugfix
michaelni
parents: 294
diff changeset
34
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
35 static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
36 {
2293
15cfba1b97b5 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents: 1845
diff changeset
37 long len= -(stride*h);
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
38 asm volatile(
3576
f7125bf10892 Support for MacIntel, last part: balign directives
gpoirier
parents: 3398
diff changeset
39 ASMALIGN(4)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
40 "1: \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
41 "movq (%1, %%"REG_a"), %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
42 "movq (%2, %%"REG_a"), %%mm2 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
43 "movq (%2, %%"REG_a"), %%mm4 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
44 "add %3, %%"REG_a" \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
45 "psubusb %%mm0, %%mm2 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
46 "psubusb %%mm4, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
47 "movq (%1, %%"REG_a"), %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
48 "movq (%2, %%"REG_a"), %%mm3 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
49 "movq (%2, %%"REG_a"), %%mm5 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
50 "psubusb %%mm1, %%mm3 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
51 "psubusb %%mm5, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
52 "por %%mm2, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
53 "por %%mm1, %%mm3 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
54 "movq %%mm0, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
55 "movq %%mm3, %%mm2 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
56 "punpcklbw %%mm7, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
57 "punpckhbw %%mm7, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
58 "punpcklbw %%mm7, %%mm3 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
59 "punpckhbw %%mm7, %%mm2 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
60 "paddw %%mm1, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
61 "paddw %%mm3, %%mm2 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
62 "paddw %%mm2, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
63 "paddw %%mm0, %%mm6 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
64 "add %3, %%"REG_a" \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
65 " js 1b \n\t"
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
66 : "+a" (len)
2293
15cfba1b97b5 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents: 1845
diff changeset
67 : "r" (blk1 - len), "r" (blk2 - len), "r" ((long)stride)
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
68 );
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
69 }
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
70
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
71 static inline void sad8_1_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
72 {
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
73 asm volatile(
3576
f7125bf10892 Support for MacIntel, last part: balign directives
gpoirier
parents: 3398
diff changeset
74 ASMALIGN(4)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
75 "1: \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
76 "movq (%1), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
77 "movq (%1, %3), %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
78 "psadbw (%2), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
79 "psadbw (%2, %3), %%mm1 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
80 "paddw %%mm0, %%mm6 \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
81 "paddw %%mm1, %%mm6 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
82 "lea (%1,%3,2), %1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
83 "lea (%2,%3,2), %2 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
84 "sub $2, %0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
85 " jg 1b \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
86 : "+r" (h), "+r" (blk1), "+r" (blk2)
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
87 : "r" ((long)stride)
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
88 );
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
89 }
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
90
4981
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
91 static int sad16_sse2(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
92 {
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
93 int ret;
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
94 asm volatile(
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
95 "pxor %%xmm6, %%xmm6 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
96 ASMALIGN(4)
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
97 "1: \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
98 "movdqu (%1), %%xmm0 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
99 "movdqu (%1, %3), %%xmm1 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
100 "psadbw (%2), %%xmm0 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
101 "psadbw (%2, %3), %%xmm1 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
102 "paddw %%xmm0, %%xmm6 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
103 "paddw %%xmm1, %%xmm6 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
104 "lea (%1,%3,2), %1 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
105 "lea (%2,%3,2), %2 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
106 "sub $2, %0 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
107 " jg 1b \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
108 : "+r" (h), "+r" (blk1), "+r" (blk2)
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
109 : "r" ((long)stride)
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
110 );
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
111 asm volatile(
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
112 "movhlps %%xmm6, %%xmm0 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
113 "paddw %%xmm0, %%xmm6 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
114 "movd %%xmm6, %0 \n\t"
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
115 : "=r"(ret)
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
116 );
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
117 return ret;
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
118 }
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
119
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
120 static inline void sad8_x2a_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
121 {
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
122 asm volatile(
3576
f7125bf10892 Support for MacIntel, last part: balign directives
gpoirier
parents: 3398
diff changeset
123 ASMALIGN(4)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
124 "1: \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
125 "movq (%1), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
126 "movq (%1, %3), %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
127 "pavgb 1(%1), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
128 "pavgb 1(%1, %3), %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
129 "psadbw (%2), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
130 "psadbw (%2, %3), %%mm1 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
131 "paddw %%mm0, %%mm6 \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
132 "paddw %%mm1, %%mm6 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
133 "lea (%1,%3,2), %1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
134 "lea (%2,%3,2), %2 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
135 "sub $2, %0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
136 " jg 1b \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
137 : "+r" (h), "+r" (blk1), "+r" (blk2)
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
138 : "r" ((long)stride)
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
139 );
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
140 }
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
141
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
142 static inline void sad8_y2a_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
143 {
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
144 asm volatile(
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
145 "movq (%1), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
146 "add %3, %1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
147 ASMALIGN(4)
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
148 "1: \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
149 "movq (%1), %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
150 "movq (%1, %3), %%mm2 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
151 "pavgb %%mm1, %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
152 "pavgb %%mm2, %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
153 "psadbw (%2), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
154 "psadbw (%2, %3), %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
155 "paddw %%mm0, %%mm6 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
156 "paddw %%mm1, %%mm6 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
157 "movq %%mm2, %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
158 "lea (%1,%3,2), %1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
159 "lea (%2,%3,2), %2 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
160 "sub $2, %0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
161 " jg 1b \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
162 : "+r" (h), "+r" (blk1), "+r" (blk2)
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
163 : "r" ((long)stride)
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
164 );
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
165 }
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
166
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
167 static inline void sad8_4_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
168 {
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
169 asm volatile(
4974
a2e489e40ea3 tweak mmx2 sad.
lorenm
parents: 4197
diff changeset
170 "movq "MANGLE(bone)", %%mm5 \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
171 "movq (%1), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
172 "pavgb 1(%1), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
173 "add %3, %1 \n\t"
3576
f7125bf10892 Support for MacIntel, last part: balign directives
gpoirier
parents: 3398
diff changeset
174 ASMALIGN(4)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
175 "1: \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
176 "movq (%1), %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
177 "movq (%1,%3), %%mm2 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
178 "pavgb 1(%1), %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
179 "pavgb 1(%1,%3), %%mm2 \n\t"
4974
a2e489e40ea3 tweak mmx2 sad.
lorenm
parents: 4197
diff changeset
180 "psubusb %%mm5, %%mm1 \n\t"
a2e489e40ea3 tweak mmx2 sad.
lorenm
parents: 4197
diff changeset
181 "pavgb %%mm1, %%mm0 \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
182 "pavgb %%mm2, %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
183 "psadbw (%2), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
184 "psadbw (%2,%3), %%mm1 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
185 "paddw %%mm0, %%mm6 \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
186 "paddw %%mm1, %%mm6 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
187 "movq %%mm2, %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
188 "lea (%1,%3,2), %1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
189 "lea (%2,%3,2), %2 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
190 "sub $2, %0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
191 " jg 1b \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
192 : "+r" (h), "+r" (blk1), "+r" (blk2)
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
193 : "r" ((long)stride)
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
194 );
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
195 }
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
196
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
197 static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int stride, int h)
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
198 {
2293
15cfba1b97b5 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents: 1845
diff changeset
199 long len= -(stride*h);
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
200 asm volatile(
3576
f7125bf10892 Support for MacIntel, last part: balign directives
gpoirier
parents: 3398
diff changeset
201 ASMALIGN(4)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
202 "1: \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
203 "movq (%1, %%"REG_a"), %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
204 "movq (%2, %%"REG_a"), %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
205 "movq (%1, %%"REG_a"), %%mm2 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
206 "movq (%2, %%"REG_a"), %%mm3 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
207 "punpcklbw %%mm7, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
208 "punpcklbw %%mm7, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
209 "punpckhbw %%mm7, %%mm2 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
210 "punpckhbw %%mm7, %%mm3 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
211 "paddw %%mm0, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
212 "paddw %%mm2, %%mm3 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
213 "movq (%3, %%"REG_a"), %%mm4 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
214 "movq (%3, %%"REG_a"), %%mm2 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
215 "paddw %%mm5, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
216 "paddw %%mm5, %%mm3 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
217 "psrlw $1, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
218 "psrlw $1, %%mm3 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
219 "packuswb %%mm3, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
220 "psubusb %%mm1, %%mm4 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
221 "psubusb %%mm2, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
222 "por %%mm4, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
223 "movq %%mm1, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
224 "punpcklbw %%mm7, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
225 "punpckhbw %%mm7, %%mm1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
226 "paddw %%mm1, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
227 "paddw %%mm0, %%mm6 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
228 "add %4, %%"REG_a" \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
229 " js 1b \n\t"
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
230 : "+a" (len)
2293
15cfba1b97b5 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents: 1845
diff changeset
231 : "r" (blk1a - len), "r" (blk1b -len), "r" (blk2 - len), "r" ((long)stride)
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
232 );
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
233 }
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
234
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
235 static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
236 {
2293
15cfba1b97b5 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents: 1845
diff changeset
237 long len= -(stride*h);
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
238 asm volatile(
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
239 "movq (%1, %%"REG_a"), %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
240 "movq 1(%1, %%"REG_a"), %%mm2 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
241 "movq %%mm0, %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
242 "movq %%mm2, %%mm3 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
243 "punpcklbw %%mm7, %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
244 "punpckhbw %%mm7, %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
245 "punpcklbw %%mm7, %%mm2 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
246 "punpckhbw %%mm7, %%mm3 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
247 "paddw %%mm2, %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
248 "paddw %%mm3, %%mm1 \n\t"
3576
f7125bf10892 Support for MacIntel, last part: balign directives
gpoirier
parents: 3398
diff changeset
249 ASMALIGN(4)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
250 "1: \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
251 "movq (%2, %%"REG_a"), %%mm2 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
252 "movq 1(%2, %%"REG_a"), %%mm4 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
253 "movq %%mm2, %%mm3 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
254 "movq %%mm4, %%mm5 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
255 "punpcklbw %%mm7, %%mm2 \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
256 "punpckhbw %%mm7, %%mm3 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
257 "punpcklbw %%mm7, %%mm4 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
258 "punpckhbw %%mm7, %%mm5 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
259 "paddw %%mm4, %%mm2 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
260 "paddw %%mm5, %%mm3 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
261 "movq 16+"MANGLE(round_tab)", %%mm5 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
262 "paddw %%mm2, %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
263 "paddw %%mm3, %%mm1 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
264 "paddw %%mm5, %%mm0 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
265 "paddw %%mm5, %%mm1 \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
266 "movq (%3, %%"REG_a"), %%mm4 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
267 "movq (%3, %%"REG_a"), %%mm5 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
268 "psrlw $2, %%mm0 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
269 "psrlw $2, %%mm1 \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
270 "packuswb %%mm1, %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
271 "psubusb %%mm0, %%mm4 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
272 "psubusb %%mm5, %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
273 "por %%mm4, %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
274 "movq %%mm0, %%mm4 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
275 "punpcklbw %%mm7, %%mm0 \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
276 "punpckhbw %%mm7, %%mm4 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
277 "paddw %%mm0, %%mm6 \n\t"
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
278 "paddw %%mm4, %%mm6 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
279 "movq %%mm2, %%mm0 \n\t"
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
280 "movq %%mm3, %%mm1 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
281 "add %4, %%"REG_a" \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
282 " js 1b \n\t"
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
283 : "+a" (len)
2293
15cfba1b97b5 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64 patch by (Aurelien Jacobs <aurel at gnuage dot org>)
michael
parents: 1845
diff changeset
284 : "r" (blk1 - len), "r" (blk1 -len + stride), "r" (blk2 - len), "r" ((long)stride)
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
285 );
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
286 }
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
287
1057
bb5de8a59da8 * static,const,compiler warning cleanup
kabi
parents: 936
diff changeset
288 static inline int sum_mmx(void)
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
289 {
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
290 int ret;
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
291 asm volatile(
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
292 "movq %%mm6, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
293 "psrlq $32, %%mm6 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
294 "paddw %%mm0, %%mm6 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
295 "movq %%mm6, %%mm0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
296 "psrlq $16, %%mm6 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
297 "paddw %%mm0, %%mm6 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
298 "movd %%mm6, %0 \n\t"
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
299 : "=r" (ret)
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
300 );
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
301 return ret&0xFFFF;
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
302 }
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
303
1057
bb5de8a59da8 * static,const,compiler warning cleanup
kabi
parents: 936
diff changeset
304 static inline int sum_mmx2(void)
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
305 {
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
306 int ret;
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
307 asm volatile(
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
308 "movd %%mm6, %0 \n\t"
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
309 : "=r" (ret)
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
310 );
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
311 return ret;
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
312 }
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
313
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
314 static inline void sad8_x2a_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
315 {
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
316 sad8_2_mmx(blk1, blk1+1, blk2, stride, h);
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
317 }
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
318 static inline void sad8_y2a_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
319 {
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
320 sad8_2_mmx(blk1, blk1+stride, blk2, stride, h);
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
321 }
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
322
900
52c26a143399 100l (sad8x8_x2 had params in wrong order)
michaelni
parents: 429
diff changeset
323
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
324 #define PIX_SAD(suf)\
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
325 static int sad8_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
326 {\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
327 assert(h==8);\
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
328 asm volatile("pxor %%mm7, %%mm7 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
329 "pxor %%mm6, %%mm6 \n\t":);\
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
330 \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
331 sad8_1_ ## suf(blk1, blk2, stride, 8);\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
332 \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
333 return sum_ ## suf();\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
334 }\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
335 static int sad8_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
336 {\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
337 assert(h==8);\
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
338 asm volatile("pxor %%mm7, %%mm7 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
339 "pxor %%mm6, %%mm6 \n\t"\
4982
6135d67c7f86 10l, r8991 broke mmx1 sad
lorenm
parents: 4981
diff changeset
340 "movq %0, %%mm5 \n\t"\
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
341 :: "m"(round_tab[1]) \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
342 );\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
343 \
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
344 sad8_x2a_ ## suf(blk1, blk2, stride, 8);\
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
345 \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
346 return sum_ ## suf();\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
347 }\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
348 \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
349 static int sad8_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
350 {\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
351 assert(h==8);\
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
352 asm volatile("pxor %%mm7, %%mm7 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
353 "pxor %%mm6, %%mm6 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
354 "movq %0, %%mm5 \n\t"\
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
355 :: "m"(round_tab[1]) \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
356 );\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
357 \
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
358 sad8_y2a_ ## suf(blk1, blk2, stride, 8);\
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
359 \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
360 return sum_ ## suf();\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
361 }\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
362 \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
363 static int sad8_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
364 {\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
365 assert(h==8);\
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
366 asm volatile("pxor %%mm7, %%mm7 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
367 "pxor %%mm6, %%mm6 \n\t"\
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
368 ::);\
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
369 \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
370 sad8_4_ ## suf(blk1, blk2, stride, 8);\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
371 \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
372 return sum_ ## suf();\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
373 }\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
374 \
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
375 static int sad16_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
376 {\
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
377 asm volatile("pxor %%mm7, %%mm7 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
378 "pxor %%mm6, %%mm6 \n\t":);\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
379 \
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
380 sad8_1_ ## suf(blk1 , blk2 , stride, h);\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
381 sad8_1_ ## suf(blk1+8, blk2+8, stride, h);\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
382 \
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
383 return sum_ ## suf();\
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
384 }\
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
385 static int sad16_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
386 {\
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
387 asm volatile("pxor %%mm7, %%mm7 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
388 "pxor %%mm6, %%mm6 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
389 "movq %0, %%mm5 \n\t"\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
390 :: "m"(round_tab[1]) \
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
391 );\
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
392 \
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
393 sad8_x2a_ ## suf(blk1 , blk2 , stride, h);\
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
394 sad8_x2a_ ## suf(blk1+8, blk2+8, stride, h);\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
395 \
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
396 return sum_ ## suf();\
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
397 }\
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
398 static int sad16_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
399 {\
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
400 asm volatile("pxor %%mm7, %%mm7 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
401 "pxor %%mm6, %%mm6 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
402 "movq %0, %%mm5 \n\t"\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
403 :: "m"(round_tab[1]) \
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
404 );\
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
405 \
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
406 sad8_y2a_ ## suf(blk1 , blk2 , stride, h);\
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
407 sad8_y2a_ ## suf(blk1+8, blk2+8, stride, h);\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
408 \
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
409 return sum_ ## suf();\
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
410 }\
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
411 static int sad16_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
412 {\
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
413 asm volatile("pxor %%mm7, %%mm7 \n\t"\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
414 "pxor %%mm6, %%mm6 \n\t"\
4980
800a543a2513 tweak mmx2 sad.
lorenm
parents: 4974
diff changeset
415 ::);\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
416 \
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
417 sad8_4_ ## suf(blk1 , blk2 , stride, h);\
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
418 sad8_4_ ## suf(blk1+8, blk2+8, stride, h);\
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
419 \
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
420 return sum_ ## suf();\
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
421 }\
72
3049d6d452a3 suppressed nasm dependancy - rewrote forward DCT and motion estimation code
glantau
parents:
diff changeset
422
294
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
423 PIX_SAD(mmx)
944632089814 4MV motion estimation (not finished yet)
michaelni
parents: 72
diff changeset
424 PIX_SAD(mmx2)
1057
bb5de8a59da8 * static,const,compiler warning cleanup
kabi
parents: 936
diff changeset
425
1092
f59c3f66363b MpegEncContext.(i)dct_* -> DspContext.(i)dct_*
michaelni
parents: 1065
diff changeset
426 void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx)
1057
bb5de8a59da8 * static,const,compiler warning cleanup
kabi
parents: 936
diff changeset
427 {
4197
bbe0bc387a19 revert bad checkin
mru
parents: 4196
diff changeset
428 if (mm_flags & MM_MMX) {
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
429 c->pix_abs[0][0] = sad16_mmx;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
430 c->pix_abs[0][1] = sad16_x2_mmx;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
431 c->pix_abs[0][2] = sad16_y2_mmx;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
432 c->pix_abs[0][3] = sad16_xy2_mmx;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
433 c->pix_abs[1][0] = sad8_mmx;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
434 c->pix_abs[1][1] = sad8_x2_mmx;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
435 c->pix_abs[1][2] = sad8_y2_mmx;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
436 c->pix_abs[1][3] = sad8_xy2_mmx;
1057
bb5de8a59da8 * static,const,compiler warning cleanup
kabi
parents: 936
diff changeset
437
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
438 c->sad[0]= sad16_mmx;
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
439 c->sad[1]= sad8_mmx;
1057
bb5de8a59da8 * static,const,compiler warning cleanup
kabi
parents: 936
diff changeset
440 }
4197
bbe0bc387a19 revert bad checkin
mru
parents: 4196
diff changeset
441 if (mm_flags & MM_MMXEXT) {
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
442 c->pix_abs[0][0] = sad16_mmx2;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
443 c->pix_abs[1][0] = sad8_mmx2;
1057
bb5de8a59da8 * static,const,compiler warning cleanup
kabi
parents: 936
diff changeset
444
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
445 c->sad[0]= sad16_mmx2;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
446 c->sad[1]= sad8_mmx2;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2293
diff changeset
447
1092
f59c3f66363b MpegEncContext.(i)dct_* -> DspContext.(i)dct_*
michaelni
parents: 1065
diff changeset
448 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
449 c->pix_abs[0][1] = sad16_x2_mmx2;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
450 c->pix_abs[0][2] = sad16_y2_mmx2;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
451 c->pix_abs[0][3] = sad16_xy2_mmx2;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
452 c->pix_abs[1][1] = sad8_x2_mmx2;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
453 c->pix_abs[1][2] = sad8_y2_mmx2;
dea5b2946999 interlaced motion estimation
michael
parents: 1569
diff changeset
454 c->pix_abs[1][3] = sad8_xy2_mmx2;
1092
f59c3f66363b MpegEncContext.(i)dct_* -> DspContext.(i)dct_*
michaelni
parents: 1065
diff changeset
455 }
1057
bb5de8a59da8 * static,const,compiler warning cleanup
kabi
parents: 936
diff changeset
456 }
4981
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
457 if ((mm_flags & MM_SSE2) && !(mm_flags & MM_3DNOW)) {
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
458 c->sad[0]= sad16_sse2;
0b392661ce83 sse2 version of fullpel sad.
lorenm
parents: 4980
diff changeset
459 }
1057
bb5de8a59da8 * static,const,compiler warning cleanup
kabi
parents: 936
diff changeset
460 }