| 1 | /* |
| 2 | * dist2_mmx.s: mmX optimized squared distance sum |
| 3 | * |
| 4 | * Original believed to be Copyright (C) 2000 Brent Byeler |
| 5 | * |
| 6 | * This program is free software; you can reaxstribute 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 | * total squared difference between two (16*h) blocks |
| 27 | * including optional half pel interpolation of [ebp+8] ; blk1 (hx,hy) |
| 28 | * blk1,blk2: addresses of top left pels of both blocks |
| 29 | * lx: distance (in bytes) of vertically adjacent pels |
| 30 | * hx,hy: flags for horizontal and/or vertical interpolation |
| 31 | * h: height of block (usually 8 or 16) |
| 32 | * mmX version |
| 33 | */ |
| 34 | |
| 35 | int sumsq_mmxcxx . . $ sumsq_mmx(a770bd97d2cd113a).(uint8_tcxx . . $ uint8_t# *blk1, uint8_tcxx . . $ uint8_t# *blk2, int lx, int hx, int hy, int h) |
| 36 | { |
| 37 | static const uint16_tcxx . . $ uint16_t# twos[4]={2,2,2,2}; |
| 38 | int sum,sum1,sum2; |
| 39 | |
| 40 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm5, mm5); |
| 41 | |
| 42 | if (h>0) |
| 43 | { |
| 44 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm7, mm7); |
| 45 | |
| 46 | if ((hx == 0) && (hy == 0)) |
| 47 | { |
| 48 | do { /* d2top00 */ |
| 49 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[0], mm0); |
| 50 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm0, mm1); |
| 51 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm0); |
| 52 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm1); |
| 53 | |
| 54 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk2[0], mm2); |
| 55 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 56 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 57 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 58 | |
| 59 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm2, mm0); |
| 60 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 61 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm0, mm0); |
| 62 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 63 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm0); |
| 64 | |
| 65 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[8], mm1); |
| 66 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm1, mm2); |
| 67 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm1); |
| 68 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm2); |
| 69 | |
| 70 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk2[8], mm3); |
| 71 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm3, mm4); |
| 72 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm3); |
| 73 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm4); |
| 74 | |
| 75 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 76 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm4, mm2); |
| 77 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 78 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm2, mm2); |
| 79 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm2, mm1); |
| 80 | |
| 81 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm0); |
| 82 | |
| 83 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm0, mm5); /* Accumulate sum in mm5 */ |
| 84 | |
| 85 | blk1 += lx; |
| 86 | blk2 += lx; |
| 87 | |
| 88 | h--; |
| 89 | } while (h); |
| 90 | |
| 91 | } else if ((hx != 0) && (hy == 0)) /* d2is10 */ |
| 92 | { |
| 93 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm6, mm6); /* mm6 = 0 and isn't changed anyplace in the loop.. */ |
| 94 | pcmpeqw_r2rcxx . . $ `utils/mmx.h:121:9`!(mm1, mm1); |
| 95 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm1, mm6); |
| 96 | |
| 97 | do { /* d2top10 */ |
| 98 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[0], mm0); |
| 99 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm0, mm1); |
| 100 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm0); |
| 101 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm1); |
| 102 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[1], mm2); |
| 103 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 104 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 105 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 106 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 107 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 108 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm0); /* here we add mm6 = 0.... weird... */ |
| 109 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); |
| 110 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm0); |
| 111 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm1); |
| 112 | |
| 113 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk2[0], mm2); |
| 114 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 115 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 116 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 117 | |
| 118 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm2, mm0); |
| 119 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 120 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm0, mm0); |
| 121 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 122 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm0); |
| 123 | |
| 124 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[8], mm1); |
| 125 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm1, mm2); |
| 126 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm1); |
| 127 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm2); |
| 128 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[9], mm3); |
| 129 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm3, mm4); |
| 130 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm3); |
| 131 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm4); |
| 132 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 133 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 134 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); |
| 135 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm2); |
| 136 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm1); |
| 137 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm2); |
| 138 | |
| 139 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk2[8], mm3); |
| 140 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm3, mm4); |
| 141 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm3); |
| 142 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm4); |
| 143 | |
| 144 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 145 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm4, mm2); |
| 146 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 147 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm2, mm2); |
| 148 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm2, mm1); |
| 149 | |
| 150 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm0); |
| 151 | |
| 152 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm0, mm5); /* Accumulate mm0 sum on mm5 */ |
| 153 | |
| 154 | blk1 += lx; |
| 155 | blk2 += lx; |
| 156 | |
| 157 | h--; |
| 158 | } while (h); |
| 159 | |
| 160 | } else if ((hx == 0) && (hy != 0)) /* d2is01 */ |
| 161 | { |
| 162 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm6, mm6); |
| 163 | pcmpeqw_r2rcxx . . $ `utils/mmx.h:121:9`!(mm1, mm1); |
| 164 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm1, mm6); /* mm6 = 1 */ |
| 165 | |
| 166 | do { /* d2top01 */ |
| 167 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[0], mm0); |
| 168 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm0, mm1); |
| 169 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm0); |
| 170 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm1); |
| 171 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[lx], mm2); |
| 172 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 173 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 174 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 175 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 176 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 177 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm0); |
| 178 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); |
| 179 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm0); |
| 180 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm1); |
| 181 | |
| 182 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk2[0], mm2); |
| 183 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 184 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 185 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 186 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm2, mm0); |
| 187 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 188 | |
| 189 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm0, mm0); |
| 190 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 191 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm0); |
| 192 | |
| 193 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[8], mm1); |
| 194 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm1, mm2); |
| 195 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm1); |
| 196 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm2); |
| 197 | |
| 198 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[lx+8], mm3); |
| 199 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm3, mm4); |
| 200 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm3); |
| 201 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm4); |
| 202 | |
| 203 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 204 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 205 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); |
| 206 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm2); |
| 207 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm1); |
| 208 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm2); |
| 209 | |
| 210 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk2[8], mm3); |
| 211 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm3, mm4); |
| 212 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm3); |
| 213 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm4); |
| 214 | |
| 215 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 216 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm4, mm2); |
| 217 | |
| 218 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 219 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm2, mm2); |
| 220 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm0); |
| 221 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm2, mm0); |
| 222 | |
| 223 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm0, mm5); |
| 224 | |
| 225 | blk1 += lx; |
| 226 | blk2 += lx; |
| 227 | |
| 228 | h--; |
| 229 | } while (h); |
| 230 | |
| 231 | } else /* d2is11 */ |
| 232 | { |
| 233 | |
| 234 | do { /* d2top11 */ |
| 235 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[0], mm0); |
| 236 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm0, mm1); |
| 237 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm0); |
| 238 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm1); |
| 239 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[1], mm2); |
| 240 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 241 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 242 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 243 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 244 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 245 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[lx], mm2); |
| 246 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 247 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 248 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 249 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[lx+1], mm4); |
| 250 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm4, mm6); |
| 251 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm4); |
| 252 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm6); |
| 253 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 254 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm3); |
| 255 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm0); |
| 256 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 257 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(*twos, mm6); |
| 258 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm0); /* round mm0 */ |
| 259 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); /* round mm1 */ |
| 260 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm0); |
| 261 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm1); |
| 262 | |
| 263 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk2[0], mm2); |
| 264 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 265 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 266 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 267 | |
| 268 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm2, mm0); |
| 269 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 270 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm0, mm0); |
| 271 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 272 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm0); |
| 273 | |
| 274 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[8], mm1); |
| 275 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm1, mm2); |
| 276 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm1); |
| 277 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm2); |
| 278 | |
| 279 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[9], mm3); |
| 280 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm3, mm4); |
| 281 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm3); |
| 282 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm4); |
| 283 | |
| 284 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 285 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 286 | |
| 287 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[lx+8], mm3); |
| 288 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm3, mm4); |
| 289 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm3); |
| 290 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm4); |
| 291 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 292 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 293 | |
| 294 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[lx+9], mm3); |
| 295 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm3, mm4); |
| 296 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm3); |
| 297 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm4); |
| 298 | |
| 299 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm1); |
| 300 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm2); |
| 301 | |
| 302 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(*twos, mm6); |
| 303 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); |
| 304 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm2); |
| 305 | |
| 306 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm1); |
| 307 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(2, mm2); |
| 308 | |
| 309 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk2[8], mm3); |
| 310 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm3, mm4); |
| 311 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm3); |
| 312 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm4); |
| 313 | |
| 314 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 315 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm4, mm2); |
| 316 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 317 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm2, mm2); |
| 318 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm2, mm1); |
| 319 | |
| 320 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm0); |
| 321 | |
| 322 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm0, mm5); |
| 323 | |
| 324 | blk1 += lx; |
| 325 | blk2 += lx; |
| 326 | |
| 327 | h--; |
| 328 | } while (h); |
| 329 | } |
| 330 | |
| 331 | } |
| 332 | |
| 333 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm5, sum1); |
| 334 | psrlq_i2rcxx . . $ `utils/mmx.h:162:9`!(32, mm5); |
| 335 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm5, sum2); |
| 336 | sum = sum1 + sum2; |
| 337 | |
| 338 | emmscxx . . $ `utils/mmx.h:72:9`!(); |
| 339 | |
| 340 | return sum; |
| 341 | } |
| 342 | |
| 343 | |
| 344 | /* |
| 345 | * total squared difference between two (8*h) blocks |
| 346 | * blk1,blk2: addresses of top left pels of both blocks |
| 347 | * lx: distance (in bytes) of vertically adjacent pels |
| 348 | * h: height of block (usually 4, or 8) |
| 349 | * mmX version |
| 350 | */ |
| 351 | |
| 352 | int sumsq_sub22_mmxcxx . . $ sumsq_sub22_mmx(f69c737b6cdd83e1).(uint8_tcxx . . $ uint8_t# *blk1, uint8_tcxx . . $ uint8_t# *blk2, int lx, int h) |
| 353 | { |
| 354 | int sum,sum1,sum2; |
| 355 | |
| 356 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm5, mm5); /* sum */ |
| 357 | |
| 358 | if (h > 0) |
| 359 | { |
| 360 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm7, mm7); |
| 361 | |
| 362 | do { /* d2top22 */ |
| 363 | |
| 364 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1[0], mm0); |
| 365 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm0, mm1); |
| 366 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm0); |
| 367 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm1); |
| 368 | |
| 369 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk2[0], mm2); |
| 370 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 371 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 372 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 373 | |
| 374 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm2, mm0); |
| 375 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 376 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm0, mm0); |
| 377 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 378 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm0, mm5); |
| 379 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm5); |
| 380 | |
| 381 | blk1 += lx; |
| 382 | blk2 += lx; |
| 383 | |
| 384 | h--; |
| 385 | } while (h); |
| 386 | } |
| 387 | |
| 388 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm5, sum1); |
| 389 | psrlq_i2rcxx . . $ `utils/mmx.h:162:9`!(32, mm5); |
| 390 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm5, sum2); |
| 391 | sum = sum1 + sum2; |
| 392 | |
| 393 | emmscxx . . $ `utils/mmx.h:72:9`!(); |
| 394 | |
| 395 | return sum; |
| 396 | } |
| 397 | |
| 398 | |
| 399 | /* |
| 400 | * total squared difference between interpolation of two (8*h) blocks and |
| 401 | * another 8*h block |
| 402 | * blk1,blk2: addresses of top left pels of both blocks |
| 403 | * lx: distance (in bytes) of vertically adjacent pels |
| 404 | * h: height of block (usually 4, or 8) |
| 405 | * mmX version |
| 406 | */ |
| 407 | |
| 408 | int bsumsq_sub22_mmxcxx . . $ bsumsq_sub22_mmx(d5aa2cdc26d03928).(uint8_tcxx . . $ uint8_t# *blk1f, uint8_tcxx . . $ uint8_t# *blk1b, uint8_tcxx . . $ uint8_t# *blk2, int lx, int h) |
| 409 | { |
| 410 | static const uint16_tcxx . . $ uint16_t# ones[4]={1,1,1,1}; |
| 411 | int sum,sum1,sum2; |
| 412 | |
| 413 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm5, mm5); |
| 414 | |
| 415 | if (h > 0) |
| 416 | { |
| 417 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm7, mm7); |
| 418 | |
| 419 | do { /* bd2top22 */ |
| 420 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1f[0], mm0); |
| 421 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm0, mm1); |
| 422 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk1b[0], mm4); |
| 423 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm4, mm6); |
| 424 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm0); |
| 425 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm1); |
| 426 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm4); |
| 427 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm6); |
| 428 | |
| 429 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(blk2[0], mm2); |
| 430 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 431 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm7, mm2); |
| 432 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm7, mm3); |
| 433 | |
| 434 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm4, mm0); |
| 435 | paddw_m2rcxx . . $ `utils/mmx.h:97:9`!(*ones, mm0); |
| 436 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm0); |
| 437 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm2, mm0); |
| 438 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm0, mm0); |
| 439 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm6, mm1); |
| 440 | paddw_m2rcxx . . $ `utils/mmx.h:97:9`!(*ones, mm1); |
| 441 | psrlw_i2rcxx . . $ `utils/mmx.h:165:9`!(1, mm1); |
| 442 | psubw_r2rcxx . . $ `utils/mmx.h:174:9`!(mm3, mm1); |
| 443 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm1, mm1); |
| 444 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm0, mm5); |
| 445 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm5); |
| 446 | |
| 447 | blk1f += lx; |
| 448 | blk1b += lx; |
| 449 | blk2 += lx; |
| 450 | |
| 451 | h--; |
| 452 | } while (h); |
| 453 | } |
| 454 | |
| 455 | |
| 456 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm5, sum1); |
| 457 | psrlq_i2rcxx . . $ `utils/mmx.h:162:9`!(32, mm5); |
| 458 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm5, sum2); |
| 459 | sum = sum1 + sum2; |
| 460 | |
| 461 | emmscxx . . $ `utils/mmx.h:72:9`!(); |
| 462 | |
| 463 | return sum; |
| 464 | |
| 465 | } |
| 466 | |
| 467 | |
| 468 | /* |
| 469 | * variance of a (size*size) block, multiplied by 256 |
| 470 | * p: address of top left pel of block |
| 471 | * lx: seperation (in bytes) of vertically adjacent pels |
| 472 | * NOTE: size is 8 or 16 |
| 473 | */ |
| 474 | |
| 475 | void variance_mmxcxx . . $ variance_mmx(925ee8f2aa08b27a).(uint8_tcxx . . $ uint8_t# *p, int size, int lx, unsigned int *p_var, unsigned int *p_mean) |
| 476 | { |
| 477 | uint8_tcxx . . $ uint8_t# *p2; |
| 478 | int col, row; |
| 479 | unsigned int sum, sum_squared, squares_sum; |
| 480 | |
| 481 | /* |
| 482 | * Use of MMX registers |
| 483 | * mm0 = <0,0,0,0> |
| 484 | * mm6 = Sum pixel squared |
| 485 | * mm7 = Sum pixels |
| 486 | */ |
| 487 | |
| 488 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm0, mm0); |
| 489 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm7, mm7); /* Zero sum accumulator (4 words) */ |
| 490 | pxor_r2rcxx . . $ `utils/mmx.h:201:9`!(mm6, mm6); /* Zero squares accumulator (2 dwords) */ |
| 491 | |
| 492 | for(col=0; col<size; col+=8) |
| 493 | { |
| 494 | p2 = p; |
| 495 | for (row=0; row<size; row++) /* varrows */ |
| 496 | { |
| 497 | movq_m2rcxx . . $ `utils/mmx.h:81:9`!(p2[col], mm2); |
| 498 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm3); |
| 499 | punpcklbw_r2rcxx . . $ `utils/mmx.h:194:9`!(mm0, mm2); |
| 500 | punpckhbw_r2rcxx . . $ `utils/mmx.h:187:9`!(mm0, mm3); |
| 501 | |
| 502 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm2, mm4); |
| 503 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm3, mm5); |
| 504 | |
| 505 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm2, mm4); /* Squares 0:3 */ |
| 506 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm2, mm7); /* Accumulate sum 0:3 (words) */ |
| 507 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm4, mm6); /* Accumulate sum squares 0:3 (dwords) */ |
| 508 | |
| 509 | pmaddwd_r2rcxx . . $ `utils/mmx.h:131:9`!(mm3, mm5); /* Squares 4:7 */ |
| 510 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm3, mm7); /* Accumulate sum 4:7 (words) */ |
| 511 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm5, mm6); /* Accumulate sum squares 4:7 (dwords) */ |
| 512 | |
| 513 | p2 += lx; /* Next row */ |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm7, mm1); |
| 518 | psrlq_i2rcxx . . $ `utils/mmx.h:162:9`!(32, mm1); |
| 519 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm1, mm7); |
| 520 | |
| 521 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm7, mm1); |
| 522 | psrlq_i2rcxx . . $ `utils/mmx.h:162:9`!(16, mm1); |
| 523 | paddw_r2rcxx . . $ `utils/mmx.h:98:9`!(mm1, mm7); |
| 524 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm7, sum); |
| 525 | sum &= 0xffff; |
| 526 | sum_squared = sum*sum; |
| 527 | |
| 528 | movq_r2rcxx . . $ `utils/mmx.h:83:9`!(mm6, mm1); |
| 529 | psrlq_i2rcxx . . $ `utils/mmx.h:162:9`!(32, mm1); |
| 530 | paddd_r2rcxx . . $ `utils/mmx.h:96:9`!(mm1, mm6); |
| 531 | movd_r2gcxx . . $ `utils/mmx.h:78:9`!(mm6, squares_sum); |
| 532 | |
| 533 | /* sum / (size*size) -> *p_mean */ |
| 534 | /* Squares sum - sum squares / (size*size) -> *p_var */ |
| 535 | |
| 536 | sum >>= 6; /* Divide sum and sum squared by 64 for 8*8 */ |
| 537 | sum_squared >>= 6; |
| 538 | if (size != 8) /* If 16 * 16 divide again by 4 (256) */ |
| 539 | { |
| 540 | sum >>= 2; |
| 541 | sum_squared >>= 2; |
| 542 | } |
| 543 | |
| 544 | *p_mean = sum; |
| 545 | *p_var = squares_sum-sum_squared; |
| 546 | |
| 547 | emmscxx . . $ `utils/mmx.h:72:9`!(); |
| 548 | } |
| 549 | |
| 550 | |
| 551 |