| 1 | /* |
| 2 | * bdist2_mmx.s: MMX optimized bidirectional squared distance sum |
| 3 | * |
| 4 | * Original believed to be Copyright (C) 2000 Brent Byeler |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version 2 |
| 9 | * of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | |
| 21 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 22 | #include "mjpeg_types.h"cxx . . $ `<file>/utils/mjpeg_types.h`/ |
| 23 | #include "mmx.h"cxx . . $ `<file>/utils/mmx.h`/ |
| 24 | |
| 25 | |
| 26 | /* |
| 27 | * squared error between a (16*h) block and a bidirectional |
| 28 | * prediction |
| 29 | * |
| 30 | * p2: address of top left pel of block |
| 31 | * pf,hxf,hyf: address and half pel flags of forward ref. block |
| 32 | * pb,hxb,hyb: address and half pel flags of backward ref. block |
| 33 | * h: height of block |
| 34 | * lx: distance (in bytes) of vertically adjacent pels in p2,pf,pb |
| 35 | * mmX version |
| 36 | */ |
| 37 | |
| 38 | int bsumsq_mmxcxx . . $ bsumsq_mmx(1f22fc03362e7774).(uint8_tcxx . . $ uint8_t# *pf, uint8_tcxx . . $ uint8_t# *pb, uint8_tcxx . . $ uint8_t# *p2, int lx, int hxf, int hyf, int hxb, int hyb, int h) |
| 39 | { |
| 40 | uint8_tcxx . . $ uint8_t# *pfa,*pfb,*pfc,*pba,*pbb,*pbc; |
| 41 | int s,s1,s2; |
| 42 | |
| 43 | pfa = pf + hxf; |
| 44 | pfb = pf + lx * hyf; |
| 45 | pfc = pfb + hxf; |
| 46 | |
| 47 | pba = pb + hxb; |
| 48 | pbb = pb + lx * hyb; |
| 49 | pbc = pbb + hxb; |
| 50 | |
| 51 | s = 0; /* (accumulated sum) */ |
| 52 | |
| 53 | if (h > 0) |
| 54 | { |
| 55 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm7, mm7); |
| 56 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm6, mm6); |
| 57 | pcmpeqw_r2rcxx . . $ `utils/mmx.h:121:9`!(mm5, mm5); |
| 58 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm5, mm6); |
| 59 | psllw_i2rcxx . . $ `utils/mmx.h:148:9`!(1, mm6); |
| 60 | |
| 61 | do { |
| 62 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pf[0], mm0); |
| 63 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm0, mm1); |
| 64 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm0); |
| 65 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm1); |
| 66 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pfa[0], mm2); |
| 67 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 68 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 69 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 70 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 71 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 72 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pfb[0], mm2); |
| 73 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 74 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 75 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 76 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 77 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 78 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pfc[0], mm2); |
| 79 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 80 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 81 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 82 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 83 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 84 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm0); |
| 85 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); |
| 86 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm0); |
| 87 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm1); |
| 88 | |
| 89 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pb[0], mm2); |
| 90 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 91 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 92 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 93 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pba[0], mm4); |
| 94 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm4, mm5); |
| 95 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm4); |
| 96 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm5); |
| 97 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 98 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm5, mm3); |
| 99 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pbb[0], mm4); |
| 100 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm4, mm5); |
| 101 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm4); |
| 102 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm5); |
| 103 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 104 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm5, mm3); |
| 105 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pbc[0], mm4); |
| 106 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm4, mm5); |
| 107 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm4); |
| 108 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm5); |
| 109 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 110 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm5, mm3); |
| 111 | |
| 112 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm2); |
| 113 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm3); |
| 114 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm2); |
| 115 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm3); |
| 116 | |
| 117 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 118 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 119 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm6); |
| 120 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm0); |
| 121 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); |
| 122 | psllw_i2rcxx . . $ `utils/mmx.h:148:9`!(1, mm6); |
| 123 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm0); |
| 124 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm1); |
| 125 | |
| 126 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(p2[0], mm2); |
| 127 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 128 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 129 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 130 | |
| 131 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm2, mm0); |
| 132 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 133 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm0, mm0); |
| 134 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 135 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm0); |
| 136 | |
| 137 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm0, s1); |
| 138 | psrlq_i2rcxx . . $ `utils/mmx.h:162:9`!(32, mm0); |
| 139 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm0, s2); |
| 140 | s += s1 + s2; |
| 141 | |
| 142 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pf[8], mm0); |
| 143 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm0, mm1); |
| 144 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm0); |
| 145 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm1); |
| 146 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pfa[8], mm2); |
| 147 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 148 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 149 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 150 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 151 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 152 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pfb[8], mm2); |
| 153 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 154 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 155 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 156 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 157 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 158 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pfc[8], mm2); |
| 159 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 160 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 161 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 162 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 163 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 164 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm0); |
| 165 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); |
| 166 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm0); |
| 167 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm1); |
| 168 | |
| 169 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pb[8], mm2); |
| 170 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 171 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 172 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 173 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pba[8], mm4); |
| 174 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm4, mm5); |
| 175 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm4); |
| 176 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm5); |
| 177 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 178 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm5, mm3); |
| 179 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pbb[8], mm4); |
| 180 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm4, mm5); |
| 181 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm4); |
| 182 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm5); |
| 183 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 184 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm5, mm3); |
| 185 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(pbc[8], mm4); |
| 186 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm4, mm5); |
| 187 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm4); |
| 188 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm5); |
| 189 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 190 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm5, mm3); |
| 191 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm2); |
| 192 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm3); |
| 193 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm2); |
| 194 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm3); |
| 195 | |
| 196 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 197 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 198 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm6); |
| 199 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm0); |
| 200 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); |
| 201 | psllw_i2rcxx . . $ `utils/mmx.h:148:9`!(1, mm6); |
| 202 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm0); |
| 203 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm1); |
| 204 | |
| 205 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(p2[8], mm2); |
| 206 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 207 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 208 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 209 | |
| 210 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm2, mm0); |
| 211 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 212 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm0, mm0); |
| 213 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 214 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm0); |
| 215 | |
| 216 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm0, s1); |
| 217 | psrlq_i2rcxx . . $ `utils/mmx.h:162:9`!(32, mm0); |
| 218 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm0, s2); |
| 219 | s += s1 + s2; |
| 220 | |
| 221 | p2 += lx; |
| 222 | pf += lx; |
| 223 | pfa += lx; |
| 224 | pfb += lx; |
| 225 | pfc += lx; |
| 226 | pb += lx; |
| 227 | pba += lx; |
| 228 | pbb += lx; |
| 229 | pbc += lx; |
| 230 | |
| 231 | h--; |
| 232 | } while(h > 0); |
| 233 | } |
| 234 | |
| 235 | emmscxx . . $ `utils/mmx.h:72:9`!(); |
| 236 | |
| 237 | return s; |
| 238 | } |