Nothing within processing uses functions from this file.
Showing the changes to codec/processing/src (1 of 3 files). Show all
Unified · Split
| @@ -1,1505 +0,0 @@ | |||
| 1 | ;*! | ||
| 2 | ;* \copy | ||
| 3 | ;* Copyright (c) 2009-2013, Cisco Systems | ||
| 4 | ;* All rights reserved. | ||
| 5 | ;* | ||
| 6 | ;* Redistribution and use in source and binary forms, with or without | ||
| 7 | ;* modification, are permitted provided that the following conditions | ||
| 8 | ;* are met: | ||
| 9 | ;* | ||
| 10 | ;* * Redistributions of source code must retain the above copyright | ||
| 11 | ;* notice, this list of conditions and the following disclaimer. | ||
| 12 | ;* | ||
| 13 | ;* * Redistributions in binary form must reproduce the above copyright | ||
| 14 | ;* notice, this list of conditions and the following disclaimer in | ||
| 15 | ;* the documentation and/or other materials provided with the | ||
| 16 | ;* distribution. | ||
| 17 | ;* | ||
| 18 | ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 19 | ;* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 20 | ;* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| 21 | ;* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 22 | ;* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 23 | ;* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| 24 | ;* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 25 | ;* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 26 | ;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 27 | ;* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
| 28 | ;* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 29 | ;* POSSIBILITY OF SUCH DAMAGE. | ||
| 30 | ;* | ||
| 31 | ;* | ||
| 32 | ;* intra_pred.asm | ||
| 33 | ;* | ||
| 34 | ;* Abstract | ||
| 35 | ;* sse2 function for intra predict operations | ||
| 36 | ;* | ||
| 37 | ;* History | ||
| 38 | ;* 18/09/2009 Created | ||
| 39 | ;* | ||
| 40 | ;* | ||
| 41 | ;*************************************************************************/ | ||
| 42 | %include "asm_inc.asm" | ||
| 43 | |||
| 44 | ;*********************************************************************** | ||
| 45 | ; Local Data (Read Only) | ||
| 46 | ;*********************************************************************** | ||
| 47 | |||
| 48 | %ifdef FORMAT_COFF | ||
| 49 | SECTION .rodata pData | ||
| 50 | %else | ||
| 51 | SECTION .rodata align=16 | ||
| 52 | %endif | ||
| 53 | |||
| 54 | align 16 | ||
| 55 | sse2_plane_inc_minus dw -7, -6, -5, -4, -3, -2, -1, 0 | ||
| 56 | align 16 | ||
| 57 | sse2_plane_inc dw 1, 2, 3, 4, 5, 6, 7, 8 | ||
| 58 | align 16 | ||
| 59 | sse2_plane_dec dw 8, 7, 6, 5, 4, 3, 2, 1 | ||
| 60 | |||
| 61 | ; for chroma plane mode | ||
| 62 | sse2_plane_inc_c dw 1, 2, 3, 4 | ||
| 63 | sse2_plane_dec_c dw 4, 3, 2, 1 | ||
| 64 | align 16 | ||
| 65 | sse2_plane_mul_b_c dw -3, -2, -1, 0, 1, 2, 3, 4 | ||
| 66 | |||
| 67 | align 16 | ||
| 68 | mmx_01bytes: times 16 db 1 | ||
| 69 | ;align 16 | ||
| 70 | ;sse_0x0004bytes: times 8 dw 4 | ||
| 71 | ;ALIGN 16 | ||
| 72 | ;sse_f000 db 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | ||
| 73 | |||
| 74 | align 16 | ||
| 75 | mmx_0x02: dw 0x02, 0x00, 0x00, 0x00 | ||
| 76 | |||
| 77 | |||
| 78 | ;*********************************************************************** | ||
| 79 | ; macros | ||
| 80 | ;*********************************************************************** | ||
| 81 | ;dB 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 | ||
| 82 | ;%1 will keep the last result | ||
| 83 | %macro SSE_DB_1_2REG 2 | ||
| 84 | pxor %1, %1 | ||
| 85 | pcmpeqw %2, %2 | ||
| 86 | psubb %1, %2 | ||
| 87 | %endmacro | ||
| 88 | |||
| 89 | ;xmm0, xmm1, xmm2, eax, ecx | ||
| 90 | ;lower 64 bits of xmm0 save the result | ||
| 91 | %macro SSE2_PRED_H_4X4_TWO_LINE 5 | ||
| 92 | movd %1, [%4-1] | ||
| 93 | movdqa %3, %1 | ||
| 94 | punpcklbw %1, %3 | ||
| 95 | movdqa %3, %1 | ||
| 96 | punpcklbw %1, %3 | ||
| 97 | |||
| 98 | ;add %4, %5 | ||
| 99 | movd %2, [%4+%5-1] | ||
| 100 | movdqa %3, %2 | ||
| 101 | punpcklbw %2, %3 | ||
| 102 | movdqa %3, %2 | ||
| 103 | punpcklbw %2, %3 | ||
| 104 | punpckldq %1, %2 | ||
| 105 | %endmacro | ||
| 106 | |||
| 107 | %macro SUMW_HORIZON1 2 | ||
| 108 | movdqa %2, %1 | ||
| 109 | psrldq %2, 8 | ||
| 110 | paddusw %1, %2 | ||
| 111 | movdqa %2, %1 | ||
| 112 | psrldq %2, 4 | ||
| 113 | paddusw %1, %2 | ||
| 114 | movdqa %2, %1 | ||
| 115 | psrldq %2, 2 | ||
| 116 | paddusw %1, %2 | ||
| 117 | %endmacro | ||
| 118 | |||
| 119 | %macro LOAD_COLUMN 6 | ||
| 120 | movd %1, [%5] | ||
| 121 | movd %2, [%5+%6] | ||
| 122 | punpcklbw %1, %2 | ||
| 123 | lea %5, [%5+2*%6] | ||
| 124 | movd %3, [%5] | ||
| 125 | movd %2, [%5+%6] | ||
| 126 | punpcklbw %3, %2 | ||
| 127 | punpcklwd %1, %3 | ||
| 128 | lea %5, [%5+2*%6] | ||
| 129 | movd %4, [%5] | ||
| 130 | movd %2, [%5+%6] | ||
| 131 | punpcklbw %4, %2 | ||
| 132 | lea %5, [%5+2*%6] | ||
| 133 | movd %3, [%5] | ||
| 134 | movd %2, [%5+%6] | ||
| 135 | lea %5, [%5+2*%6] | ||
| 136 | punpcklbw %3, %2 | ||
| 137 | punpcklwd %4, %3 | ||
| 138 | punpckhdq %1, %4 | ||
| 139 | %endmacro | ||
| 140 | |||
| 141 | %macro SUMW_HORIZON 3 | ||
| 142 | movhlps %2, %1 ; x2 = xx xx xx xx d7 d6 d5 d4 | ||
| 143 | paddw %1, %2 ; x1 = xx xx xx xx d37 d26 d15 d04 | ||
| 144 | punpcklwd %1, %3 ; x1 = d37 d26 d15 d04 | ||
| 145 | movhlps %2, %1 ; x2 = xxxx xxxx d37 d26 | ||
| 146 | paddd %1, %2 ; x1 = xxxx xxxx d1357 d0246 | ||
| 147 | pshuflw %2, %1, 0x4e ; x2 = xxxx xxxx d0246 d1357 | ||
| 148 | paddd %1, %2 ; x1 = xxxx xxxx xxxx d01234567 | ||
| 149 | %endmacro | ||
| 150 | |||
| 151 | |||
| 152 | %macro COPY_16_TIMES 2 | ||
| 153 | movdqa %2, [%1-16] | ||
| 154 | psrldq %2, 15 | ||
| 155 | pmuludq %2, [mmx_01bytes] | ||
| 156 | pshufd %2, %2, 0 | ||
| 157 | %endmacro | ||
| 158 | |||
| 159 | %macro COPY_16_TIMESS 3 | ||
| 160 | movdqa %2, [%1+%3-16] | ||
| 161 | psrldq %2, 15 | ||
| 162 | pmuludq %2, [mmx_01bytes] | ||
| 163 | pshufd %2, %2, 0 | ||
| 164 | %endmacro | ||
| 165 | |||
| 166 | %macro LOAD_COLUMN_C 6 | ||
| 167 | movd %1, [%5] | ||
| 168 | movd %2, [%5+%6] | ||
| 169 | punpcklbw %1,%2 | ||
| 170 | lea %5, [%5+2*%6] | ||
| 171 | movd %3, [%5] | ||
| 172 | movd %2, [%5+%6] | ||
| 173 | punpcklbw %3, %2 | ||
| 174 | punpckhwd %1, %3 | ||
| 175 | lea %5, [%5+2*%6] | ||
| 176 | %endmacro | ||
| 177 | |||
| 178 | %macro LOAD_2_LEFT_AND_ADD 0 | ||
| 179 | lea r1, [r1+2*r2] | ||
| 180 | movzx r4, byte [r1-0x01] | ||
| 181 | add r3, r4 | ||
| 182 | movzx r4, byte [r1+r2-0x01] | ||
| 183 | add r3, r4 | ||
| 184 | %endmacro | ||
| 185 | |||
| 186 | ;*********************************************************************** | ||
| 187 | ; Code | ||
| 188 | ;*********************************************************************** | ||
| 189 | |||
| 190 | SECTION .text | ||
| 191 | WELS_EXTERN WelsI4x4LumaPredH_sse2 | ||
| 192 | WELS_EXTERN WelsI4x4LumaPredDDR_mmx | ||
| 193 | WELS_EXTERN WelsI4x4LumaPredDc_sse2 | ||
| 194 | WELS_EXTERN WelsI16x16LumaPredPlane_sse2 | ||
| 195 | |||
| 196 | ALIGN 16 | ||
| 197 | ;*********************************************************************** | ||
| 198 | ; void __cdecl WelsI4x4LumaPredH_sse2(uint8_t *pred, uint8_t *pRef, int32_t stride) | ||
| 199 | ; | ||
| 200 | ; pred must align to 16 | ||
| 201 | ;*********************************************************************** | ||
| 202 | WelsI4x4LumaPredH_sse2: | ||
| 203 | push r3 | ||
| 204 | %assign push_num 1 | ||
| 205 | LOAD_3_PARA | ||
| 206 | %ifndef X86_32 | ||
| 207 | movsx r2, r2d | ||
| 208 | %endif | ||
| 209 | movzx r3, byte [r1-1] | ||
| 210 | movd xmm0, r3d | ||
| 211 | pmuludq xmm0, [mmx_01bytes] | ||
| 212 | |||
| 213 | movzx r3, byte [r1+r2-1] | ||
| 214 | movd xmm1, r3d | ||
| 215 | pmuludq xmm1, [mmx_01bytes] | ||
| 216 | |||
| 217 | unpcklps xmm0, xmm1 | ||
| 218 | |||
| 219 | lea r1, [r1+r2*2] | ||
| 220 | movzx r3, byte [r1-1] | ||
| 221 | movd xmm2, r3d | ||
| 222 | pmuludq xmm2, [mmx_01bytes] | ||
| 223 | |||
| 224 | movzx r3, byte [r1+r2-1] | ||
| 225 | movd xmm3, r3d | ||
| 226 | pmuludq xmm3, [mmx_01bytes] | ||
| 227 | |||
| 228 | unpcklps xmm2, xmm3 | ||
| 229 | unpcklpd xmm0, xmm2 | ||
| 230 | |||
| 231 | movdqa [r0], xmm0 | ||
| 232 | pop r3 | ||
| 233 | ret | ||
| 234 | |||
| 235 | ;*********************************************************************** | ||
| 236 | ; void WelsI16x16LumaPredPlane_sse2(uint8_t *pred, uint8_t *pRef, int32_t stride); | ||
| 237 | ;*********************************************************************** | ||
| 238 | WelsI16x16LumaPredPlane_sse2: | ||
| 239 | ;%define pushsize 4 | ||
| 240 | ;push esi | ||
| 241 | ;mov esi, [esp + pushsize + 8] | ||
| 242 | ;mov ecx, [esp + pushsize + 12] | ||
| 243 | push r3 | ||
| 244 | push r4 | ||
| 245 | %assign push_num 2 | ||
| 246 | LOAD_3_PARA | ||
| 247 | %ifndef X86_32 | ||
| 248 | movsx r2, r2d | ||
| 249 | %endif | ||
| 250 | sub r1, 1 | ||
| 251 | sub r1, r2 | ||
| 252 | |||
| 253 | ;for H | ||
| 254 | pxor xmm7, xmm7 | ||
| 255 | movq xmm0, [r1] | ||
| 256 | movdqa xmm5, [sse2_plane_dec] | ||
| 257 | punpcklbw xmm0, xmm7 | ||
| 258 | pmullw xmm0, xmm5 | ||
| 259 | movq xmm1, [r1 + 9] | ||
| 260 | movdqa xmm6, [sse2_plane_inc] | ||
| 261 | punpcklbw xmm1, xmm7 | ||
| 262 | pmullw xmm1, xmm6 | ||
| 263 | psubw xmm1, xmm0 | ||
| 264 | |||
| 265 | SUMW_HORIZON xmm1,xmm0,xmm2 | ||
| 266 | movd r3d, xmm1 ; H += (i + 1) * (top[8 + i] - top[6 - i]); | ||
| 267 | movsx r3, r3w | ||
| 268 | imul r3, 5 | ||
| 269 | add r3, 32 | ||
| 270 | sar r3, 6 ; b = (5 * H + 32) >> 6; | ||
| 271 | SSE2_Copy8Times xmm1, r3d ; xmm1 = b,b,b,b,b,b,b,b | ||
| 272 | |||
| 273 | movzx r4, BYTE [r1+16] | ||
| 274 | sub r1, 3 | ||
| 275 | LOAD_COLUMN xmm0, xmm2, xmm3, xmm4, r1, r2 | ||
| 276 | |||
| 277 | add r1, 3 | ||
| 278 | movzx r3, BYTE [r1+8*r2] | ||
| 279 | add r4, r3 | ||
| 280 | shl r4, 4 ; a = (left[15*stride] + top[15]) << 4; | ||
| 281 | |||
| 282 | sub r1, 3 | ||
| 283 | add r1, r2 | ||
| 284 | LOAD_COLUMN xmm7, xmm2, xmm3, xmm4, r1, r2 | ||
| 285 | pxor xmm4, xmm4 | ||
| 286 | punpckhbw xmm0, xmm4 | ||
| 287 | pmullw xmm0, xmm5 | ||
| 288 | punpckhbw xmm7, xmm4 | ||
| 289 | pmullw xmm7, xmm6 | ||
| 290 | psubw xmm7, xmm0 | ||
| 291 | |||
| 292 | SUMW_HORIZON xmm7,xmm0,xmm2 | ||
| 293 | movd r3d, xmm7 ; V | ||
| 294 | movsx r3, r3w | ||
| 295 | imul r3, 5 | ||
| 296 | add r3, 32 | ||
| 297 | sar r3, 6 ; c = (5 * V + 32) >> 6; | ||
| 298 | SSE2_Copy8Times xmm4, r3d ; xmm4 = c,c,c,c,c,c,c,c | ||
| 299 | |||
| 300 | ;mov esi, [esp + pushsize + 4] | ||
| 301 | add r4, 16 | ||
| 302 | imul r3, -7 | ||
| 303 | add r3, r4 ; s = a + 16 + (-7)*c | ||
| 304 | SSE2_Copy8Times xmm0, r3d ; xmm0 = s,s,s,s,s,s,s,s | ||
| 305 | |||
| 306 | xor r3, r3 | ||
| 307 | movdqa xmm5, [sse2_plane_inc_minus] | ||
| 308 | |||
| 309 | get_i16x16_luma_pred_plane_sse2_1: | ||
| 310 | movdqa xmm2, xmm1 | ||
| 311 | pmullw xmm2, xmm5 | ||
| 312 | paddw xmm2, xmm0 | ||
| 313 | psraw xmm2, 5 | ||
| 314 | movdqa xmm3, xmm1 | ||
| 315 | pmullw xmm3, xmm6 | ||
| 316 | paddw xmm3, xmm0 | ||
| 317 | psraw xmm3, 5 | ||
| 318 | packuswb xmm2, xmm3 | ||
| 319 | movdqa [r0], xmm2 | ||
| 320 | paddw xmm0, xmm4 | ||
| 321 | add r0, 16 | ||
| 322 | inc r3 | ||
| 323 | cmp r3, 16 | ||
| 324 | jnz get_i16x16_luma_pred_plane_sse2_1 | ||
| 325 | pop r4 | ||
| 326 | pop r3 | ||
| 327 | ret | ||
| 328 | |||
| 329 | ;*********************************************************************** | ||
| 330 | ; void WelsI16x16LumaPredH_sse2(uint8_t *pred, uint8_t *pRef, int32_t stride); | ||
| 331 | ;*********************************************************************** | ||
| 332 | |||
| 333 | %macro SSE2_PRED_H_16X16_ONE_LINE 0 | ||
| 334 | add r0, 16 | ||
| 335 | add r1, r2 | ||
| 336 | movzx r3, byte [r1] | ||
| 337 | SSE2_Copy16Times xmm0, r3d | ||
| 338 | movdqa [r0], xmm0 | ||
| 339 | %endmacro | ||
| 340 | |||
| 341 | WELS_EXTERN WelsI16x16LumaPredH_sse2 | ||
| 342 | WelsI16x16LumaPredH_sse2: | ||
| 343 | push r3 | ||
| 344 | %assign push_num 1 | ||
| 345 | LOAD_3_PARA | ||
| 346 | %ifndef X86_32 | ||
| 347 | movsx r2, r2d | ||
| 348 | %endif | ||
| 349 | dec r1 | ||
| 350 | movzx r3, byte [r1] | ||
| 351 | SSE2_Copy16Times xmm0, r3d | ||
| 352 | movdqa [r0], xmm0 | ||
| 353 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 354 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 355 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 356 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 357 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 358 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 359 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 360 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 361 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 362 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 363 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 364 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 365 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 366 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 367 | SSE2_PRED_H_16X16_ONE_LINE | ||
| 368 | pop r3 | ||
| 369 | ret | ||
| 370 | |||
| 371 | ;*********************************************************************** | ||
| 372 | ; void WelsI16x16LumaPredV_sse2(uint8_t *pred, uint8_t *pRef, int32_t stride); | ||
| 373 | ;*********************************************************************** | ||
| 374 | WELS_EXTERN WelsI16x16LumaPredV_sse2 | ||
| 375 | WelsI16x16LumaPredV_sse2: | ||
| 376 | ;mov edx, [esp+4] ; pred | ||
| 377 | ;mov eax, [esp+8] ; pRef | ||
| 378 | ;mov ecx, [esp+12] ; stride | ||
| 379 | %assign push_num 0 | ||
| 380 | LOAD_3_PARA | ||
| 381 | %ifndef X86_32 | ||
| 382 | movsx r2, r2d | ||
| 383 | %endif | ||
| 384 | sub r1, r2 | ||
| 385 | movdqa xmm0, [r1] | ||
| 386 | |||
| 387 | movdqa [r0], xmm0 | ||
| 388 | movdqa [r0+10h], xmm0 | ||
| 389 | movdqa [r0+20h], xmm0 | ||
| 390 | movdqa [r0+30h], xmm0 | ||
| 391 | movdqa [r0+40h], xmm0 | ||
| 392 | movdqa [r0+50h], xmm0 | ||
| 393 | movdqa [r0+60h], xmm0 | ||
| 394 | movdqa [r0+70h], xmm0 | ||
| 395 | movdqa [r0+80h], xmm0 | ||
| 396 | movdqa [r0+90h], xmm0 | ||
| 397 | movdqa [r0+160], xmm0 | ||
| 398 | movdqa [r0+176], xmm0 | ||
| 399 | movdqa [r0+192], xmm0 | ||
| 400 | movdqa [r0+208], xmm0 | ||
| 401 | movdqa [r0+224], xmm0 | ||
| 402 | movdqa [r0+240], xmm0 | ||
| 403 | |||
| 404 | ret | ||
| 405 | |||
| 406 | ;*********************************************************************** | ||
| 407 | ; void WelsIChromaPredPlane_sse2(uint8_t *pred, uint8_t *pRef, int32_t stride); | ||
| 408 | ;*********************************************************************** | ||
| 409 | WELS_EXTERN WelsIChromaPredPlane_sse2 | ||
| 410 | WelsIChromaPredPlane_sse2: | ||
| 411 | ;%define pushsize 4 | ||
| 412 | ;push esi | ||
| 413 | ;mov esi, [esp + pushsize + 8] ;pRef | ||
| 414 | ;mov ecx, [esp + pushsize + 12] ;stride | ||
| 415 | push r3 | ||
| 416 | push r4 | ||
| 417 | %assign push_num 2 | ||
| 418 | LOAD_3_PARA | ||
| 419 | %ifndef X86_32 | ||
| 420 | movsx r2, r2d | ||
| 421 | %endif | ||
| 422 | sub r1, 1 | ||
| 423 | sub r1, r2 | ||
| 424 | |||
| 425 | pxor mm7, mm7 | ||
| 426 | movq mm0, [r1] | ||
| 427 | movq mm5, [sse2_plane_dec_c] | ||
| 428 | punpcklbw mm0, mm7 | ||
| 429 | pmullw mm0, mm5 | ||
| 430 | movq mm1, [r1 + 5] | ||
| 431 | movq mm6, [sse2_plane_inc_c] | ||
| 432 | punpcklbw mm1, mm7 | ||
| 433 | pmullw mm1, mm6 | ||
| 434 | psubw mm1, mm0 | ||
| 435 | |||
| 436 | movq2dq xmm1, mm1 | ||
| 437 | pxor xmm2, xmm2 | ||
| 438 | SUMW_HORIZON xmm1,xmm0,xmm2 | ||
| 439 | movd r3d, xmm1 | ||
| 440 | movsx r3, r3w | ||
| 441 | imul r3, 17 | ||
| 442 | add r3, 16 | ||
| 443 | sar r3, 5 ; b = (17 * H + 16) >> 5; | ||
| 444 | SSE2_Copy8Times xmm1, r3d ; mm1 = b,b,b,b,b,b,b,b | ||
| 445 | |||
| 446 | movzx r3, BYTE [r1+8] | ||
| 447 | sub r1, 3 | ||
| 448 | LOAD_COLUMN_C mm0, mm2, mm3, mm4, r1, r2 | ||
| 449 | |||
| 450 | add r1, 3 | ||
| 451 | movzx r4, BYTE [r1+4*r2] | ||
| 452 | add r4, r3 | ||
| 453 | shl r4, 4 ; a = (left[7*stride] + top[7]) << 4; | ||
| 454 | |||
| 455 | sub r1, 3 | ||
| 456 | add r1, r2 | ||
| 457 | LOAD_COLUMN_C mm7, mm2, mm3, mm4, r1, r2 | ||
| 458 | pxor mm4, mm4 | ||
| 459 | punpckhbw mm0, mm4 | ||
| 460 | pmullw mm0, mm5 | ||
| 461 | punpckhbw mm7, mm4 | ||
| 462 | pmullw mm7, mm6 | ||
| 463 | psubw mm7, mm0 | ||
| 464 | |||
| 465 | movq2dq xmm7, mm7 | ||
| 466 | pxor xmm2, xmm2 | ||
| 467 | SUMW_HORIZON xmm7,xmm0,xmm2 | ||
| 468 | movd r3d, xmm7 ; V | ||
| 469 | movsx r3, r3w | ||
| 470 | imul r3, 17 | ||
| 471 | add r3, 16 | ||
| 472 | sar r3, 5 ; c = (17 * V + 16) >> 5; | ||
| 473 | SSE2_Copy8Times xmm4, r3d ; mm4 = c,c,c,c,c,c,c,c | ||
| 474 | |||
| 475 | ;mov esi, [esp + pushsize + 4] | ||
| 476 | add r4, 16 | ||
| 477 | imul r3, -3 | ||
| 478 | add r3, r4 ; s = a + 16 + (-3)*c | ||
| 479 | SSE2_Copy8Times xmm0, r3d ; xmm0 = s,s,s,s,s,s,s,s | ||
| 480 | |||
| 481 | xor r3, r3 | ||
| 482 | movdqa xmm5, [sse2_plane_mul_b_c] | ||
| 483 | |||
| 484 | get_i_chroma_pred_plane_sse2_1: | ||
| 485 | movdqa xmm2, xmm1 | ||
| 486 | pmullw xmm2, xmm5 | ||
| 487 | paddw xmm2, xmm0 | ||
| 488 | psraw xmm2, 5 | ||
| 489 | packuswb xmm2, xmm2 | ||
| 490 | movq [r0], xmm2 | ||
| 491 | paddw xmm0, xmm4 | ||
| 492 | add r0, 8 | ||
| 493 | inc r3 | ||
| 494 | cmp r3, 8 | ||
| 495 | jnz get_i_chroma_pred_plane_sse2_1 | ||
| 496 | pop r4 | ||
| 497 | pop r3 | ||
| 498 | WELSEMMS | ||
| 499 | ret | ||
| 500 | |||
| 501 | ALIGN 16 | ||
| 502 | ;*********************************************************************** | ||
| 503 | ; 0 |1 |2 |3 |4 | | ||
| 504 | ; 6 |7 |8 |9 |10| | ||
| 505 | ; 11|12|13|14|15| | ||
| 506 | ; 16|17|18|19|20| | ||
| 507 | ; 21|22|23|24|25| | ||
| 508 | ; 7 is the start pixel of current 4x4 block | ||
| 509 | ; pred[7] = ([6]+[0]*2+[1]+2)/4 | ||
| 510 | ; | ||
| 511 | ; void __cdecl WelsI4x4LumaPredDDR_mmx(uint8_t *pred,uint8_t *pRef,int32_t stride) | ||
| 512 | ; | ||
| 513 | ;*********************************************************************** | ||
| 514 | WelsI4x4LumaPredDDR_mmx: | ||
| 515 | ;mov edx,[esp+4] ;pred | ||
| 516 | ;mov eax,[esp+8] ;pRef | ||
| 517 | ;mov ecx,[esp+12] ;stride | ||
| 518 | %assign push_num 0 | ||
| 519 | LOAD_3_PARA | ||
| 520 | %ifndef X86_32 | ||
| 521 | movsx r2, r2d | ||
| 522 | %endif | ||
| 523 | movq mm1,[r1+r2-8] ;get value of 11,decreasing 8 is trying to improve the performance of movq mm1[8] = 11 | ||
| 524 | movq mm2,[r1-8] ;get value of 6 mm2[8] = 6 | ||
| 525 | sub r1, r2 ;mov eax to above line of current block(postion of 1) | ||
| 526 | punpckhbw mm2,[r1-8] ;mm2[8](high 8th byte of mm2) = [0](value of 0), mm2[7]= [6] | ||
| 527 | movd mm3,[r1] ;get value 1, mm3[1] = [1],mm3[2]=[2],mm3[3]=[3] | ||
| 528 | punpckhwd mm1,mm2 ;mm1[8]=[0],mm1[7]=[6],mm1[6]=[11] | ||
| 529 | psllq mm3,18h ;mm3[5]=[1] | ||
| 530 | psrlq mm1,28h ;mm1[3]=[0],mm1[2]=[6],mm1[1]=[11] | ||
| 531 | por mm3,mm1 ;mm3[6]=[3],mm3[5]=[2],mm3[4]=[1],mm3[3]=[0],mm3[2]=[6],mm3[1]=[11] | ||
| 532 | movq mm1,mm3 ;mm1[6]=[3],mm1[5]=[2],mm1[4]=[1],mm1[3]=[0],mm1[2]=[6],mm1[1]=[11] | ||
| 533 | lea r1,[r1+r2*2-8h] ;set eax point to 12 | ||
| 534 | movq mm4,[r1+r2] ;get value of 16, mm4[8]=[16] | ||
| 535 | psllq mm3,8 ;mm3[7]=[3],mm3[6]=[2],mm3[5]=[1],mm3[4]=[0],mm3[3]=[6],mm3[2]=[11],mm3[1]=0 | ||
| 536 | psrlq mm4,38h ;mm4[1]=[16] | ||
| 537 | por mm3,mm4 ;mm3[7]=[3],mm3[6]=[2],mm3[5]=[1],mm3[4]=[0],mm3[3]=[6],mm3[2]=[11],mm3[1]=[16] | ||
| 538 | movq mm2,mm3 ;mm2[7]=[3],mm2[6]=[2],mm2[5]=[1],mm2[4]=[0],mm2[3]=[6],mm2[2]=[11],mm2[1]=[16] | ||
| 539 | movq mm4,[r1+r2*2] ;mm4[8]=[21] | ||
| 540 | psllq mm3,8 ;mm3[8]=[3],mm3[7]=[2],mm3[6]=[1],mm3[5]=[0],mm3[4]=[6],mm3[3]=[11],mm3[2]=[16],mm3[1]=0 | ||
| 541 | psrlq mm4,38h ;mm4[1]=[21] | ||
| 542 | por mm3,mm4 ;mm3[8]=[3],mm3[7]=[2],mm3[6]=[1],mm3[5]=[0],mm3[4]=[6],mm3[3]=[11],mm3[2]=[16],mm3[1]=[21] | ||
| 543 | movq mm4,mm3 ;mm4[8]=[3],mm4[7]=[2],mm4[6]=[1],mm4[5]=[0],mm4[4]=[6],mm4[3]=[11],mm4[2]=[16],mm4[1]=[21] | ||
| 544 | pavgb mm3,mm1 ;mm3=([11]+[21]+1)/2 | ||
| 545 | pxor mm1,mm4 ;find odd value in the lowest bit of each byte | ||
| 546 | pand mm1,[mmx_01bytes] ;set the odd bit | ||
| 547 | psubusb mm3,mm1 ;decrease 1 from odd bytes | ||
| 548 | pavgb mm2,mm3 ;mm2=(([11]+[21]+1)/2+1+[16])/2 | ||
| 549 | |||
| 550 | movd [r0+12],mm2 | ||
| 551 | psrlq mm2,8 | ||
| 552 | movd [r0+8],mm2 | ||
| 553 | psrlq mm2,8 | ||
| 554 | movd [r0+4],mm2 | ||
| 555 | psrlq mm2,8 | ||
| 556 | movd [r0],mm2 | ||
| 557 | WELSEMMS | ||
| 558 | ret | ||
| 559 | |||
| 560 | ALIGN 16 | ||
| 561 | ;*********************************************************************** | ||
| 562 | ; 0 |1 |2 |3 |4 | | ||
| 563 | ; 5 |6 |7 |8 |9 | | ||
| 564 | ; 10|11|12|13|14| | ||
| 565 | ; 15|16|17|18|19| | ||
| 566 | ; 20|21|22|23|24| | ||
| 567 | ; 6 is the start pixel of current 4x4 block | ||
| 568 | ; pred[6] = ([1]+[2]+[3]+[4]+[5]+[10]+[15]+[20]+4)/8 | ||
| 569 | ; | ||
| 570 | ; void __cdecl WelsI4x4LumaPredDc_sse2(uint8_t *pred,uint8_t *pRef,int32_t stride) | ||
| 571 | ; | ||
| 572 | ;*********************************************************************** | ||
| 573 | WelsI4x4LumaPredDc_sse2: | ||
| 574 | push r3 | ||
| 575 | push r4 | ||
| 576 | %assign push_num 2 | ||
| 577 | LOAD_3_PARA | ||
| 578 | %ifndef X86_32 | ||
| 579 | movsx r2, r2d | ||
| 580 | %endif | ||
| 581 | movzx r4, byte [r1-1h] | ||
| 582 | sub r1, r2 | ||
| 583 | movd xmm0, [r1] | ||
| 584 | pxor xmm1, xmm1 | ||
| 585 | psadbw xmm0, xmm1 | ||
| 586 | xor r3, r3 | ||
| 587 | movd r3d, xmm0 | ||
| 588 | add r3, r4 | ||
| 589 | movzx r4, byte [r1+r2*2-1h] | ||
| 590 | add r3, r4 | ||
| 591 | |||
| 592 | lea r1, [r1+r2*2-1] | ||
| 593 | movzx r4, byte [r1+r2] | ||
| 594 | add r3, r4 | ||
| 595 | |||
| 596 | movzx r4, byte [r1+r2*2] | ||
| 597 | add r3, r4 | ||
| 598 | add r3, 4 | ||
| 599 | sar r3, 3 | ||
| 600 | imul r3, 0x01010101 | ||
| 601 | |||
| 602 | movd xmm0, r3d | ||
| 603 | pshufd xmm0, xmm0, 0 | ||
| 604 | movdqa [r0], xmm0 | ||
| 605 | pop r4 | ||
| 606 | pop r3 | ||
| 607 | ret | ||
| 608 | |||
| 609 | ALIGN 16 | ||
| 610 | ;*********************************************************************** | ||
| 611 | ; void __cdecl WelsIChromaPredH_mmx(uint8_t *pred, uint8_t *pRef, int32_t stride) | ||
| 612 | ; copy 8 pixel of 8 line from left | ||
| 613 | ;*********************************************************************** | ||
| 614 | %macro MMX_PRED_H_8X8_ONE_LINE 4 | ||
| 615 | movq %1, [%3-8] | ||
| 616 | psrlq %1, 38h | ||
| 617 | |||
| 618 | ;pmuludq %1, [mmx_01bytes] ;extend to 4 bytes | ||
| 619 | pmullw %1, [mmx_01bytes] | ||
| 620 | pshufw %1, %1, 0 | ||
| 621 | movq [%4], %1 | ||
| 622 | %endmacro | ||
| 623 | |||
| 624 | %macro MMX_PRED_H_8X8_ONE_LINEE 4 | ||
| 625 | movq %1, [%3+r2-8] | ||
| 626 | psrlq %1, 38h | ||
| 627 | |||
| 628 | ;pmuludq %1, [mmx_01bytes] ;extend to 4 bytes | ||
| 629 | pmullw %1, [mmx_01bytes] | ||
| 630 | pshufw %1, %1, 0 | ||
| 631 | movq [%4], %1 | ||
| 632 | %endmacro | ||
| 633 | |||
| 634 | WELS_EXTERN WelsIChromaPredH_mmx | ||
| 635 | WelsIChromaPredH_mmx: | ||
| 636 | ;mov edx, [esp+4] ;pred | ||
| 637 | ;mov eax, [esp+8] ;pRef | ||
| 638 | ;mov ecx, [esp+12] ;stride | ||
| 639 | %assign push_num 0 | ||
| 640 | LOAD_3_PARA | ||
| 641 | %ifndef X86_32 | ||
| 642 | movsx r2, r2d | ||
| 643 | %endif | ||
| 644 | movq mm0, [r1-8] | ||
| 645 | psrlq mm0, 38h | ||
| 646 | |||
| 647 | ;pmuludq mm0, [mmx_01bytes] ;extend to 4 bytes | ||
| 648 | pmullw mm0, [mmx_01bytes] | ||
| 649 | pshufw mm0, mm0, 0 | ||
| 650 | movq [r0], mm0 | ||
| 651 | |||
| 652 | MMX_PRED_H_8X8_ONE_LINEE mm0, mm1, r1,r0+8 | ||
| 653 | |||
| 654 | lea r1,[r1+r2*2] | ||
| 655 | MMX_PRED_H_8X8_ONE_LINE mm0, mm1, r1,r0+16 | ||
| 656 | |||
| 657 | MMX_PRED_H_8X8_ONE_LINEE mm0, mm1, r1,r0+24 | ||
| 658 | |||
| 659 | lea r1,[r1+r2*2] | ||
| 660 | MMX_PRED_H_8X8_ONE_LINE mm0, mm1, r1,r0+32 | ||
| 661 | |||
| 662 | MMX_PRED_H_8X8_ONE_LINEE mm0, mm1, r1,r0+40 | ||
| 663 | |||
| 664 | lea r1,[r1+r2*2] | ||
| 665 | MMX_PRED_H_8X8_ONE_LINE mm0, mm1, r1,r0+48 | ||
| 666 | |||
| 667 | MMX_PRED_H_8X8_ONE_LINEE mm0, mm1, r1,r0+56 | ||
| 668 | WELSEMMS | ||
| 669 | ret | ||
| 670 | |||
| 671 | ALIGN 16 | ||
| 672 | ;*********************************************************************** | ||
| 673 | ; void __cdecl WelsI4x4LumaPredV_sse2(uint8_t *pred, uint8_t *pRef, int32_t stride) | ||
| 674 | ; copy pixels from top 4 pixels | ||
| 675 | ;*********************************************************************** | ||
| 676 | WELS_EXTERN WelsI4x4LumaPredV_sse2 | ||
| 677 | WelsI4x4LumaPredV_sse2: | ||
| 678 | %assign push_num 0 | ||
| 679 | LOAD_3_PARA | ||
| 680 | %ifndef X86_32 | ||
| 681 | movsx r2, r2d | ||
| 682 | %endif | ||
| 683 | sub r1, r2 | ||
| 684 | movd xmm0, [r1] | ||
| 685 | pshufd xmm0, xmm0, 0 | ||
| 686 | movdqa [r0], xmm0 | ||
| 687 | ret | ||
| 688 | |||
| 689 | ALIGN 16 | ||
| 690 | ;*********************************************************************** | ||
| 691 | ; void __cdecl WelsIChromaPredV_sse2(uint8_t *pred, uint8_t *pRef, int32_t stride) | ||
| 692 | ; copy 8 pixels from top 8 pixels | ||
| 693 | ;*********************************************************************** | ||
| 694 | WELS_EXTERN WelsIChromaPredV_sse2 | ||
| 695 | WelsIChromaPredV_sse2: | ||
| 696 | %assign push_num 0 | ||
| 697 | LOAD_3_PARA | ||
| 698 | %ifndef X86_32 | ||
| 699 | movsx r2, r2d | ||
| 700 | %endif | ||
| 701 | sub r1, r2 | ||
| 702 | movq xmm0, [r1] | ||
| 703 | movdqa xmm1, xmm0 | ||
| 704 | punpcklqdq xmm0, xmm1 | ||
| 705 | movdqa [r0], xmm0 | ||
| 706 | movdqa [r0+16], xmm0 | ||
| 707 | movdqa [r0+32], xmm0 | ||
| 708 | movdqa [r0+48], xmm0 | ||
| 709 | ret | ||
| 710 | |||
| 711 | ALIGN 16 | ||
| 712 | ;*********************************************************************** | ||
| 713 | ; lt|t0|t1|t2|t3| | ||
| 714 | ; l0| | ||
| 715 | ; l1| | ||
| 716 | ; l2| | ||
| 717 | ; l3| | ||
| 718 | ; t3 will never been used | ||
| 719 | ; destination: | ||
| 720 | ; |a |b |c |d | | ||
| 721 | ; |e |f |a |b | | ||
| 722 | ; |g |h |e |f | | ||
| 723 | ; |i |j |g |h | | ||
| 724 | |||
| 725 | ; a = (1 + lt + l0)>>1 | ||
| 726 | ; e = (1 + l0 + l1)>>1 | ||
| 727 | ; g = (1 + l1 + l2)>>1 | ||
| 728 | ; i = (1 + l2 + l3)>>1 | ||
| 729 | |||
| 730 | ; d = (2 + t0 + (t1<<1) + t2)>>2 | ||
| 731 | ; c = (2 + lt + (t0<<1) + t1)>>2 | ||
| 732 | ; b = (2 + l0 + (lt<<1) + t0)>>2 | ||
| 733 | |||
| 734 | ; f = (2 + l1 + (l0<<1) + lt)>>2 | ||
| 735 | ; h = (2 + l2 + (l1<<1) + l0)>>2 | ||
| 736 | ; j = (2 + l3 + (l2<<1) + l1)>>2 | ||
| 737 | ; [b a f e h g j i] + [d c b a] --> mov to memory | ||
| 738 | ; | ||
| 739 | ; void WelsI4x4LumaPredHD_mmx(uint8_t *pred,uint8_t *pRef,int32_t stride) | ||
| 740 | ;*********************************************************************** | ||
| 741 | WELS_EXTERN WelsI4x4LumaPredHD_mmx | ||
| 742 | WelsI4x4LumaPredHD_mmx: | ||
| 743 | %assign push_num 0 | ||
| 744 | LOAD_3_PARA | ||
| 745 | %ifndef X86_32 | ||
| 746 | movsx r2, r2d | ||
| 747 | %endif | ||
| 748 | sub r1, r2 | ||
| 749 | movd mm0, [r1-1] ; mm0 = [xx xx xx xx t2 t1 t0 lt] | ||
| 750 | psllq mm0, 20h ; mm0 = [t2 t1 t0 lt xx xx xx xx] | ||
| 751 | |||
| 752 | movd mm1, [r1+2*r2-4] | ||
| 753 | punpcklbw mm1, [r1+r2-4] ; mm1[7] = l0, mm1[6] = l1 | ||
| 754 | lea r1, [r1+2*r2] | ||
| 755 | movd mm2, [r1+2*r2-4] | ||
| 756 | punpcklbw mm2, [r1+r2-4] ; mm2[7] = l2, mm2[6] = l3 | ||
| 757 | punpckhwd mm2, mm1 ; mm2 = [l0 l1 l2 l3 xx xx xx xx] | ||
| 758 | psrlq mm2, 20h | ||
| 759 | pxor mm0, mm2 ; mm0 = [t2 t1 t0 lt l0 l1 l2 l3] | ||
| 760 | |||
| 761 | movq mm1, mm0 | ||
| 762 | psrlq mm1, 10h ; mm1 = [xx xx t2 t1 t0 lt l0 l1] | ||
| 763 | movq mm2, mm0 | ||
| 764 | psrlq mm2, 8h ; mm2 = [xx t2 t1 t0 lt l0 l1 l2] | ||
| 765 | movq mm3, mm2 | ||
| 766 | movq mm4, mm1 | ||
| 767 | pavgb mm1, mm0 | ||
| 768 | |||
| 769 | pxor mm4, mm0 ; find odd value in the lowest bit of each byte | ||
| 770 | pand mm4, [mmx_01bytes] ; set the odd bit | ||
| 771 | psubusb mm1, mm4 ; decrease 1 from odd bytes | ||
| 772 | |||
| 773 | pavgb mm2, mm1 ; mm2 = [xx xx d c b f h j] | ||
| 774 | |||
| 775 | movq mm4, mm0 | ||
| 776 | pavgb mm3, mm4 ; mm3 = [xx xx xx xx a e g i] | ||
| 777 | punpcklbw mm3, mm2 ; mm3 = [b a f e h g j i] | ||
| 778 | |||
| 779 | psrlq mm2, 20h | ||
| 780 | psllq mm2, 30h ; mm2 = [d c 0 0 0 0 0 0] | ||
| 781 | movq mm4, mm3 | ||
| 782 | psrlq mm4, 10h ; mm4 = [0 0 b a f e h j] | ||
| 783 | pxor mm2, mm4 ; mm2 = [d c b a xx xx xx xx] | ||
| 784 | psrlq mm2, 20h ; mm2 = [xx xx xx xx d c b a] | ||
| 785 | |||
| 786 | movd [r0], mm2 | ||
| 787 | movd [r0+12], mm3 | ||
| 788 | psrlq mm3, 10h | ||
| 789 | movd [r0+8], mm3 | ||
| 790 | psrlq mm3, 10h | ||
| 791 | movd [r0+4], mm3 | ||
| 792 | WELSEMMS | ||
| 793 | ret | ||
| 794 | |||
| 795 | ALIGN 16 | ||
| 796 | ;*********************************************************************** | ||
| 797 | ; lt|t0|t1|t2|t3| | ||
| 798 | ; l0| | ||
| 799 | ; l1| | ||
| 800 | ; l2| | ||
| 801 | ; l3| | ||
| 802 | ; t3 will never been used | ||
| 803 | ; destination: | ||
| 804 | ; |a |b |c |d | | ||
| 805 | ; |c |d |e |f | | ||
| 806 | ; |e |f |g |g | | ||
| 807 | ; |g |g |g |g | | ||
| 808 | |||
| 809 | ; a = (1 + l0 + l1)>>1 | ||
| 810 | ; c = (1 + l1 + l2)>>1 | ||
| 811 | ; e = (1 + l2 + l3)>>1 | ||
| 812 | ; g = l3 | ||
| 813 | |||
| 814 | ; b = (2 + l0 + (l1<<1) + l2)>>2 | ||
| 815 | ; d = (2 + l1 + (l2<<1) + l3)>>2 | ||
| 816 | ; f = (2 + l2 + (l3<<1) + l3)>>2 | ||
| 817 | |||
| 818 | ; [g g f e d c b a] + [g g g g] --> mov to memory | ||
| 819 | ; | ||
| 820 | ; void WelsI4x4LumaPredHU_mmx(uint8_t *pred,uint8_t *pRef,int32_t stride) | ||
| 821 | ;*********************************************************************** | ||
| 822 | WELS_EXTERN WelsI4x4LumaPredHU_mmx | ||
| 823 | WelsI4x4LumaPredHU_mmx: | ||
| 824 | %assign push_num 0 | ||
| 825 | LOAD_3_PARA | ||
| 826 | %ifndef X86_32 | ||
| 827 | movsx r2, r2d | ||
| 828 | %endif | ||
| 829 | movd mm0, [r1-4] ; mm0[3] = l0 | ||
| 830 | punpcklbw mm0, [r1+r2-4] ; mm0[7] = l1, mm0[6] = l0 | ||
| 831 | lea r1, [r1+2*r2] | ||
| 832 | movd mm2, [r1-4] ; mm2[3] = l2 | ||
| 833 | movd mm4, [r1+r2-4] ; mm4[3] = l3 | ||
| 834 | punpcklbw mm2, mm4 | ||
| 835 | punpckhwd mm0, mm2 ; mm0 = [l3 l2 l1 l0 xx xx xx xx] | ||
| 836 | |||
| 837 | psrlq mm4, 18h | ||
| 838 | psllq mm4, 38h ; mm4 = [l3 xx xx xx xx xx xx xx] | ||
| 839 | psrlq mm0, 8h | ||
| 840 | pxor mm0, mm4 ; mm0 = [l3 l3 l2 l1 l0 xx xx xx] | ||
| 841 | |||
| 842 | movq mm1, mm0 | ||
| 843 | psllq mm1, 8h ; mm1 = [l3 l2 l1 l0 xx xx xx xx] | ||
| 844 | movq mm3, mm1 ; mm3 = [l3 l2 l1 l0 xx xx xx xx] | ||
| 845 | pavgb mm1, mm0 ; mm1 = [g e c a xx xx xx xx] | ||
| 846 | |||
| 847 | movq mm2, mm0 | ||
| 848 | psllq mm2, 10h ; mm2 = [l2 l1 l0 xx xx xx xx xx] | ||
| 849 | movq mm5, mm2 | ||
| 850 | pavgb mm2, mm0 | ||
| 851 | |||
| 852 | pxor mm5, mm0 ; find odd value in the lowest bit of each byte | ||
| 853 | pand mm5, [mmx_01bytes] ; set the odd bit | ||
| 854 | psubusb mm2, mm5 ; decrease 1 from odd bytes | ||
| 855 | |||
| 856 | pavgb mm2, mm3 ; mm2 = [f d b xx xx xx xx xx] | ||
| 857 | |||
| 858 | psrlq mm2, 8h | ||
| 859 | pxor mm2, mm4 ; mm2 = [g f d b xx xx xx xx] | ||
| 860 | |||
| 861 | punpckhbw mm1, mm2 ; mm1 = [g g f e d c b a] | ||
| 862 | punpckhbw mm4, mm4 ; mm4 = [g g xx xx xx xx xx xx] | ||
| 863 | punpckhbw mm4, mm4 ; mm4 = [g g g g xx xx xx xx] | ||
| 864 | |||
| 865 | psrlq mm4, 20h | ||
| 866 | movd [r0+12], mm4 | ||
| 867 | |||
| 868 | movd [r0], mm1 | ||
| 869 | psrlq mm1, 10h | ||
| 870 | movd [r0+4], mm1 | ||
| 871 | psrlq mm1, 10h | ||
| 872 | movd [r0+8], mm1 | ||
| 873 | WELSEMMS | ||
| 874 | ret | ||
| 875 | |||
| 876 | |||
| 877 | |||
| 878 | ALIGN 16 | ||
| 879 | ;*********************************************************************** | ||
| 880 | ; lt|t0|t1|t2|t3| | ||
| 881 | ; l0| | ||
| 882 | ; l1| | ||
| 883 | ; l2| | ||
| 884 | ; l3| | ||
| 885 | ; l3 will never been used | ||
| 886 | ; destination: | ||
| 887 | ; |a |b |c |d | | ||
| 888 | ; |e |f |g |h | | ||
| 889 | ; |i |a |b |c | | ||
| 890 | ; |j |e |f |g | | ||
| 891 | |||
| 892 | ; a = (1 + lt + t0)>>1 | ||
| 893 | ; b = (1 + t0 + t1)>>1 | ||
| 894 | ; c = (1 + t1 + t2)>>1 | ||
| 895 | ; d = (1 + t2 + t3)>>1 | ||
| 896 | |||
| 897 | ; e = (2 + l0 + (lt<<1) + t0)>>2 | ||
| 898 | ; f = (2 + lt + (t0<<1) + t1)>>2 | ||
| 899 | ; g = (2 + t0 + (t1<<1) + t2)>>2 | ||
| 900 | |||
| 901 | ; h = (2 + t1 + (t2<<1) + t3)>>2 | ||
| 902 | ; i = (2 + lt + (l0<<1) + l1)>>2 | ||
| 903 | ; j = (2 + l0 + (l1<<1) + l2)>>2 | ||
| 904 | ; | ||
| 905 | ; void WelsI4x4LumaPredVR_mmx(uint8_t *pred,uint8_t *pRef,int32_t stride) | ||
| 906 | ;*********************************************************************** | ||
| 907 | WELS_EXTERN WelsI4x4LumaPredVR_mmx | ||
| 908 | WelsI4x4LumaPredVR_mmx: | ||
| 909 | %assign push_num 0 | ||
| 910 | LOAD_3_PARA | ||
| 911 | %ifndef X86_32 | ||
| 912 | movsx r2, r2d | ||
| 913 | %endif | ||
| 914 | sub r1, r2 | ||
| 915 | movq mm0, [r1-1] ; mm0 = [xx xx xx t3 t2 t1 t0 lt] | ||
| 916 | psllq mm0, 18h ; mm0 = [t3 t2 t1 t0 lt xx xx xx] | ||
| 917 | |||
| 918 | movd mm1, [r1+2*r2-4] | ||
| 919 | punpcklbw mm1, [r1+r2-4] ; mm1[7] = l0, mm1[6] = l1 | ||
| 920 | lea r1, [r1+2*r2] | ||
| 921 | movq mm2, [r1+r2-8] ; mm2[7] = l2 | ||
| 922 | punpckhwd mm2, mm1 ; mm2 = [l0 l1 l2 xx xx xx xx xx] | ||
| 923 | psrlq mm2, 28h | ||
| 924 | pxor mm0, mm2 ; mm0 = [t3 t2 t1 t0 lt l0 l1 l2] | ||
| 925 | |||
| 926 | movq mm1, mm0 | ||
| 927 | psllq mm1, 8h ; mm1 = [t2 t1 t0 lt l0 l1 l2 xx] | ||
| 928 | pavgb mm1, mm0 ; mm1 = [d c b a xx xx xx xx] | ||
| 929 | |||
| 930 | movq mm2, mm0 | ||
| 931 | psllq mm2, 10h ; mm2 = [t1 t0 lt l0 l1 l2 xx xx] | ||
| 932 | movq mm3, mm2 | ||
| 933 | pavgb mm2, mm0 | ||
| 934 | |||
| 935 | pxor mm3, mm0 ; find odd value in the lowest bit of each byte | ||
| 936 | pand mm3, [mmx_01bytes] ; set the odd bit | ||
| 937 | psubusb mm2, mm3 ; decrease 1 from odd bytes | ||
| 938 | |||
| 939 | movq mm3, mm0 | ||
| 940 | psllq mm3, 8h ; mm3 = [t2 t1 t0 lt l0 l1 l2 xx] | ||
| 941 | pavgb mm3, mm2 ; mm3 = [h g f e i j xx xx] | ||
| 942 | movq mm2, mm3 | ||
| 943 | |||
| 944 | psrlq mm1, 20h ; mm1 = [xx xx xx xx d c b a] | ||
| 945 | movd [r0], mm1 | ||
| 946 | |||
| 947 | psrlq mm2, 20h ; mm2 = [xx xx xx xx h g f e] | ||
| 948 | movd [r0+4], mm2 | ||
| 949 | |||
| 950 | movq mm4, mm3 | ||
| 951 | psllq mm4, 20h | ||
| 952 | psrlq mm4, 38h ; mm4 = [xx xx xx xx xx xx xx i] | ||
| 953 | |||
| 954 | movq mm5, mm3 | ||
| 955 | psllq mm5, 28h | ||
| 956 | psrlq mm5, 38h ; mm5 = [xx xx xx xx xx xx xx j] | ||
| 957 | |||
| 958 | psllq mm1, 8h | ||
| 959 | pxor mm4, mm1 ; mm4 = [xx xx xx xx c b a i] | ||
| 960 | movd [r0+8], mm4 | ||
| 961 | |||
| 962 | psllq mm2, 8h | ||
| 963 | pxor mm5, mm2 ; mm5 = [xx xx xx xx g f e j] | ||
| 964 | movd [r0+12], mm5 | ||
| 965 | WELSEMMS | ||
| 966 | ret | ||
| 967 | |||
| 968 | ALIGN 16 | ||
| 969 | ;*********************************************************************** | ||
| 970 | ; lt|t0|t1|t2|t3|t4|t5|t6|t7 | ||
| 971 | ; l0| | ||
| 972 | ; l1| | ||
| 973 | ; l2| | ||
| 974 | ; l3| | ||
| 975 | ; lt,t0,t1,t2,t3 will never been used | ||
| 976 | ; destination: | ||
| 977 | ; |a |b |c |d | | ||
| 978 | ; |b |c |d |e | | ||
| 979 | ; |c |d |e |f | | ||
| 980 | ; |d |e |f |g | | ||
| 981 | |||
| 982 | ; a = (2 + t0 + t2 + (t1<<1))>>2 | ||
| 983 | ; b = (2 + t1 + t3 + (t2<<1))>>2 | ||
| 984 | ; c = (2 + t2 + t4 + (t3<<1))>>2 | ||
| 985 | ; d = (2 + t3 + t5 + (t4<<1))>>2 | ||
| 986 | |||
| 987 | ; e = (2 + t4 + t6 + (t5<<1))>>2 | ||
| 988 | ; f = (2 + t5 + t7 + (t6<<1))>>2 | ||
| 989 | ; g = (2 + t6 + t7 + (t7<<1))>>2 | ||
| 990 | |||
| 991 | ; [g f e d c b a] --> mov to memory | ||
| 992 | ; | ||
| 993 | ; void WelsI4x4LumaPredDDL_mmx(uint8_t *pred,uint8_t *pRef,int32_t stride) | ||
| 994 | ;*********************************************************************** | ||
| 995 | WELS_EXTERN WelsI4x4LumaPredDDL_mmx | ||
| 996 | WelsI4x4LumaPredDDL_mmx: | ||
| 997 | %assign push_num 0 | ||
| 998 | LOAD_3_PARA | ||
| 999 | %ifndef X86_32 | ||
| 1000 | movsx r2, r2d | ||
| 1001 | %endif | ||
| 1002 | sub r1, r2 | ||
| 1003 | movq mm0, [r1] ; mm0 = [t7 t6 t5 t4 t3 t2 t1 t0] | ||
| 1004 | movq mm1, mm0 | ||
| 1005 | movq mm2, mm0 | ||
| 1006 | |||
| 1007 | movq mm3, mm0 | ||
| 1008 | psrlq mm3, 38h | ||
| 1009 | psllq mm3, 38h ; mm3 = [t7 xx xx xx xx xx xx xx] | ||
| 1010 | |||
| 1011 | psllq mm1, 8h ; mm1 = [t6 t5 t4 t3 t2 t1 t0 xx] | ||
| 1012 | psrlq mm2, 8h | ||
| 1013 | pxor mm2, mm3 ; mm2 = [t7 t7 t6 t5 t4 t3 t2 t1] | ||
| 1014 | |||
| 1015 | movq mm3, mm1 | ||
| 1016 | pavgb mm1, mm2 | ||
| 1017 | pxor mm3, mm2 ; find odd value in the lowest bit of each byte | ||
| 1018 | pand mm3, [mmx_01bytes] ; set the odd bit | ||
| 1019 | psubusb mm1, mm3 ; decrease 1 from odd bytes | ||
| 1020 | |||
| 1021 | pavgb mm0, mm1 ; mm0 = [g f e d c b a xx] | ||
| 1022 | |||
| 1023 | psrlq mm0, 8h | ||
| 1024 | movd [r0], mm0 | ||
| 1025 | psrlq mm0, 8h | ||
| 1026 | movd [r0+4], mm0 | ||
| 1027 | psrlq mm0, 8h | ||
| 1028 | movd [r0+8], mm0 | ||
| 1029 | psrlq mm0, 8h | ||
| 1030 | movd [r0+12], mm0 | ||
| 1031 | WELSEMMS | ||
| 1032 | ret | ||
| 1033 | |||
| 1034 | |||
| 1035 | ALIGN 16 | ||
| 1036 | ;*********************************************************************** | ||
| 1037 | ; lt|t0|t1|t2|t3|t4|t5|t6|t7 | ||
| 1038 | ; l0| | ||
| 1039 | ; l1| | ||
| 1040 | ; l2| | ||
| 1041 | ; l3| | ||
| 1042 | ; lt,t0,t1,t2,t3 will never been used | ||
| 1043 | ; destination: | ||
| 1044 | ; |a |b |c |d | | ||
| 1045 | ; |e |f |g |h | | ||
| 1046 | ; |b |c |d |i | | ||
| 1047 | ; |f |g |h |j | | ||
| 1048 | |||
| 1049 | ; a = (1 + t0 + t1)>>1 | ||
| 1050 | ; b = (1 + t1 + t2)>>1 | ||
| 1051 | ; c = (1 + t2 + t3)>>1 | ||
| 1052 | ; d = (1 + t3 + t4)>>1 | ||
| 1053 | ; i = (1 + t4 + t5)>>1 | ||
| 1054 | |||
| 1055 | ; e = (2 + t0 + (t1<<1) + t2)>>2 | ||
| 1056 | ; f = (2 + t1 + (t2<<1) + t3)>>2 | ||
| 1057 | ; g = (2 + t2 + (t3<<1) + t4)>>2 | ||
| 1058 | ; h = (2 + t3 + (t4<<1) + t5)>>2 | ||
| 1059 | ; j = (2 + t4 + (t5<<1) + t6)>>2 | ||
| 1060 | |||
| 1061 | ; [i d c b a] + [j h g f e] --> mov to memory | ||
| 1062 | ; | ||
| 1063 | ; void WelsI4x4LumaPredVL_mmx(uint8_t *pred,uint8_t *pRef,int32_t stride) | ||
| 1064 | ;*********************************************************************** | ||
| 1065 | WELS_EXTERN WelsI4x4LumaPredVL_mmx | ||
| 1066 | WelsI4x4LumaPredVL_mmx: | ||
| 1067 | %assign push_num 0 | ||
| 1068 | LOAD_3_PARA | ||
| 1069 | %ifndef X86_32 | ||
| 1070 | movsx r2, r2d | ||
| 1071 | %endif | ||
| 1072 | sub r1, r2 | ||
| 1073 | movq mm0, [r1] ; mm0 = [t7 t6 t5 t4 t3 t2 t1 t0] | ||
| 1074 | movq mm1, mm0 | ||
| 1075 | movq mm2, mm0 | ||
| 1076 | |||
| 1077 | psrlq mm1, 8h ; mm1 = [xx t7 t6 t5 t4 t3 t2 t1] | ||
| 1078 | psrlq mm2, 10h ; mm2 = [xx xx t7 t6 t5 t4 t3 t2] | ||
| 1079 | |||
| 1080 | movq mm3, mm1 | ||
| 1081 | pavgb mm3, mm0 ; mm3 = [xx xx xx i d c b a] | ||
| 1082 | |||
| 1083 | movq mm4, mm2 | ||
| 1084 | pavgb mm2, mm0 | ||
| 1085 | pxor mm4, mm0 ; find odd value in the lowest bit of each byte | ||
| 1086 | pand mm4, [mmx_01bytes] ; set the odd bit | ||
| 1087 | psubusb mm2, mm4 ; decrease 1 from odd bytes | ||
| 1088 | |||
| 1089 | pavgb mm2, mm1 ; mm2 = [xx xx xx j h g f e] | ||
| 1090 | |||
| 1091 | movd [r0], mm3 | ||
| 1092 | psrlq mm3, 8h | ||
| 1093 | movd [r0+8], mm3 | ||
| 1094 | |||
| 1095 | movd [r0+4], mm2 | ||
| 1096 | psrlq mm2, 8h | ||
| 1097 | movd [r0+12], mm2 | ||
| 1098 | WELSEMMS | ||
| 1099 | ret | ||
| 1100 | |||
| 1101 | ALIGN 16 | ||
| 1102 | ;*********************************************************************** | ||
| 1103 | ; | ||
| 1104 | ; void WelsIChromaPredDc_sse2(uint8_t *pred, uint8_t *pRef, int32_t stride) | ||
| 1105 | ;*********************************************************************** | ||
| 1106 | WELS_EXTERN WelsIChromaPredDc_sse2 | ||
| 1107 | WelsIChromaPredDc_sse2: | ||
| 1108 | push r3 | ||
| 1109 | push r4 | ||
| 1110 | %assign push_num 2 | ||
| 1111 | LOAD_3_PARA | ||
| 1112 | %ifndef X86_32 | ||
| 1113 | movsx r2, r2d | ||
| 1114 | %endif | ||
| 1115 | sub r1, r2 | ||
| 1116 | movq mm0, [r1] | ||
| 1117 | |||
| 1118 | movzx r3, byte [r1+r2-0x01] ; l1 | ||
| 1119 | lea r1, [r1+2*r2] | ||
| 1120 | movzx r4, byte [r1-0x01] ; l2 | ||
| 1121 | add r3, r4 | ||
| 1122 | movzx r4, byte [r1+r2-0x01] ; l3 | ||
| 1123 | add r3, r4 | ||
| 1124 | lea r1, [r1+2*r2] | ||
| 1125 | movzx r4, byte [r1-0x01] ; l4 | ||
| 1126 | add r3, r4 | ||
| 1127 | movd mm1, r3d ; mm1 = l1+l2+l3+l4 | ||
| 1128 | |||
| 1129 | movzx r3, byte [r1+r2-0x01] ; l5 | ||
| 1130 | lea r1, [r1+2*r2] | ||
| 1131 | movzx r4, byte [r1-0x01] ; l6 | ||
| 1132 | add r3, r4 | ||
| 1133 | movzx r4, byte [r1+r2-0x01] ; l7 | ||
| 1134 | add r3, r4 | ||
| 1135 | lea r1, [r1+2*r2] | ||
| 1136 | movzx r4, byte [r1-0x01] ; l8 | ||
| 1137 | add r3, r4 | ||
| 1138 | movd mm2, r3d ; mm2 = l5+l6+l7+l8 | ||
| 1139 | |||
| 1140 | movq mm3, mm0 | ||
| 1141 | psrlq mm0, 0x20 | ||
| 1142 | psllq mm3, 0x20 | ||
| 1143 | psrlq mm3, 0x20 | ||
| 1144 | pxor mm4, mm4 | ||
| 1145 | psadbw mm0, mm4 | ||
| 1146 | psadbw mm3, mm4 ; sum1 = mm3+mm1, sum2 = mm0, sum3 = mm2 | ||
| 1147 | |||
| 1148 | paddq mm3, mm1 | ||
| 1149 | movq mm1, mm2 | ||
| 1150 | paddq mm1, mm0; ; sum1 = mm3, sum2 = mm0, sum3 = mm2, sum4 = mm1 | ||
| 1151 | |||
| 1152 | movq mm4, [mmx_0x02] | ||
| 1153 | |||
| 1154 | paddq mm0, mm4 | ||
| 1155 | psrlq mm0, 0x02 | ||
| 1156 | |||
| 1157 | paddq mm2, mm4 | ||
| 1158 | psrlq mm2, 0x02 | ||
| 1159 | |||
| 1160 | paddq mm3, mm4 | ||
| 1161 | paddq mm3, mm4 | ||
| 1162 | psrlq mm3, 0x03 | ||
| 1163 | |||
| 1164 | paddq mm1, mm4 | ||
| 1165 | paddq mm1, mm4 | ||
| 1166 | psrlq mm1, 0x03 | ||
| 1167 | |||
| 1168 | pmuludq mm0, [mmx_01bytes] | ||
| 1169 | pmuludq mm3, [mmx_01bytes] | ||
| 1170 | psllq mm0, 0x20 | ||
| 1171 | pxor mm0, mm3 ; mm0 = m_up | ||
| 1172 | |||
| 1173 | pmuludq mm2, [mmx_01bytes] | ||
| 1174 | pmuludq mm1, [mmx_01bytes] | ||
| 1175 | psllq mm1, 0x20 | ||
| 1176 | pxor mm1, mm2 ; mm2 = m_down | ||
| 1177 | |||
| 1178 | movq [r0], mm0 | ||
| 1179 | movq [r0+0x08], mm0 | ||
| 1180 | movq [r0+0x10], mm0 | ||
| 1181 | movq [r0+0x18], mm0 | ||
| 1182 | |||
| 1183 | movq [r0+0x20], mm1 | ||
| 1184 | movq [r0+0x28], mm1 | ||
| 1185 | movq [r0+0x30], mm1 | ||
| 1186 | movq [r0+0x38], mm1 | ||
| 1187 | |||
| 1188 | pop r4 | ||
| 1189 | pop r3 | ||
| 1190 | WELSEMMS | ||
| 1191 | ret | ||
| 1192 | |||
| 1193 | |||
| 1194 | |||
| 1195 | ALIGN 16 | ||
| 1196 | ;*********************************************************************** | ||
| 1197 | ; | ||
| 1198 | ; void WelsI16x16LumaPredDc_sse2(uint8_t *pred, uint8_t *pRef, int32_t stride) | ||
| 1199 | ;*********************************************************************** | ||
| 1200 | WELS_EXTERN WelsI16x16LumaPredDc_sse2 | ||
| 1201 | WelsI16x16LumaPredDc_sse2: | ||
| 1202 | push r3 | ||
| 1203 | push r4 | ||
| 1204 | %assign push_num 2 | ||
| 1205 | LOAD_3_PARA | ||
| 1206 | %ifndef X86_32 | ||
| 1207 | movsx r2, r2d | ||
| 1208 | %endif | ||
| 1209 | sub r1, r2 | ||
| 1210 | movdqa xmm0, [r1] ; read one row | ||
| 1211 | pxor xmm1, xmm1 | ||
| 1212 | psadbw xmm0, xmm1 | ||
| 1213 | movdqa xmm1, xmm0 | ||
| 1214 | psrldq xmm1, 0x08 | ||
| 1215 | pslldq xmm0, 0x08 | ||
| 1216 | psrldq xmm0, 0x08 | ||
| 1217 | paddw xmm0, xmm1 | ||
| 1218 | |||
| 1219 | movzx r3, byte [r1+r2-0x01] | ||
| 1220 | movzx r4, byte [r1+2*r2-0x01] | ||
| 1221 | add r3, r4 | ||
| 1222 | lea r1, [r1+r2] | ||
| 1223 | LOAD_2_LEFT_AND_ADD | ||
| 1224 | LOAD_2_LEFT_AND_ADD | ||
| 1225 | LOAD_2_LEFT_AND_ADD | ||
| 1226 | LOAD_2_LEFT_AND_ADD | ||
| 1227 | LOAD_2_LEFT_AND_ADD | ||
| 1228 | LOAD_2_LEFT_AND_ADD | ||
| 1229 | LOAD_2_LEFT_AND_ADD | ||
| 1230 | add r3, 0x10 | ||
| 1231 | movd xmm1, r3d | ||
| 1232 | paddw xmm0, xmm1 | ||
| 1233 | psrld xmm0, 0x05 | ||
| 1234 | pmuludq xmm0, [mmx_01bytes] | ||
| 1235 | pshufd xmm0, xmm0, 0 | ||
| 1236 | |||
| 1237 | movdqa [r0], xmm0 | ||
| 1238 | movdqa [r0+0x10], xmm0 | ||
| 1239 | movdqa [r0+0x20], xmm0 | ||
| 1240 | movdqa [r0+0x30], xmm0 | ||
| 1241 | movdqa [r0+0x40], xmm0 | ||
| 1242 | movdqa [r0+0x50], xmm0 | ||
| 1243 | movdqa [r0+0x60], xmm0 | ||
| 1244 | movdqa [r0+0x70], xmm0 | ||
| 1245 | movdqa [r0+0x80], xmm0 | ||
| 1246 | movdqa [r0+0x90], xmm0 | ||
| 1247 | movdqa [r0+0xa0], xmm0 | ||
| 1248 | movdqa [r0+0xb0], xmm0 | ||
| 1249 | movdqa [r0+0xc0], xmm0 | ||
| 1250 | movdqa [r0+0xd0], xmm0 | ||
| 1251 | movdqa [r0+0xe0], xmm0 | ||
| 1252 | movdqa [r0+0xf0], xmm0 | ||
| 1253 | |||
| 1254 | pop r4 | ||
| 1255 | pop r3 | ||
| 1256 | ret | ||
| 1257 | |||
| 1258 | ;*********************************************************************** | ||
| 1259 | ; | ||
| 1260 | ;int32_t WelsSmpleSatdThree4x4_sse2( uint8_t *pDec, int32_t iLineSizeDec, uint8_t *pEnc, int32_t iLinesizeEnc, | ||
| 1261 | ; uint8_t* pRed, int32_t* pBestMode, int32_t, int32_t, int32_t); | ||
| 1262 | ; | ||
| 1263 | ;*********************************************************************** | ||
| 1264 | %ifdef X86_ASM | ||
| 1265 | WELS_EXTERN WelsSmpleSatdThree4x4_sse2 | ||
| 1266 | align 16 | ||
| 1267 | WelsSmpleSatdThree4x4_sse2: | ||
| 1268 | push ebx | ||
| 1269 | push esi | ||
| 1270 | push edi | ||
| 1271 | mov eax, [esp+24];p_enc | ||
| 1272 | mov ebx, [esp+28];linesize_enc | ||
| 1273 | |||
| 1274 | ; load source 4x4 samples and Hadamard transform | ||
| 1275 | movd xmm0, [eax] | ||
| 1276 | movd xmm1, [eax+ebx] | ||
| 1277 | lea eax , [eax+2*ebx] | ||
| 1278 | movd xmm2, [eax] | ||
| 1279 | movd xmm3, [eax+ebx] | ||
| 1280 | punpckldq xmm0, xmm2 | ||
| 1281 | punpckldq xmm1, xmm3 | ||
| 1282 | |||
| 1283 | pxor xmm6, xmm6 | ||
| 1284 | punpcklbw xmm0, xmm6 | ||
| 1285 | punpcklbw xmm1, xmm6 | ||
| 1286 | |||
| 1287 | movdqa xmm2, xmm0 | ||
| 1288 | paddw xmm0, xmm1 | ||
| 1289 | psubw xmm2, xmm1 | ||
| 1290 | SSE2_XSawp qdq, xmm0, xmm2, xmm3 | ||
| 1291 | |||
| 1292 | movdqa xmm4, xmm0 | ||
| 1293 | paddw xmm0, xmm3 | ||
| 1294 | psubw xmm4, xmm3 | ||
| 1295 | |||
| 1296 | movdqa xmm2, xmm0 | ||
| 1297 | punpcklwd xmm0, xmm4 | ||
| 1298 | punpckhwd xmm4, xmm2 | ||
| 1299 | |||
| 1300 | SSE2_XSawp dq, xmm0, xmm4, xmm3 | ||
| 1301 | SSE2_XSawp qdq, xmm0, xmm3, xmm5 | ||
| 1302 | |||
| 1303 | movdqa xmm7, xmm0 | ||
| 1304 | paddw xmm0, xmm5 | ||
| 1305 | psubw xmm7, xmm5 | ||
| 1306 | |||
| 1307 | SSE2_XSawp qdq, xmm0, xmm7, xmm1 | ||
| 1308 | |||
| 1309 | ; Hadamard transform results are saved in xmm0 and xmm2 | ||
| 1310 | movdqa xmm2, xmm0 | ||
| 1311 | paddw xmm0, xmm1 | ||
| 1312 | psubw xmm2, xmm1 | ||
| 1313 | |||
| 1314 | ; load top boundary samples: [a b c d] | ||
| 1315 | mov eax, [esp+16];p_dec | ||
| 1316 | sub eax, [esp+20];linesize_dec | ||
| 1317 | movzx ecx, byte [eax] | ||
| 1318 | movzx edx, byte [eax+1] | ||
| 1319 | movzx esi, byte [eax+2] | ||
| 1320 | movzx edi, byte [eax+3] | ||
| 1321 | |||
| 1322 | ; get the transform results of top boundary samples: [a b c d] | ||
| 1323 | add edx, ecx ; edx = a + b | ||
| 1324 | add edi, esi ; edi = c + d | ||
| 1325 | add ecx, ecx ; ecx = a + a | ||
| 1326 | add esi, esi ; esi = c + c | ||
| 1327 | sub ecx, edx ; ecx = a + a - a - b = a - b | ||
| 1328 | sub esi, edi ; esi = c + c - c - d = c - d | ||
| 1329 | add edi, edx ; edi = (a + b) + (c + d) | ||
| 1330 | add edx, edx | ||
| 1331 | sub edx, edi ; edx = (a + b) - (c + d) | ||
| 1332 | add esi, ecx ; esi = (a - b) + (c - d) | ||
| 1333 | add ecx, ecx | ||
| 1334 | sub ecx, esi ; ecx = (a - b) - (c - d) ; [edi edx ecx esi] | ||
| 1335 | |||
| 1336 | movdqa xmm6, xmm0 | ||
| 1337 | movdqa xmm7, xmm2 | ||
| 1338 | movd xmm5, edi ; store the edi for DC mode | ||
| 1339 | pxor xmm3, xmm3 | ||
| 1340 | pxor xmm4, xmm4 | ||
| 1341 | pinsrw xmm3, edi, 0 | ||
| 1342 | pinsrw xmm3, esi, 4 | ||
| 1343 | psllw xmm3, 2 | ||
| 1344 | pinsrw xmm4, edx, 0 | ||
| 1345 | pinsrw xmm4, ecx, 4 | ||
| 1346 | psllw xmm4, 2 | ||
| 1347 | |||
| 1348 | ; get the satd of H | ||
| 1349 | psubw xmm0, xmm3 | ||
| 1350 | psubw xmm2, xmm4 | ||
| 1351 | |||
| 1352 | WELS_AbsW xmm0, xmm1 | ||
| 1353 | WELS_AbsW xmm2, xmm1 | ||
| 1354 | paddusw xmm0, xmm2 | ||
| 1355 | SUMW_HORIZON1 xmm0, xmm1 ; satd of V is stored in xmm0 | ||
| 1356 | |||
| 1357 | ; load left boundary samples: [a b c d]' | ||
| 1358 | mov eax, [esp+16] | ||
| 1359 | mov ebx, [esp+20] | ||
| 1360 | movzx ecx, byte [eax-1] | ||
| 1361 | movzx edx, byte [eax+ebx-1] | ||
| 1362 | lea eax , [eax+2*ebx] | ||
| 1363 | movzx esi, byte [eax-1] | ||
| 1364 | movzx edi, byte [eax+ebx-1] | ||
| 1365 | |||
| 1366 | ; get the transform results of left boundary samples: [a b c d]' | ||
| 1367 | add edx, ecx ; edx = a + b | ||
| 1368 | add edi, esi ; edi = c + d | ||
| 1369 | add ecx, ecx ; ecx = a + a | ||
| 1370 | add esi, esi ; esi = c + c | ||
| 1371 | sub ecx, edx ; ecx = a + a - a - b = a - b | ||
| 1372 | sub esi, edi ; esi = c + c - c - d = c - d | ||
| 1373 | add edi, edx ; edi = (a + b) + (c + d) | ||
| 1374 | add edx, edx | ||
| 1375 | sub edx, edi ; edx = (a + b) - (c + d) | ||
| 1376 | add esi, ecx ; esi = (a - b) + (c - d) | ||
| 1377 | add ecx, ecx | ||
| 1378 | sub ecx, esi ; ecx = (a - b) - (c - d) ; [edi edx ecx esi]' | ||
| 1379 | |||
| 1380 | ; store the transform results in xmm3 | ||
| 1381 | movd xmm3, edi | ||
| 1382 | pinsrw xmm3, edx, 1 | ||
| 1383 | pinsrw xmm3, ecx, 2 | ||
| 1384 | pinsrw xmm3, esi, 3 | ||
| 1385 | psllw xmm3, 2 | ||
| 1386 | |||
| 1387 | ; get the satd of V | ||
| 1388 | movdqa xmm2, xmm6 | ||
| 1389 | movdqa xmm4, xmm7 | ||
| 1390 | psubw xmm2, xmm3 | ||
| 1391 | WELS_AbsW xmm2, xmm1 | ||
| 1392 | WELS_AbsW xmm4, xmm1 | ||
| 1393 | paddusw xmm2, xmm4 | ||
| 1394 | SUMW_HORIZON1 xmm2, xmm1 ; satd of H is stored in xmm2 | ||
| 1395 | |||
| 1396 | ; DC result is stored in xmm1 | ||
| 1397 | add edi, 4 | ||
| 1398 | movd xmm1, edi | ||
| 1399 | paddw xmm1, xmm5 | ||
| 1400 | psrlw xmm1, 3 | ||
| 1401 | movdqa xmm5, xmm1 | ||
| 1402 | psllw xmm1, 4 | ||
| 1403 | |||
| 1404 | ; get the satd of DC | ||
| 1405 | psubw xmm6, xmm1 | ||
| 1406 | WELS_AbsW xmm6, xmm1 | ||
| 1407 | WELS_AbsW xmm7, xmm1 | ||
| 1408 | paddusw xmm6, xmm7 | ||
| 1409 | SUMW_HORIZON1 xmm6, xmm1 ; satd of DC is stored in xmm6 | ||
| 1410 | |||
| 1411 | ; comparing order: DC H V | ||
| 1412 | mov edx, [esp+32] | ||
| 1413 | movd eax, xmm6 | ||
| 1414 | movd edi, xmm2 | ||
| 1415 | movd esi, xmm0 | ||
| 1416 | and eax, 0xffff | ||
| 1417 | shr eax, 1 | ||
| 1418 | and edi, 0xffff | ||
| 1419 | shr edi, 1 | ||
| 1420 | and esi, 0xffff | ||
| 1421 | shr esi, 1 | ||
| 1422 | add eax, [esp+40] | ||
| 1423 | add edi, [esp+44] | ||
| 1424 | add esi, [esp+48] | ||
| 1425 | cmp ax, di | ||
| 1426 | jg near not_dc | ||
| 1427 | cmp ax, si | ||
| 1428 | jg near not_dc_h | ||
| 1429 | |||
| 1430 | ; for DC mode | ||
| 1431 | movd ebx, xmm5 | ||
| 1432 | imul ebx, 0x01010101 | ||
| 1433 | movd xmm5, ebx | ||
| 1434 | pshufd xmm5, xmm5, 0 | ||
| 1435 | movdqa [edx], xmm5 | ||
| 1436 | mov ebx, [esp+36] | ||
| 1437 | mov dword [ebx], 0x02 | ||
| 1438 | pop edi | ||
| 1439 | pop esi | ||
| 1440 | pop ebx | ||
| 1441 | ret | ||
| 1442 | |||
| 1443 | not_dc: | ||
| 1444 | cmp di, si | ||
| 1445 | jg near not_dc_h | ||
| 1446 | |||
| 1447 | ; for H mode | ||
| 1448 | SSE_DB_1_2REG xmm6, xmm7 | ||
| 1449 | mov eax, [esp+16] | ||
| 1450 | mov ebx, [esp+20] | ||
| 1451 | movzx ecx, byte [eax-1] | ||
| 1452 | movd xmm0, ecx | ||
| 1453 | pmuludq xmm0, xmm6 | ||
| 1454 | |||
| 1455 | movzx ecx, byte [eax+ebx-1] | ||
| 1456 | movd xmm1, ecx | ||
| 1457 | pmuludq xmm1, xmm6 | ||
| 1458 | %if 1 | ||
| 1459 | punpckldq xmm0, xmm1 | ||
| 1460 | %else | ||
| 1461 | unpcklps xmm0, xmm1 | ||
| 1462 | %endif | ||
| 1463 | lea eax, [eax+ebx*2] | ||
| 1464 | movzx ecx, byte [eax-1] | ||
| 1465 | movd xmm2, ecx | ||
| 1466 | pmuludq xmm2, xmm6 | ||
| 1467 | |||
| 1468 | movzx ecx, byte [eax+ebx-1] | ||
| 1469 | movd xmm3, ecx | ||
| 1470 | pmuludq xmm3, xmm6 | ||
| 1471 | %if 1 | ||
| 1472 | punpckldq xmm2, xmm3 | ||
| 1473 | punpcklqdq xmm0, xmm2 | ||
| 1474 | %else | ||
| 1475 | unpcklps xmm2, xmm3 | ||
| 1476 | unpcklpd xmm0, xmm2 | ||
| 1477 | %endif | ||
| 1478 | movdqa [edx],xmm0 | ||
| 1479 | |||
| 1480 | mov eax, edi | ||
| 1481 | mov ebx, [esp+36] | ||
| 1482 | mov dword [ebx], 0x01 | ||
| 1483 | |||
| 1484 | pop edi | ||
| 1485 | pop esi | ||
| 1486 | pop ebx | ||
| 1487 | ret | ||
| 1488 | not_dc_h: | ||
| 1489 | ; for V mode | ||
| 1490 | mov eax, [esp+16] | ||
| 1491 | sub eax, [esp+20] | ||
| 1492 | movd xmm0, [eax] | ||
| 1493 | pshufd xmm0, xmm0, 0 | ||
| 1494 | movdqa [edx],xmm0 | ||
| 1495 | |||
| 1496 | mov eax, esi | ||
| 1497 | mov ebx, [esp+36] | ||
| 1498 | mov dword [ebx], 0x00 | ||
| 1499 | |||
| 1500 | pop edi | ||
| 1501 | pop esi | ||
| 1502 | pop ebx | ||
| 1503 | ret | ||
| 1504 | %endif | ||
| 1505 | |||